1
votes

We have an .ear file that is running normal in a WebLogic 10.3.6 application server. The .ear uses Spring 3.0.5 and Hibernate 3.5.2.

If we deploy the same .ear file in another WebLogic 10.3.6 server, we get the next error.

org.springframework.web.context.ContextLoader initWebApplicationContext
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'filterService': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private nl.surf.adapter.generic.dao.MessageFilterDAO nl.surf.adapter.generic.service.FilterService.messageFilterDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/domain-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private nl.surf.adapter.generic.dao.MessageFilterDAO nl.surf.adapter.generic.service.FilterService.messageFilterDAO; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/domain-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/domain-config.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError
Caused by: java.lang.NoClassDefFoundError
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration

I've tried several solutions:

  • Place hibernate3.jar in .war/WEB-INF/lib (all jars are now in .ear/lib)
  • Use <prefer-web-inf-classes>true</prefer-web-inf-classes> in .war/WEB-INF/weblogic.xml

Nothing seems to work. I'm kind of lost here...

1
Solved the problem myself. Can't answer yet, so answer follows tomorrow.tsluijter
I see in the exception thrown, hibernate annotation bootstraping is missing in web.xml. Right?Sym-Sym
I'm experiencing the same issue with Velocity. I'm interested in the approach to get around this NoClassDefFoundError issue for org/apache/velocity/app/VelocityEngine.Jason TEPOORTEN

1 Answers

1
votes

After some extensive searching on the web and trial and error changes on the .ear, i've found the solution for my problem.

I've changed file META-INF/weblogic-application.xml and added the tags beneath inside tag <weblogic-application>

<prefer-application-packages>
  <package-name>org.apache.*</package-name>
  <package-name>antlr.*</package-name>
</prefer-application-packages>