This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes Loading different version of Hibernate(3.3) in Jboss4.0.3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Loading different version of Hibernate(3.3) in Jboss4.0.3" Watch "Loading different version of Hibernate(3.3) in Jboss4.0.3" New topic
Author

Loading different version of Hibernate(3.3) in Jboss4.0.3

Prashant Vasudeo
Ranch Hand

Joined: Mar 25, 2003
Posts: 38
Hi All,

I am using Hibernate code 3.2.5GA and Annotations 3.3 with Jboss 4.0.3, which comes pre-packaged with Hibernate 3.1 jar.

I am facing classloading problem, as it takes 3.1 jar rather than 3.3 which is bundled in my .war file.

what i want that my application should use 3.3 jar packaged in my war file rather than from 3.1 jar

after reading these article...
http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration
http://java2.5341.com/msg/68204.html

I did following changes,

jboss-web.xml
--------------
<jboss-web>
<context-root>ABC</context-root>
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>
aaaa.com:loader=ABC.war
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>

jboss-app.xml
--------------
<jboss-app>
<class-loading>
<loader-repository>aaaa.com:loader=ABC.ear</loader-repository>
</class-loading>
</jboss-app>

I am using following structure of my ear file
/
ABC.war
META-INF/
application.xml
jboss-app.xml

Also I don't have access to jboss-service.xml, as it is not for a particluar jboss instance but for firm wide usage, so i cannot change anything in this file.

Can anybody tell me what is wrong in it or any other way to work

Prashant

[ January 30, 2008: Message edited by: Prashant Vasudeo ]
[ January 30, 2008: Message edited by: Prashant Vasudeo ]
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9956
    
163

Since your WAR is packaged in the EAR, you need not do anything related to classloading configuration in the jboss-web.xml. So your jboss-web.xml can be something like :



Then in the jboss-app.xml you add something like this:



Try these changes and see if it works. If not, then post the exact details as to what is happening.


[My Blog] [JavaRanch Journal]
Prashant Vasudeo
Ranch Hand

Joined: Mar 25, 2003
Posts: 38
in Jboss-app.xml
org.myapp:loader=MyAppClassLoader

what is "MyAppClassLoader"...Do I need to create my own classloader or its value will be "myear.ear" ?

Prashant
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9956
    
163

org.myapp:loader=MyAppClassLoader is just a unique name. You can give any unique name(actually there's a pre-defined format for MBean Object names), as per your wish. JBoss will create a classloader for your application with this name. In general, the name looks like:

Prashant Vasudeo
Ranch Hand

Joined: Mar 25, 2003
Posts: 38
Hi done the changes

Still picks the 3.1 hibernate and not 3.3

-------------------------------------------------
[org.hibernate.cfg.Environment] Hibernate 3.1 [org.hibernate.cfg.Environment] hibernate.properties not found [org.hibernate.cfg.Environment] using CGLIB reflection optimizer [org.hibernate.cfg.Environment] using JDK 1.4 java.sql.Timestamp handling [org.hibernate.cfg.Configuration] configuring from resource: /hibernate.qa.cfg.xml [org.hibernate.cfg.Configuration] Configuration resource: /hibernate.qa.cfg.xml [org.hibernate.util.DTDEntityResolver] trying to locate http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath under org/hibernate/ [org.hibernate.util.DTDEntityResolver] found http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath [org.hibernate.cfg.Configuration] dialect=org.hibernate.dialect.DB2Dialect [org.hibernate.cfg.Configuration] show_sql=true [org.hibernate.cfg.Configuration] hibernate.format_sql=false [org.hibernate.cfg.Configuration] use_outer_join=false

My unix server is configured for server as "all" and not "default"

I downloaded Jboss4.0.3 Windows version and without changing any thing i deployed the war file with jboss-web.xml It is picking jar from WEB-INF/lin folder i.e 3.3 jar are getting loaded.

Any difference between server "all" and "default" ?

Prashant
[ January 31, 2008: Message edited by: Prashant Vasudeo ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Loading different version of Hibernate(3.3) in Jboss4.0.3
 
Similar Threads
Using your own log4j.properties file
Issue with JBoss logging for different jboss instances running on same machine
log4j.properties in jboss4.0.3
Clasloaders in jboss
deploying two identical webapps independently