【问题标题】:Maven, Jetty, JOTMMaven、码头、JOTM
【发布时间】:2010-11-12 20:09:21
【问题描述】:

我无法在 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

有什么想法吗?

谢谢, 沃尔特

【问题讨论】:

    标签: java maven-2 jetty jotm


    【解决方案1】:

    carol.properties 在您的项目中位于何处?

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

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

    【讨论】:

    • 嗯 - 好的,我稍后再试。希望这就是我所需要的?这个错误对我来说更像是一个配置问题(语法),但我稍后会尝试。
    • 我试过了,但我得到了同样的信息。这是构建战争时 carol.properties 所在的位置:/WEB-INF/classes/resources/carol.properties
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-16
      • 1970-01-01
      • 2010-10-19
      • 1970-01-01
      • 1970-01-01
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多