aspose file tools*
The moose likes Tomcat and the fly likes Problem with JPA under TOMCAT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Problem with JPA under TOMCAT" Watch "Problem with JPA under TOMCAT" New topic
Author

Problem with JPA under TOMCAT

fabianoSouza Souza
Greenhorn

Joined: Oct 07, 2006
Posts: 9
Hello,, I have a small application that uses JSF and JPA with hibernate... when I run this app as stand alone app everithing goes fine... the problem happens when I run this app in TOMCAT.. I believe there should be some special config to run JPA under TOMCAT..

If someone knows anything about.. would apreciate..

here is my persistence.xml


this class return an entity manager


this is my ManagedBean


When I run this class everything works fine


but I get error when I run from JSF code under TOMCAT


Error:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception

root cause

java.lang.NoClassDefFoundError: javax/persistence/Persistence
br.com.devmedia.entity.JpaUtil.<init>(JpaUtil.java:13)
br.com.devmedia.entity.JpaUtil.getInstance(JpaUtil.java:1
br.com.devmedia.faces.FirstJsfandjpa.<init>(FirstJsfandjpa.java:16)
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:513)
java.lang.Class.newInstance0(Class.java:355)
java.lang.Class.newInstance(Class.java:30
com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:185)
com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:105)
com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:36
com.sun.faces.mgbean.BeanManager.create(BeanManager.java:222)
com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:86)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:61)
org.apache.el.parser.AstValue.getValue(AstValue.java:107)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
javax.faces.component.UIData.getValue(UIData.java:614)
javax.faces.component.UIData.getDataModel(UIData.java:1129)
javax.faces.component.UIData.setRowIndex(UIData.java:451)
com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:77)
javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
javax.faces.component.UIData.encodeBegin(UIData.java:967)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:92
javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

Your stacktrace seems to be indicating that the JPA api jar isn't in the application's classpath. Do you have a copy of the persistence-api JAR in your WEB-INF/lib directory?


Customer surveys are for companies who didn't pay proper attention to begin with.
fabianoSouza Souza
Greenhorn

Joined: Oct 07, 2006
Posts: 9
Hello Tim.. thanks for the reply... I'm using eclipse IDE and all jars is in app classpath... but I found out that the jars from hibernate should be stored into tomcat lib folder... I just put a copy of hibernate jars into tomcat lib and everything is working...

thanks!

Fabiano
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16228
    
  21

fabianoSouza Souza wrote:Hello Tim.. thanks for the reply... I'm using eclipse IDE and all jars is in app classpath... but I found out that the jars from hibernate should be stored into tomcat lib folder... I just put a copy of hibernate jars into tomcat lib and everything is working...

thanks!

Fabiano


Who did you find this out from? I don't do that, and I don't have problems. In fact, I'd be more concerned that but putting them in the common library I would have problems. As I indicated in a recent posting here, most jars aren't written to be sharable across multiple apps. Although certainly, JPA itself is a good candidate, since it's a core component in the JEE 5 spec.
fabianoSouza Souza
Greenhorn

Joined: Oct 07, 2006
Posts: 9
well.. I agree with you.. and I don't know why my app needs hibernate jars into tomcat lib.. it is strange
 
Consider Paul's rocket mass heater.
 
subject: Problem with JPA under TOMCAT