Maven、码头、JOTM

发布于 2024-07-27 17:13:50 字数 3032 浏览 10 评论 0原文

我无法在 Maven 构建环境中的 Jetty 之上配置 JOTM。 当我尝试运行我的应用程序时出现的异常如下:

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

我使用它作为参考:http://docs.codehaus.org/display/JETTY/JOTM

jetty.xml (maven 的 pom.xml 中的 jettyConfig,这实际上被看到)

<?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 (不太确定这被看到,但从异常来看,这是否相关?)

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

有什么想法吗?

谢谢, 沃尔特

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜妞爱困 2024-08-03 17:13:50

carol.properties 位于您的项目中的什么位置?

Maven 资源需要位于 src/main/resources 下。 Jetty 希望 carol.properties 位于资源文件夹中。

因此,您可能需要将 carol.properties 移动到 src/main/resources/resources ,以便在 Jetty 启动之前通过 process-resources 阶段将文件复制到 target/resources 。

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.

反话 2024-08-03 17:13:50

看来 carol 使用自己的 carol.jar/carol.properties 文件而不是您的文件。
我在 jetty 8 中使用 jta 准备了一个示例项目,并修改了 carol.jar/carol.properties 文件。 那里是 http://github.com/beolnix/jta-in-jetty8 。 似乎一切正常(提交、回滚 - 没问题),但有时会出现 org.omg.CORBA.BAD_INV_ORDER 异常。 在我的示例中,此异常被忽略,

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())
}

因为它不影响事务处理的结果

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文