dong5300 发表于 2017-2-27 09:16:03

Jetty6 让web应用启动时读取jetty-env.xml设置JNDI

  之前一直在用hightide.没去操心jetty-env.xml是如何被读取的.
  这次由于要迁移到Windows中运行,开始用Java Service Wrapper配置hightide的启动,但一直有些小问题。
  Google后发现Jetty本身就已经带了Java Service Wrapper,于是把环境换成了Jetty6.1.25.启动是解决了,但是应用在启动是报错,找不到jndi数据源.看看WEB-INF/jetty-env.xml一直好好的呆着,怎么就是读不到?
  再仔细看看jetty关于jndi的设置,问题找到,还需要单独设置下plus的参数:
  


<Array id="plusConfig" type="java.lang.String">
<Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
<Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
<Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
<Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
<Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item>
</Array>
<Call name="addLifeCycle">
<Arg>
<New class="org.mortbay.jetty.deployer.WebAppDeployer">
<Set name="contexts"><Ref id="Contexts"/></Set>
<Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/webapps</Set>
<Set name="parentLoaderPriority">false</Set>
<Set name="extract">true</Set>
<Set name="allowDuplicates">false</Set>
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
<Set name="configurationClasses"><Ref id="plusConfig"/></Set>
</New>
</Arg>
</Call>
  加到jetty/contaxts/下的应用配置里,问题解决。
  http://docs.codehaus.org/display/JETTY/JNDI
页: [1]
查看完整版本: Jetty6 让web应用启动时读取jetty-env.xml设置JNDI