This troubles you somewhat because you've taken the usual approach of putting 3rd party libraries to be shared into the applib directory of the OC4J instance -- so the classes should be available!
Well the problem here is that when the datasource is being constructed by EM, the classloader that is used is one that is obtained from the ascontrol application. And if you look carefully at the configuration of the ascontrol application, you'll see that it specifically removes the global.libraries shared-library from its list of imports. And guess what -- the global.libraries shared-library is defined with a single code-source -- that being the contents of the applib directory. Therefore the ascontrol application does not see the mysqlconnector.jar file you put into the applib directory. At runtime OC4J would see it, so if you manually add the datasource definition it'll work fine -- but using EM to construct the MySQL datasource requires it to see the jar file.
The change to make this work is quite easy and you have few options:
1. You can edit the orion-application.xml file of the deployed ascontrol application, and comment out the line that removes the importing of the global.libraries.xml file:
2. You continue to use the convenience of applib to make the driver available container wide, but instead of reconfiguring the ascontrol application to not remove the global.libraries, you just drop the mysql-connector.jar file into the WEB-INF/lib directory of the ascontrol application, so it is able to locate the specified class from its own set of libraries. To to that, copy the mysql-connector.jar file into $ORACLE_HOME/j2ee/home/applications/ascontrol/ascontrol/web-inf/lib directory. And then restart either the ascontrol application, or the OC4J instance itself to ensure the new library is visible.
<imported-shared-libraries>
<--
<remove-inherited name="global.libraries"/>
-->
<import-shared-library name="oracle.xml.security"/>
<import-shared-library name="oracle.xml.security"/>
</imported-shared-libraries>
3. Instead of using the convenience of the applib directory, you can deploy the MySQL connector as a named/versioned shared-library and then specifically import it into applications where you need it. This would for example need to be done in the application you deploy that needs to connect to MySQL and where corresponding datasource is defined, and also in the ascontrol application itself. . To do the latter, since you can't use EM to configure itself, you'd need to edit the $ORACLE_HOME/j2ee/home/application-deployments/ascontrol/orion-application.xml file and manually add the import statement to pull in the MySQL shared-library:
<imported-shared-libraries>
<remove-inherited name="global.libraries"/>
<import-shared-library name="oracle.xml.security"/>
<import-shared-library name="oracle.xml.security"/>
<import-shared-library name="mysql.connector"/>
</imported-shared-libraries>
3 comments:
Fantastic! I was getting crazy already until I found this! Thanks!
Thank you. It worked like a peach!
Thank you Dost..
I was also facing the same problem.
thanks a lot.
Post a Comment