JHarnach
JHarnach

Reputation: 4034

What do I need to include in Tomcat 7 to get javax.persistence working correctly?

I'm attempting to build a JSF/Hibernate application using Java 7 and Tomcat 7. I have installed the Java SDK and the JavaEE SDK, and copied the javaee.jar and javaee-api-6.jar into my Tomcat LIB folder. By my understanding of this post and this post I should have all of the jars I need, and to the best of my knowledge I have no other jars in this folder that have conflicting resources.

A deeper inspection of the Glassfish lib folder does show a number of relevant-looking jars, but not the complete javaee package, so I cant move the Javaee-api-6.jar out and move them in, they're incomplete and I get a similar error indicating (I'm assuming) that the implementation of some class can't be found.

So my question is: What do I need to include in Tomcat 7 to get javax.persistence working correctly ?

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/servlet/ServletException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.privateGetPublicMethods(Unknown Source)
at java.lang.Class.getMethods(Unknown Source)
at org.apache.tomcat.util.IntrospectionUtils.findMethods(IntrospectionUtils.java:713)
at org.apache.tomcat.util.IntrospectionUtils.setProperty(IntrospectionUtils.java:272)
at org.apache.tomcat.util.IntrospectionUtils.setProperty(IntrospectionUtils.java:261)
at org.apache.tomcat.util.digester.SetPropertiesRule.begin(SetPropertiesRule.java:215)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1282)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1543)
at org.apache.catalina.startup.Catalina.load(Catalina.java:554)
at org.apache.catalina.startup.Catalina.load(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:262)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:430)

Upvotes: 0

Views: 5351

Answers (1)

BalusC
BalusC

Reputation: 1108742

What do I need to include in Tomcat 7 to get javax.persistence working correctly ?

Not the Java EE SDK download from Oracle. It basically contains the Oracle Glassfish server. You seem to be misunderstanding what exactly Java EE is.

I strongly recommend to undo all changes you made in Tomcat while trying to morph it into a Glassfish server. Or, better, restart from scratch.

You should be choosing a concrete JPA implementation and installing it instead. There are several:

Each comes with a download link and decent documentation. Hibernate is the most popular. EclipseLink is the reference implementation (and thus the one used under the covers in Glassfish). OpenJPA is just another one from the Apache Software Foundation. Ultimately it's matter of dropping the JAR file(s) of the concrete JPA implementation in /WEB-INF/lib of the webapp (and thus not Tomcat's /lib).

Upvotes: 6

Related Questions