Jetty サーバーでいくつかの JNDI エントリを定義しようとしています (それらは JVM スコープになります) が、期待どおりに "java:comp/env" 名前空間に自動的にバインドされません。私は次のドキュメントに従っています: http://wiki.eclipse.org/Jetty/Feature/JNDI#Configuring_env-entries
ここに私のjetty.xmlがあります:
<Configure id="server" class="org.eclipse.jetty.server.Server">
<New class="org.eclipse.jetty.plus.jndi.EnvEntry">
<Arg></Arg>
<Arg>prop/someValue</Arg>
<Arg type="java.lang.String">hello</Arg>
<Arg type="boolean">true</Arg>
</New>
</Configure>
Jetty の例が示すように、これが「java:comp/env/prop/someValue」にバインドされることを期待していましたが、「java:comp/env」はまったく作成されていないようです。
ただし、「prop/someValue」のルックアップは機能します。
注 - 私は webapp を持っていないので、WEB-INF/jetty-env.xml も web.xml もありません。Jetty サーバーを起動し、必要な JNDI エントリで構成しようとしています。
また、「bindToENC」メソッドを使用して、エントリを明示的にバインドしようとしました:
<Configure id="server" class="org.eclipse.jetty.server.Server">
<New class="org.eclipse.jetty.plus.jndi.EnvEntry">
<Arg></Arg>
<Arg>prop/someValue</Arg>
<Arg type="java.lang.String">hello</Arg>
<Arg type="boolean">true</Arg>
</New>
<Call name="bindToENC">
<Arg>prop/someValue</Arg>
</Call>
</Configure>
ただし、これによりサーバーの起動に失敗します。
2012-11-14 11:17:25,648 DEBUG - XML new class org.eclipse.jetty.plus.jndi.EnvEntry (org.eclipse.jetty.xml.XmlConfiguration)
2012-11-14 11:17:25,650 DEBUG - SAVE prop/someValue in null (jndi)
2012-11-14 11:17:25,656 DEBUG - InitialContextFactory.getInitialContext() (jndi)
2012-11-14 11:17:25,664 DEBUG - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@664883c (jndi)
2012-11-14 11:17:25,665 DEBUG - InitialContextFactory.getInitialContext() (jndi)
2012-11-14 11:17:25,665 DEBUG - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@6e811c88 (jndi)
2012-11-14 11:17:25,666 DEBUG - Looking up name="__" (jndi)
2012-11-14 11:17:25,666 DEBUG - Adding binding with key=__ obj=org.eclipse.jetty.jndi.NamingContext@39dd3812 for context=null as __: org.eclipse.jetty.jndi.NamingContext:org.eclipse.jetty.jndi.NamingContext@39dd3812 (jndi)
2012-11-14 11:17:25,666 DEBUG - Subcontext __ created (jndi)
2012-11-14 11:17:25,666 DEBUG - Looking up name="prop" (jndi)
2012-11-14 11:17:25,666 DEBUG - Adding binding with key=prop obj=org.eclipse.jetty.jndi.NamingContext@6a8c436b for context=__ as prop: org.eclipse.jetty.jndi.NamingContext:org.eclipse.jetty.jndi.NamingContext@6a8c436b (jndi)
2012-11-14 11:17:25,666 DEBUG - Subcontext prop created (jndi)
2012-11-14 11:17:25,667 DEBUG - Removing binding with key=someValue (jndi)
2012-11-14 11:17:25,667 DEBUG - Adding binding with key=someValue obj=prop/someValue for context=prop as someValue: org.eclipse.jetty.plus.jndi.EnvEntry:prop/someValue (jndi)
2012-11-14 11:17:25,667 DEBUG - Bound object to someValue (jndi)
2012-11-14 11:17:25,667 DEBUG - Looking up name="prop" (jndi)
2012-11-14 11:17:25,667 DEBUG - Adding binding with key=prop obj=org.eclipse.jetty.jndi.NamingContext@27b15692 for context=null as prop: org.eclipse.jetty.jndi.NamingContext:org.eclipse.jetty.jndi.NamingContext@27b15692 (jndi)
2012-11-14 11:17:25,667 DEBUG - Subcontext prop created (jndi)
2012-11-14 11:17:25,667 DEBUG - Removing binding with key=someValue (jndi)
2012-11-14 11:17:25,668 DEBUG - Adding binding with key=someValue obj=hello for context=prop as someValue: java.lang.String:hello (jndi)
2012-11-14 11:17:25,668 DEBUG - Bound object to someValue (jndi)
2012-11-14 11:17:25,668 DEBUG - XML call bindToENC (org.eclipse.jetty.xml.XmlConfiguration)
2012-11-14 11:17:25,668 DEBUG - InitialContextFactory.getInitialContext() (jndi)
2012-11-14 11:17:25,668 DEBUG - Created initial context delegate for local namespace:org.eclipse.jetty.jndi.local.localContextRoot@6baa9f99 (jndi)
2012-11-14 11:17:25,671 DEBUG - >>> new root context requested (org.eclipse.jetty.jndi.java.javaURLContextFactory)
2012-11-14 11:17:25,673 DEBUG - Adding binding with key=comp obj=Reference Class Name: javax.naming.Context
Type: parser
Content: org.eclipse.jetty.jndi.java.javaNameParser
for context=null as comp: javax.naming.Reference:Reference Class Name: javax.naming.Context
Type: parser
Content: org.eclipse.jetty.jndi.java.javaNameParser
(jndi)
2012-11-14 11:17:25,673 DEBUG - Looking up name="comp/env" (jndi)
2012-11-14 11:17:25,690 DEBUG - Using thread context classloader (jndi)
2012-11-14 11:17:25,690 DEBUG - No entry for classloader: sun.misc.Launcher$AppClassLoader@35a16869 (jndi)
2012-11-14 11:17:25,690 DEBUG - Looking up name="env" (jndi)
2012-11-14 11:17:25,690 WARN - Config error at <Call name="bindToENC"><Arg>prop/someValue</Arg></Call> (org.eclipse.jetty.xml.XmlConfiguration)
2012-11-14 11:17:25,690 WARN - Config error at <New class="org.eclipse.jetty.plus.jndi.EnvEntry"><Arg/><Arg>prop/someValue</Arg><Arg type="java.lang.String">hello</Arg><Arg type="boolean">true</Arg><Call name="bindToENC"><Arg>prop/someValue</Arg></Call></New> (org.eclipse.jetty.xml.XmlConfiguration)
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.jetty.util.TypeUtil.call(TypeUtil.java:538)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:732)
これを機能させる方法を知っている人はいますか?