首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何让Jetty使用JVM作用域的JNDI?

如何让Jetty使用JVM作用域的JNDI?
EN

Stack Overflow用户
提问于 2012-04-13 21:19:33
回答 1查看 897关注 0票数 0

我正在尝试为Jetty中的Jackrabbit存储库工厂设置一个JNDI资源。问题是,我似乎将JNDI作为webapp作用域。我需要它是JVM作用域。据我从文档中了解,您需要指定一个空参数,如下所示(解释here),如下所示(<Arg></Arg>)。

我有两个部署到Jetty的the应用程序,我需要它们共享相同的JNDI。如果它们没有共享,Jackrabbit会尝试初始化两次,但都失败了,这会破坏我的整个应用程序。

我通过调试器运行了代码,我可以看到第一个被访问的webapp需要对Jackrabbit存储库进行JNDI查找,它获得了BindableRepositoryFactory的一个实例,并正确地向cache对象添加了记录。但是,在JNDI查找时会为cache创建一个完全不同的对象。这显然仍然是空的,因此创建了一个新的实例,这会搞砸事情。

我正在使用Jetty 7.6.2.v20120308。下面是我的jetty-jndi.xml:

代码语言:javascript
复制
<New class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg></Arg>
    <Arg>jndi:comp/env/jcr/repository</Arg>
    <Arg>
        <New class="javax.naming.Reference" id="reference">
            <Arg>javax.jcr.Repository</Arg>
            <Arg>org.apache.jackrabbit.core.jndi.BindableRepositoryFactory</Arg>
            <Arg>null</Arg>
            <Call name="add" id="reference">
                <Arg>
                    <New class="javax.naming.StringRefAddr">
                        <Arg>configFilePath</Arg>
                        <Arg><SystemProperty name="jetty.home" default="."/>/jackrabbit/repository.xml</Arg>
                    </New>
                </Arg>
            </Call>
            <Call name="add" id="reference">
                <Arg>
                    <New class="javax.naming.StringRefAddr">
                        <Arg>repHomeDir</Arg>
                        <Arg><SystemProperty name="jetty.home" default="."/>/jackrabbit</Arg>
                    </New>
                </Arg>
            </Call>
        </New>
    </Arg>
</New>

在我调用jetty的pom文件中,我有以下相关设置,这些设置告诉Jetty使用JNDI和Plus设置xml-s:

代码语言:javascript
复制
<jettyConfig>${project.build.directory}/jetty/etc/jetty-plus.xml,${project.build.directory}/jetty/etc/jetty-jndi.xml</jettyConfig>

在jetty-plus.xml中,我有:

代码语言:javascript
复制
<!-- =========================================================== -->
<!-- Sequence of configurations to defining Plus features.       -->
<!-- =========================================================== -->
<Array id="plusConfig" type="java.lang.String">
    <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item>
    <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
    <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
    <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
    <Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>        <!-- Add for JNDI -->
    <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>       <!-- Add for JNDI -->
    <Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
    <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
    <Item>org.eclipse.jetty.webapp.TagLibConfiguration</Item>          <!-- Not needed for Jetty-8 -->
</Array>


<!-- =========================================================== -->
<!-- Apply plusConfig to all webapps for this Server             -->
<!-- =========================================================== -->
<Call name="setAttribute">
    <Arg>org.eclipse.jetty.webapp.configuration</Arg>
    <Arg>
        <Ref id="plusConfig"/>
    </Arg>
</Call>

你知道我做错了什么吗?

非常感谢!:)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-04-14 00:41:06

这似乎是Jetty的全局JNDI资源配置中的一个错误。

我已经在Jetty's bugzilla中提交了一个错误,并将接受这个正确的答案,尽管它不是解决方案。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10141599

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档