• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problem with JPA under TOMCAT

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Saloon Keeper
Posts: 28493
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
fabianoSouza Souza
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 28493
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well.. I agree with you.. and I don't know why my app needs hibernate jars into tomcat lib.. it is strange
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic