• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

Deployment error NoClassDefFoundError: org.hibernate.cfg.Configuration on Oracle 11g App Server

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I'm currently trying to deploy a spring/hibernate application to Oracle 11g Application Server.

Every time we deploy the war file we get the following error:-

Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonSessionFactory' defined in ServletContext resource [/WEB-INF/spring.hibernate.webservices.weblogic-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org.hibernate.cfg.Configuration
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org.hibernate.cfg.Configuration
Caused by: java.lang.NoClassDefFoundError: org.hibernate.cfg.Configuration

This is part of the structure within my deployed war file:-

WEB-INF
| |
classes lib

Using spring2.5.6 jar files & hibernate3.1.2.jar within lib

Not sure why this should happen since I have org.hibernate.cfg.Configuration within the hinernate3.1.2.jar.
It's as if the lib directory is not been seen?
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
I have been coming back to this problem for over 3 weeks .
Not sure how to solve this one
Any help would really be appreciated.

Mat
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm... I am not sure what the problem could be. Try moving the hibernate jar to your server library and let us know if that fixes the problem. It might be a problem with a classloader. Is hibernate / spring already present in the container's classpath ? If Spring is present in the CP I can see why this will be a problem.
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepak,
thanks you for replying to my email.

I have just checked and we have the following jar files located on the server:-

com.bea.core.weblogic.spring.instrument_1.0.0.0.jar
com.bea.core.repackaged.springframework.spring_1.0.0.0_2-5-3.jar
com.bea.core.repackaged.springframework.pitchfork_1.2.0.0_1-0.jar

could not find any hibernate files on the server.

I currently have the following files under WEB-INF\lib deployed within my WAR.

antlr-2.7.6rc1.jar, aopalliance.jar, aopalliance2.0.1.jar, asm-attrs.jar, asm.jar
cglib-2.1.3.jar, dom4j-1.6.1.jar, ehcache-1.1.jar ,ehcache-1.2.3.jar ,hibernate3.1.2.jar
javassist-3.4.GA.jar, jstl.jar ,log4j-1.2.14.jar ,quartz-all-1.6.1.jar ,servlet.jar
slf4j-log4j12-1.5.0.jar
spring-aop2.5.6.jar ,spring-beans2.5.6.jar ,spring-context-support2.5.6.jar ,spring-context2.5.6.jar
,spring-core2.5.6.jar, spring-dao2.0.1.jar, spring-jdbc2.5.6.jar, spring-jms2.5.6.jar
,spring-modules-jakarta-commons0.9.jar, spring-modules-validation0.9.jar, spring-orm2.5.6.jar
,spring-test2.5.6.jar, spring-tx2.5.6.jar, spring-web2.5.6.jar,spring-webmvc-portlet2.5.6.jar
,spring-webmvc-struts2.5.6.jar, spring-webmvc2.5.6.jar,
standard.jar

Do I have to use a weblogic-application.xml descriptor that contains something like this:-

<prefer-application-packages>
<package-name>antlr*</package-name>
<package-name>spring*</package-name>
</prefer-application-packages>

thus telling the server to use my war classes instead of the server classes within its classpath.

Not sure about the format needed within a weblogic-application.xml ?
Am I correct in placing my jar files under WEB-INF\lib ?
Do I have to configure my MANIFEST.MF file (i.e. class-Path) ?

I have a lot of questions

Any help would really be appreciated

Mat






 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

thanks you for replying to my email.



I hope you meant post / thread. I did not reply over email.


com.bea.core.weblogic.spring.instrument_1.0.0.0.jar
com.bea.core.repackaged.springframework.spring_1.0.0.0_2-5-3.jar
com.bea.core.repackaged.springframework.pitchfork_1.2.0.0_1-0.jar



Those are instrumentation jars and BEAs own repackaged jars to be used by WL I would presume.


Do I have to use a weblogic-application.xml descriptor that contains something like this:-

<prefer-application-packages>
<package-name>antlr*</package-name>
<package-name>spring*</package-name>
</prefer-application-packages>



Good work Mat. That should help

Am I correct in placing my jar files under WEB-INF\lib ?



Yes you are.

Do I have to configure my MANIFEST.MF file (i.e. class-Path) ?



Nope. Not needed. If it is under WEB-INF/lib it should work. You need a manifest only if you place the jars on the WARs root.

To find out which class is loaded from which jar, just use the -verbose option with sun JDK. Your console will be flooded however and the server will be slow just from printing all that information
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepak,
after deploying again with the new weblogic-application.xml, I get the following server error:-

<Warning> <J2EE> <BEA-160195> <The application version lifecycle event listener oracle.security.jps.wls.listeners.JpsAppVersionLifecycleListener is ignored because the application em is not versioned.>
org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver initHandlerMappings
WARNING: Ignoring namespace handler [org.springmodules.validation.bean.conf.namespace.ValidatorNamespaceHandler]: problem with handler class file or dependent class
java.lang.NoSuchFieldError: IS_JAVA_1_6
at org.springmodules.validation.util.LibraryUtils.<clinit>(LibraryUtils.java:45)
at org.springmodules.validation.bean.conf.namespace.ValidatorNamespaceHandler.init(ValidatorNamespaceHandler.java:51)
at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.initHandlerMappings(DefaultNamespaceHandlerResolver.java:123)
at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.<init>(DefaultNamespaceHandlerResolver.java:97)
at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.<init>

Have you any idea

Mat
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The libraries seem mixed up. A compile time library class had this field in its class definition. But at runtime it was replaced by a class whose definition is different and does not contain the said field. Probably another outdated jar that is loaded from yours truly - weblogic ?

Ever since WL 9.2 classpath and classloading have become hell. LibraryUtils line 45 should throw some light into what is going on. Try to load all spring related jars from your WAR library.
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepak,
I will have a look at this on monday.
Thanks for your help so far

Mat
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepak,

just got back to this problem. Found out that weblogic 11g classloader doesn't seem to recognize
the jar files included in a war. You have to tell weblogic to look into the war via weblogic.xml under WEB-INF/
as follows:-

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-web-app.xsd">
<context-root>/myApp</context-root>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>

This seemed to sort out the Deployment error NoClassDefFoundError: org.hibernate.cfg.Configuration

I'm now getting the following:-
Servlet: "context" failed to preload on startup in Web application: "spring.hibernate.webservices.weblogic.war". org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonSessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.InternalError: erroneous handlers at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1336)

Do I have to update the MANIFEST.MF under META-INF to specify the server classpath jar files that I need to use?
I tried doing this within MANIFEST.MF as follows:-

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: XXXX
Built-By: XXXX
Weblogic-Application-Version: XX.XX
Class-Path: sys_manifest_classpath/ lib/ features/

But I still got the above error.

This problem is

Can any body help me pass this as I think I'm getting close

Mat



 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You have to tell weblogic to look into the war via weblogic.xml under WEB-INF/
as follows:-



Yep. Thats one solution

I'm now getting the following:-
Servlet: "context" failed to preload on startup in Web application: "spring.hibernate.webservices.weblogic.war".



I suspect there is a classnotfoundException hiding behind that problem. Take a look at the server's log -> weblogic.log. Since the Classnotfound is propagated to the server, it should have logged the exception. Once you know which class is missing, simply include that in WEB-INF/lib. Previously, this class was probably loaded from system classpath. But since you asked weblogic to load it from your application and it is missing, it threw the Classnotfound exception.

Let us know if this was the problem. I wonder what jars are missing in your lib.
 
Mat Anthony
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepak,
you were correct that I had missing jar files within WEB-INF/lib dir.

I'm now getting the folling error:-

Servlet: "context" failed to preload on startup in Web application: "spring.hibernate.webservices.weblogic.war". org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy. You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.

I have checked the lib dir and it does contain the following:-
commons-logging.jar
and log4j-1.2.15.jar

If I remove commons-logging.jar, I get a class not found error on deployment.

Any ideas

Mat

 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The commons logging has an interface and an implementation. The LogFactory class from the interface/skeleton side might have been loaded from elsewhere while the implementation is loaded by your application classloader. hmmm... check where the LogFactory class is loaded from by using the -verbose switch when running the server. This will create tons of logs so beware.

This link can also help -> http://articles.qos.ch/classloader.html

It lists the same problem that you have but for a scenario that details child first loading behaviour
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spent a whole afternoon trying to fix this issue. We confirmed that:

- spring-modules-validation0.9.jar called a IS_JAVA_1_6 field that isn't defined
- Apache's commons-lang library provides the IS_JAVA_X_X fields
- the error occurs when commons-lang is version 2.1 (when there was no java 1.6 yet)
- the commons-lang version 2.3 defines IS_JAVA_1_6
- adding the correct commons-lang(v2.3) to your war file does not fix the problem
- adding additional LIB paths to the setEnv script in "<oracle>\user-modules\<app>\bin" with the correct commons-lang does not fix the problem

What fixes the problem is to manually replace WebLogic's commons-lang library located in "...\Oracle\Middleware\modules\". Replace the apache-commons-lang library file with the commons-lang 2.3. Make sure that the name of the v2.3 library is the original v2.1 library name (yes, it's a hack, renaming the 2.3 library to the 2.1 library)

It worked for me. I hope it works for you too.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic