File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes java.lang.NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "java.lang.NoClassDefFoundError" Watch "java.lang.NoClassDefFoundError" New topic
Author

java.lang.NoClassDefFoundError

Rodrigo Del Bianco
Greenhorn

Joined: Jan 09, 2009
Posts: 6
Hello all

I'm using jsf with richfaces, jpa, hibernate, JBoss 4.2 and MySQL.
I get an error when i try to access a specific page, but the error aren't guiding me to problem root.
Detail: class "br/com/inforen/model/GrupoFamiliar" exists and is there!

thanks a lot!

Trace:
exception

javax.servlet.ServletException: Servlet execution threw an exception
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

root cause

java.lang.NoClassDefFoundError: WEB-INF/classes/br/com/inforen/model/GrupoFamiliar (wrong name: br/com/inforen/model/GrupoFamiliar)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:675)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
java.net.URLClassLoader.access$100(URLClassLoader.java:56)
java.net.URLClassLoader$1.run(URLClassLoader.java:195)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:188)
org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:682)
org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:662)
java.lang.ClassLoader.loadClass(ClassLoader.java:316)
org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:200)
org.jboss.mx.loading.UnifiedLoaderRepository3.loadClassFromClassLoader(UnifiedLoaderRepository3.java:312)
org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:189)
org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
java.lang.ClassLoader.loadClass(ClassLoader.java:306)
java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:579)
java.lang.ClassLoader.loadClass(ClassLoader.java:251)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1345)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:242)
org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:112)
org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1008)
org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1080)
org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:871)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:758)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253)
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
br.com.inforen.controller.BensJpaController.<init>(BensJpaController.java:37)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
java.lang.Class.newInstance0(Class.java:350)
java.lang.Class.newInstance(Class.java:303)
com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:277)
com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:546)
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
br.com.inforen.mb.BensController.<init>(BensController.java:43)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
java.lang.Class.newInstance0(Class.java:350)
java.lang.Class.newInstance(Class.java:303)
com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:277)
com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:546)
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45)
org.apache.el.parser.AstValue.getTarget(AstValue.java:42)
org.apache.el.parser.AstValue.invoke(AstValue.java:127)
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
javax.faces.component.UICommand.broadcast(UICommand.java:383)
org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
To start, the exception message at its own is already odd.

I would expect the full qualified class name here, but it shows a file system path. Aren't you specifying file system paths instead of class names somewhere in the Hibernate configuration?
Rodrigo Del Bianco
Greenhorn

Joined: Jan 09, 2009
Posts: 6
Yes, the exception don't help.

* One more information, i'm using a Mac OS Leopard.
I looked for something odd and didn't find anything.
I mapped class like this: <mapping class="br.com.inforen.model.GrupoFamiliar"/>

Bauke Scholtz wrote:To start, the exception message at its own is already odd.

I would expect the full qualified class name here, but it shows a file system path. Aren't you specifying file system paths instead of class names somewhere in the Hibernate configuration?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Oh, I now see that you're using JPA. Where is the persistence.xml located? It should be in WEB-INF/classes/META-INF.
Rodrigo Del Bianco
Greenhorn

Joined: Jan 09, 2009
Posts: 6
Yes, my first application using JPA.
It is located in WEB-INF/classes/META-INF.
I don't know what is wrong!
Some idea?

thanks
Rodrigo

Bauke Scholtz wrote:Oh, I now see that you're using JPA. Where is the persistence.xml located? It should be in WEB-INF/classes/META-INF.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Don't you have the persistence.xml duplicated at another locations?

Edit: you have a hibernate.cfg.xml file around as well? You shouldn't be using it when you use JPA.
Which tutorial/book are you using while implementing this?
Rodrigo Del Bianco
Greenhorn

Joined: Jan 09, 2009
Posts: 6
i used an IDE generated application for test.
i removed hibernate.cfg.xml, but this shouldn't be a problem, right? If my application have a part using hibernate sessions?
I put my persistence.xml in WebContent/META-INF. If i put in WEB-INF/classes/META-INF i get another exception because EntityManagerFactory can't find the persistence unit.

Bauke Scholtz wrote:Don't you have the persistence.xml duplicated at another locations?

Edit: you have a hibernate.cfg.xml file around as well? You shouldn't be using it when you use JPA.
Which tutorial/book are you using while implementing this?
Srini Mutpur
Greenhorn

Joined: Mar 29, 2008
Posts: 24
Try by putting persistence.xml in src/META-INf folder. your entity manager should find atleast from here.
Actually it should work even if its there in WEB-INF/classes/META-INF foler. I've also faced the same prob in IDE.


SCJP 1.5
Rodrigo Del Bianco
Greenhorn

Joined: Jan 09, 2009
Posts: 6
Ok, putting persistence.xml in src/META-INf folder i got the last exception with paths, opposite to full qualified class name.

Srini Jadcherla wrote:Try by putting persistence.xml in src/META-INf folder. your entity manager should find atleast from here.
Actually it should work even if its there in WEB-INF/classes/META-INF foler. I've also faced the same prob in IDE.
Srini Mutpur
Greenhorn

Joined: Mar 29, 2008
Posts: 24
Could you paste the exact exception which you are getting?


Rodrigo Del Bianco wrote:Ok, putting persistence.xml in src/META-INf folder i got the last exception with paths, opposite to full qualified class name.
Rodrigo Del Bianco
Greenhorn

Joined: Jan 09, 2009
Posts: 6
The exception:
I didn't find a cause for this exception occur.

javax.servlet.ServletException: Servlet execution threw an exception
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
root cause

java.lang.NoClassDefFoundError: WEB-INF/classes/br/com/inforen/model/GrupoFamiliar (wrong name: br/com/inforen/model/GrupoFamiliar)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClass(ClassLoader.java:675)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
java.net.URLClassLoader.access$100(URLClassLoader.java:56)
java.net.URLClassLoader$1.run(URLClassLoader.java:195)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:188)
org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:682)
org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:662)
java.lang.ClassLoader.loadClass(ClassLoader.java:316)
org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:200)
org.jboss.mx.loading.UnifiedLoaderRepository3.loadClassFromClassLoader(UnifiedLoaderRepository3.java:312)
org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:189)
org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
java.lang.ClassLoader.loadClass(ClassLoader.java:306)
java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:579)
java.lang.ClassLoader.loadClass(ClassLoader.java:251)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1345)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:242)
org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:112)
org.hibernate.ejb.Ejb3Configuration.classForName(Ejb3Configuration.java:1008)
org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1080)
org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:871)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:758)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:191)
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:253)
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
br.com.inforen.controller.BensJpaController.<init>(BensJpaController.java:46)
br.com.inforen.mb.BensController.<init>(BensController.java:44)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:494)
java.lang.Class.newInstance0(Class.java:350)
java.lang.Class.newInstance(Class.java:303)
com.sun.faces.config.ManagedBeanFactoryImpl.newInstance(ManagedBeanFactoryImpl.java:277)
com.sun.faces.application.ApplicationAssociate.createAndMaybeStoreManagedBeans(ApplicationAssociate.java:546)
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:82)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:45)
org.apache.el.parser.AstValue.getTarget(AstValue.java:42)
org.apache.el.parser.AstValue.invoke(AstValue.java:127)
org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
javax.faces.component.UICommand.broadcast(UICommand.java:383)
org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:321)
org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:296)
org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:253)
org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:466)
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

Srini Jadcherla wrote:Could you paste the exact exception which you are getting?


Rodrigo Del Bianco wrote:Ok, putting persistence.xml in src/META-INf folder i got the last exception with paths, opposite to full qualified class name.
Paréj Péter
Greenhorn

Joined: Oct 08, 2009
Posts: 2
...have the same here. Any solution?
Mircea De
Greenhorn

Joined: Sep 14, 2011
Posts: 4
Same issue here on JBoss 4.2.2 with class-loading isolation activated through jboss-web.xml. Has ANY body found a solution for this?
 
 
subject: java.lang.NoClassDefFoundError