[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] Jetty, Atomikos, Hibernate, XA - NoClassDefFoundError and other exceptions
|
Hi guys
My system:
Jetty 6.1.22
Atomikos Essentials 3.6.0
Hibernate 3.3.2
Linux
JDK 6 u18
How properly configure them to make hibernate lookup the Atomikos TM ?
===> The relevant documentation:
http://docs.codehaus.org/display/JETTY/JNDI#JNDI-tx
http://www.atomikos.com/Documentation/HibernateThreeStandalone
What I did:
===> etc/jetty-plus.xml
<Call class="java.lang.System" name="setProperty">
<Arg>com.atomikos.icatch.file</Arg>
<Arg><SystemProperty name="jetty.home" default="."
/>/resources/atomikos.properties</Arg>
</Call>
<New id="tx" class="org.mortbay.jetty.plus.naming.Transaction">
<Arg>
<New class="com.atomikos.icatch.jta.UserTransactionImp"/>
</Arg>
</New>
<New id="blah" class="org.mortbay.jetty.plus.naming.Resource">
<Arg></Arg>
<Arg>jdbc/pgsql</Arg>
<Arg>
<New class="com.atomikos.jdbc.AtomikosDataSourceBean">
<Set name="minPoolSize">1</Set>
<Set name="maxPoolSize">4</Set>
<Set
name="xaDataSourceClassName">org.postgresql.xa.PGXADataSource</Set>
<Set name="UniqueResourceName">psql22-xa</Set>
<Get name="xaProperties">
<Call name="setProperty">
<Arg>serverName</Arg>
<Arg>localhost</Arg>
</Call>
<Call name="setProperty">
<Arg>portNumber</Arg>
<Arg>5432</Arg>
</Call>
<Call name="setProperty">
<Arg>databaseName</Arg>
<Arg>test2</Arg>
</Call>
<Call name="setProperty">
<Arg>user</Arg>
<Arg>claudio</Arg>
</Call>
<Call name="setProperty">
<Arg>password</Arg>
<Arg>admin</Arg>
</Call>
</Get>
</New>
</Arg>
</New>
===> WEB-INF/classes/META-INF/persistence.xml
<persistence-unit name="mypu" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/pgsql</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.current_session_context_class" value="jta" />
<property name="hibernate.transaction.manager_lookup_class"
value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/>
<!--<property name="hibernate.transaction.factory_class"
value="com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory"/>-->
<property name="hibernate.transaction.factory_class"
value="org.hibernate.transaction.JTATransactionFactory"/>
I will explain some variation of the above file at the end of this message
===> jetty.home/resources/atomikos.properties
com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
com.atomikos.icatch.automatic_resource_registration=true
com.atomikos.icatch.output_dir=../work
com.atomikos.icatch.log_base_dir=../work
com.atomikos.icatch.enable_logging=true
com.atomikos.icatch.console_log_level=INFO
com.atomikos.icatch.console_file_name=atomikos-tm.log
com.atomikos.icatch.log_base_name=atomikos-base.log
===> The application uses the ContextDeployer, see the configuration:
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="contextPath">/myapp</Set>
<Set name="parentLoaderPriority">false</Set>
<Set name="war">/home/claudio/alphaworks/projects/myapp/build/web</Set>
</Configure>
===> The startup line:
java -jar start.jar etc/jetty-logging.xml etc/jetty-plus.xml
etc/jetty-sslengine.xml etc/jetty.xml
The exception at runtime
2010-01-25 21:21:25,811 WARN org.hibernate.ejb.Ejb3Configuration:
Overriding hibernate.transaction.factory_class is dangerous, this
might break the EJB3 specification implementation
2010-01-25 21:21:25,834 DEBUG org.hibernate.ejb.util.NamingHelper: No
JNDI name configured for binding Ejb3Configuration
2010-01-25 21:21:25,843 INFO org.hibernate.util.NamingHelper: JNDI
InitialContext properties:{}
2010-01-25 21:21:25,845 INFO
org.hibernate.connection.DatasourceConnectionProvider: Using
datasource: jdbc/pgsql
2010-01-25 21:21:26,008 INFO org.hibernate.cfg.SettingsFactory:
RDBMS: PostgreSQL, version: 8.3.7
2010-01-25 21:21:26,008 INFO org.hibernate.cfg.SettingsFactory: JDBC
driver: PostgreSQL Native Driver, version: PostgreSQL 8.3 JDBC4 with
SSL (build 605)
2010-01-25 21:21:26,019 INFO org.hibernate.dialect.Dialect: Using
dialect: org.hibernate.dialect.PostgreSQLDialect
2010-01-25 21:21:26,047 INFO
org.hibernate.transaction.TransactionFactoryFactory: Transaction
strategy: com.atomikos.icatch.jta.hibernate3.AtomikosJTATransactionFactory
==> logs/server.log <==
2010-01-25 21:21:26,056 ERROR org.mortbay.log: Error for /myapp/app/
java.lang.NoClassDefFoundError: org/hibernate/transaction/JTATransactionFactory
at java.lang.ClassLoader.defineClass1(Native Method) [na:1.6.0_18]
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
[na:1.6.0_18]
at java.lang.ClassLoader.defineClass(ClassLoader.java:616) [na:1.6.0_18]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
[na:1.6.0_18]
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
[na:1.6.0_18]
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
[na:1.6.0_18]
at java.net.URLClassLoader$1.run(URLClassLoader.java:197) [na:1.6.0_18]
at java.security.AccessController.doPrivileged(Native Method)
[na:1.6.0_18]
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[na:1.6.0_18]
at java.lang.ClassLoader.loadClass(ClassLoader.java:307) [na:1.6.0_18]
at java.lang.ClassLoader.loadClass(ClassLoader.java:248) [na:1.6.0_18]
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:401)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:363)
[jetty-6.1.22.jar:6.1.22]
at java.lang.Class.forName0(Native Method) [na:1.6.0_18]
at java.lang.Class.forName(Class.java:169) [na:1.6.0_18]
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
[hibernate-core-3.3.2.GA.jar:3.3.2.GA]
at org.hibernate.transaction.TransactionFactoryFactory.buildTransactionFactory(TransactionFactoryFactory.java:65)
[hibernate-core-3.3.2.GA.jar:3.3.2.GA]
at org.hibernate.cfg.SettingsFactory.createTransactionFactory(SettingsFactory.java:429)
[hibernate-core-3.3.2.GA.jar:3.4.0.GA]
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:156)
[hibernate-core-3.3.2.GA.jar:3.4.0.GA]
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
[hibernate-core-3.3.2.GA.jar:3.4.0.GA]
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
[hibernate-core-3.3.2.GA.jar:3.4.0.GA]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
[hibernate-core-3.3.2.GA.jar:3.4.0.GA]
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
[hibernate-annotations-3.4.0.GA.jar:3.4.0.GA]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
[hibernate-entitymanager-3.4.0.GA.jar:3.4.0.GA]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
[hibernate-entitymanager-3.4.0.GA.jar:3.4.0.GA]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
[persistence-api-1.0.jar:1.0]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
[persistence-api-1.0.jar:1.0]
at br.com.evconf.EvConfRequestCycle.<init>(EvConfRequestCycle.java:28)
[classes/:na]
at br.com.evconf.EvConfApp.newRequestCycle(EvConfApp.java:60)
[classes/:na]
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:474)
[wicket-1.4.5.jar:1.4.5]
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
[wicket-1.4.5.jar:1.4.5]
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.Server.handle(Server.java:326)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
[jetty-6.1.22.jar:6.1.22]
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
[jetty-util-6.1.22.jar:6.1.22]
Caused by: java.lang.ClassNotFoundException:
org.hibernate.transaction.JTATransactionFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:202) [na:1.6.0_18]
at java.security.AccessController.doPrivileged(Native Method)
[na:1.6.0_18]
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[na:1.6.0_18]
at java.lang.ClassLoader.loadClass(ClassLoader.java:307) [na:1.6.0_18]
at java.lang.ClassLoader.loadClass(ClassLoader.java:248) [na:1.6.0_18]
If I copy the lib/transactions-essentials-all.jar to WEB-INF/lib/ it works !
Obviously I dont want to put the atomikos jar as my application
dependency. Nor copy the whole hibernate jars into jetty/lib.
I see the atomikos library (server scoped) cannot see the hibernate
library (application scoped).
I changed the persistence.xml to exclude the hibernate transaction
configurations (manager_lookup_class, factory_class,
current_session_context_class) to let hibernate configure itself.
But it threw the following exception (only the relevant part)
javax.persistence.PersistenceException: [PersistenceUnit: mypu] Unable
to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
[hibernate-entitymanager-3.4.0.GA.jar:3.4.0.GA]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
[hibernate-entitymanager-3.4.0.GA.jar:3.4.0.GA]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
[persistence-api-1.0.jar:1.0]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
[persistence-api-1.0.jar:1.0]
Caused by: org.hibernate.HibernateException: The chosen transaction
strategy requires access to the JTA TransactionManager
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:371)
[hibernate-core-3.3.2.GA.jar:3.3.2.GA]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
[hibernate-core-3.3.2.GA.jar:3.4.0.GA]
Configuring only the hibernate.transaction.factory_class to
org.hibernate.transaction.JTATransactionFactory, throws the exception
org.hibernate.TransactionException: Could not find UserTransaction in
JNDI [java:comp/UserTransaction]
at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:173)
at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:149)
I did a bit of searching on the internet, but no success.
==> A test case is available to show the issue, download at
http://www.claudius.com.br/hib-jetty-atomikos-bundle.tar.gz
Inside you find a war file ready to deploy and the source code:
hib-jetty-atomikos.war
hib-jetty-atomikos (directory)
You need to create a jdbc/pgsql resource at etc/jetty-plus.xml, see
the example at the top of the post.
Sorry for the long post, but there is a issue and a test case, I hope
someone can take a look at this.
Cheers
Claudio Miranda