Search code examples
javamaven-2jettyjotm

Maven, Jetty, JOTM


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


Solution

  • 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.