Maven, Gettata, JOTM
Domanda
Sono stato in grado di configurare JOTM ontop di Jetty all'interno di un Maven costruire ambiente. L'eccezione che ottengo quando provo a fare funzionare la mia domanda è la seguente:
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
Sto usando questo come punto di riferimento: http://docs.codehaus.org/display / Molo / JOTM
jetty.xml (JettyConfig in pom.xml di Maven, questo è in realtà essere visto)
<?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 (non così sicuro che questo è essere visti, ma l'eccezione, è presente anche rilevanti?)
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
Tutte le idee?
Grazie, Walter
Soluzione
Dove si trova carol.properties nel vostro progetto?
risorse Maven devono essere sotto src / main / resources. Jetty si aspetta carol.properties di essere nella cartella delle risorse.
Così potrebbe essere necessario spostare carol.properties a src / main / risorse / risorse in modo che il file viene copiato per indirizzare / risorse dalla fase di processo-risorse prima Jetty viene lanciato.
Altri suggerimenti
Sembra che Carol sta usando file carol.jar/carol.properties
posto del tuo.
Ho preparato un progetto di esempio con il JTA in pontile 8 con il file carol.jar/carol.properties
modificato. lì è http://github.com/beolnix/jta-in-jetty8 . Sembra che tutto è OK, (commit, rollback - nessun problema), ma a volte sembra l'eccezione org.omg.CORBA.BAD_INV_ORDER
. Nel mio esempio questa eccezione viene ignorato
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())
}
perché non influenza il risultato della elaborazione delle transazioni