|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 6 of 6
<library-ref>
<library-name>trinidad</library-name>
</library-ref>
The process for deploying libraries to OC4J is different from the process for WebLogic. For example, to use a TimesTen data
source, you must point the OC4J to the locations of the TimesTen JAR files by running through the following steps:
shared-lib/TimesTen/5.0 directory to the OC4J home.
JARs in this directory.
server.xml file (located in the oc4j-home/config directory):
<shared-library name="timesten" version="5.0" library-compatible="true">
<code-source path="pad/shared-lib/timesten/5.0/ttjdbc5.jar"/>
</shared-library>
application.xml file (located in the oc4j-home/config directory):
<imported-shared-libraries>
<import-shared-library name="timesten"/>
</imported-shared-libraries>
By using libraries, you no longer need to add the JARs to an EAR or a WAR file.
As I mentioned in this article's introduction, sometimes an application server's own system classes can interfere with the classes in the framework you're using. I'll demonstrate this issue and a solution for WebLogic through an example that uses the Hibernate ORM framework.
Commonly, an ORM framework uses a custom-defined query language. Hibernate's query language is HQL. An HQL query is composed of Java objects instead of database objects. In order for the query to communicate with the database, an SQL query must be parsed from the query language. To this end, Hibernate uses a query parser -- the ANTLR library. Unfortunately, WebLogic uses its own version of ANTLR in its system classpath, and it is loaded before classes related to the application are loaded. Because the WebLogic server does not have a proper classloading isolation mechanism, WebLogic doesn't recognize the Hibernate classes in the context of the application. WebLogic fixes this issue by prefixing the names of packages. However, the ANTLR version used in the WebLogic server does not have this prefix.
A workaround is to make sure that the Hibernate classes are loaded before the system classes are loaded. You can accomplish this by editing the setDomainEnv file to include this section:
@REM SET THE CLASSPATH set CLASSPATH=..\..\..\wlserver_10.3\Hibernate\antlr-2.7.6.jar set CLASSPATH=%CLASSPATH%;..\..\..\wlserver_10.3\Hibernate\asm.jar set CLASSPATH=%CLASSPATH%;..\..\..\wlserver_10.3\Hibernate\asm-attrs.jar set CLASSPATH=%CLASSPATH%;..\..\..\wlserver_10.3\Hibernate\cglib-2.1.3.jar set CLASSPATH=%CLASSPATH%;..\..\..\wlserver_10.3\Hibernate\commons-collections-2.1.1.jar set CLASSPATH=%CLASSPATH%;..\..\..\wlserver_10.3\Hibernate\commons-logging-1.0.4.jar set CLASSPATH=%CLASSPATH%;..\..\..\wlserver_10.3\Hibernate\dom4j-1.6.1.jar set CLASSPATH=%CLASSPATH%;..\..\..\wlserver_10.3\Hibernate\ehcache-1.2.3.jar set CLASSPATH=%CLASSPATH%;..\..\..\wlserver_10.3\Hibernate\hibernate3.jar set CLASSPATH=%CLASSPATH%;..\..\..\wlserver_10.3\Hibernate\jta.jar set CLASSPATH=%CLASSPATH%;..\..\..\wlserver_10.3\TimesTen\ttjdbc5.jar set CLASSPATH=%CLASSPATH%;%PRE_CLASSPATH%;%WEBLOGIC_CLASSPATH%;...
If you want to use Hibernate on OC4J, you must remove the TopLink library, which also contains classes that interfere with
Hibernate. To remove TopLink, add the following to the application.xml file:
<imported-shared-libraries>
<remove-inherited name="oracle.toplink"/>
</imported-shared-libraries>
With all the Hibernate classes in the right place, Hibernate operates without any problems on both OC4J and the WebLogic server.
When you create an enterprise Java application, thoroughly understanding your application server is as important as mastering your development tools and framework. In this article, you've learned how to tweak WebLogic and OC4J to use some popular third-party libraries, and to enable EJBs to take advantage of JNDI lookups and Java EE resource injection. By delegating resource management to the application server, you can reduce development time, reduce your application's complexity, and improve your application's performance.
After studying at the Delft University of Technology, Ren� van Wijk worked at TNO for six years as an analyst/project manager. Since 2006, he has worked at Transfer Solutions, where he builds systems and educates new employees in Java EE technologies.
Read more about Tools & Methods in JavaWorld's Tools & Methods section.