题
I have been unable to configure JOTM ontop of Jetty inside a Maven build environment. The exception I get when I try to run my application is the following:
2009-07-21 19:47:23.499::WARN: Config error at <New id="UserTransaction" class="org.mortbay.jetty.plus.naming.Transaction"><Arg>
<Ref id="ut"/>
</Arg></New>
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failure
A flat name can only have a single component
I am using this as a reference:http://docs.codehaus.org/display/JETTY/JOTM
jetty.xml (jettyConfig in maven's pom.xml, this is actually being seen)
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.mortbay.jetty.Server">
<!-- Configure a Jotm instance which provides a javax.transaction.TransactionManager -->
<!-- and a javax.transaction.UserTransaction implementation. -->
<New id="jotm" class="org.objectweb.jotm.Jotm">
<Arg type="boolean">True</Arg>
<Arg type="boolean">False</Arg>
<Call id="tm" name="getTransactionManager"/>
<Call id="ut" name="getUserTransaction"/>
</New>
<!-- Set up the UserTransaction impl from JOTM as the transaction manager for jetty -->
<!--
<New id="UserTransaction" class="org.mortbay.jetty.plus.naming.Transaction">
<Arg>
<Ref id="ut"/>
</Arg>
</New>
-->
<New id="userTransaction" class="org.mortbay.jetty.plus.naming.Resource">
<Arg></Arg>
<Arg>javax.transaction.TransactionManager</Arg>
<Arg>
<Ref id="ut"/>
</Arg>
</New>
<New id="tx" class="org.mortbay.jetty.plus.naming.Transaction">
<Arg>
<Ref id="ut"/>
</Arg>
</New>
<!-- If you want to be able to set up more references in webapp specific files -->
<!-- such as context deployment files and WEB-INF/jetty-env.xml files, you -->
<!-- need to save a reference to the JOTM tm object: -->
<!--
<Call name="setAttribute">
<Arg>tm</Arg>
<Arg><Ref id="tm"/></Arg>
</Call>
-->
</Configure>
carol.properties (not so sure this is being seen, but from the exception, is this even relevant?)
carol.start.ns=false
carol.start.jndi=false
carol.protocols=jrmp
carol.start.rmi=false
carol.jvm.rmi.local.call=true
carol.jndi.java.naming.factory.url.pkgs=org.mortbay.naming
Any ideas?
Thanks, Walter
解决方案
Where is carol.properties located in your project?
Maven resources need to be under src/main/resources. Jetty expects carol.properties to be in the resources folder.
So you may need to move carol.properties to src/main/resources/resources so the file is copied to target/resources by the process-resources stage before Jetty is launched.
其他提示
It seems that carol is using own carol.jar/carol.properties
file instead of yours.
i prepared an example project with jta in jetty 8 with modified carol.jar/carol.properties
file. there it is http://github.com/beolnix/jta-in-jetty8 . Seems that all is OK, (commit, rollback - no problem) but sometimes the org.omg.CORBA.BAD_INV_ORDER
exception appears. In my example this exception is ignored
try {
ret = ctx.proceed()
tx.commit()
} catch (org.omg.CORBA.BAD_INV_ORDER e) {
//nop
} catch (Throwable e) {
tx.rollback()
throw new TransactionException(e.getMessage())
}
because it does not influence the result of the transaction processing