1

jdbc データソースの JNDI 接続を検索しているときに、以下のエラーが発生します。

javax.naming.ConfigurationException: サーバー ランタイムが操作のスレッドを J2EE アプリケーション コンポーネントに関連付けることができないため、"java:" 名に対する JNDI 操作を完了できません。この状態は、「java:」名を使用する JNDI クライアントがサーバー アプリケーション要求のスレッドで実行されない場合に発生する可能性があります。J2EE アプリケーションが、静的コード ブロック内またはその J2EE アプリケーションによって作成されたスレッド内の「java:」名に対して JNDI 操作を実行しないようにしてください。このようなコードは、必ずしもサーバー アプリケーション要求のスレッドで実行されるとは限らないため、"java:" 名に対する JNDI 操作ではサポートされません。[ルート例外は javax.naming.NameNotFoundException: Name not found in context "java:".]

検索コードが静的メソッド内にあります。それがこのエラーの理由ですか。私はスレッドを作成していません

問題なくTomcatで動作します

ご協力いただきありがとうございます

私が使用しているコードは以下のようなものです:

  javax.naming.InitialContext ctx = new javax.naming.InitialContext();
  Context cxt = (Context) ctx.lookup("java:/comp/env/");

スタックトレース:

C1APP522   2    2013-07-01 21:57:18,332 ERROR DBUtil get EnvContext failed
javax.naming.ConfigurationException: A JNDI operation on a "java:" name cannot be completed because the server runtime is not able to associate the operation's thread with any J2EE application component.  This condition can occur when the JNDI client using the "java:" name is not executed on the thread of a server application request.  Make sure that a J2EE application does not execute JNDI operations on "java:" names within static code blocks or in threads created by that J2EE application.  Such code does not necessarily run on the thread of a server application request and therefore is not supported by JNDI operations on "java:" names. [Root exception is javax.naming.NameNotFoundException: Name  not found in context "java:".]
    at com.ibm.ws.naming.java.javaURLContextImpl.throwConfigurationExceptionWithDefaultJavaNS(javaURLContextImpl.java:428)
    at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:399)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:220)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:160)
    at javax.naming.InitialContext.lookup(InitialContext.java:436)
    at com.test.integration.database.DBUtil_Ext.getEnvContext(DBUtil_Ext.java:121)
    at com.test.integration.database.DBUtil_Ext.getDataSource(DBUtil_Ext.java:102)
    at com.test.integration.database.DBUtil_Ext.getConnection(DBUtil_Ext.java:70)
    at com.test.integration.IntegrationTransportPlugin_Ext.send(IntegrationTransportPlugin_Ext.java:107)
    at com.test.integration.IntegrationTransportPlugin_Ext.send(IntegrationTransportPlugin_Ext.gs)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.test.system.integration.plugins.PluginProxy.invoke(PluginProxy.java:66)
    at $Proxy58.send(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.test.system.integration.plugins.PluginCallTraceImpl$PluginCallTraceHandler.invoke(PluginCallTraceImpl.java:61)
    at $Proxy58.send(Unknown Source)
    at com.test.system.integration.messaging.dispatch.MessageWriter$2.run(MessageWriter.java:347)
    at com.test.system.transaction.ScopedUserTransaction.run(ScopedUserTransaction.java:54)
    at com.test.system.transaction.TransactionManagerImpl.execute(TransactionManagerImpl.java:111)
    at com.test.system.integration.messaging.dispatch.AckHelper.executeMessageOperation(AckHelper.java:137)
    at com.test.system.integration.messaging.dispatch.AckHelper.executeMessageOperation(AckHelper.java:121)
    at com.test.system.integration.messaging.dispatch.MessageWriter.executeSendAndAfterSendInTxn(MessageWriter.java:332)
    at com.test.system.integration.messaging.dispatch.MessageWriter.sendNextMessage(MessageWriter.java:272)
    at com.test.system.integration.messaging.dispatch.MessageSenderRunnable.trySendMessage(MessageSenderRunnable.java:52)
    at com.test.system.integration.messaging.dispatch.MessageSenderRunnable.send(MessageSenderRunnable.java:42)
    at com.test.system.integration.messaging.dispatch.MessageSenderRunnable.run(MessageSenderRunnable.java:30)
    at com.test.system.integration.messaging.dispatch.MessageWriter$CatchesExceptionRunnable.run(MessageWriter.java:603)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:452)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
    at java.util.concurrent.FutureTask.run(FutureTask.java:149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:736)
Caused by: javax.naming.NameNotFoundException: Name  not found in context "java:".
    at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1837)
    at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1166)
    at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1095)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1233)
    at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:395)
    ... 37 more
C1APP522        2013-07-01 21:57:18,332 ERROR Messaging Exception in MessageSenderRunnable
java.lang.RuntimeException: get EnvContext failed
    at com.test.integration.database.DBUtil_Ext.getEnvContext(DBUtil_Ext.java:125)
    at com.test.integration.database.DBUtil_Ext.getDataSource(DBUtil_Ext.java:102)
    at com.test.integration.database.DBUtil_Ext.getConnection(DBUtil_Ext.java:70)
    at com.test.integration.IntegrationTransportPlugin_Ext.send(IntegrationTransportPlugin_Ext.java:107)
    at com.test.integration.IntegrationTransportPlugin_Ext.send(IntegrationTransportPlugin_Ext.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.test.system.integration.plugins.PluginProxy.invoke(PluginProxy.java:66)
    at $Proxy58.send(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.test.system.integration.plugins.PluginCallTraceImpl$PluginCallTraceHandler.invoke(PluginCallTraceImpl.java:61)
    at $Proxy58.send(Unknown Source)
    at com.test.system.integration.messaging.dispatch.MessageWriter$2.run(MessageWriter.java:347)
    at com.test.system.transaction.ScopedUserTransaction.run(ScopedUserTransaction.java:54)
    at com.test.system.transaction.TransactionManagerImpl.execute(TransactionManagerImpl.java:111)
    at com.test.system.integration.messaging.dispatch.AckHelper.executeMessageOperation(AckHelper.java:137)
    at com.test.system.integration.messaging.dispatch.AckHelper.executeMessageOperation(AckHelper.java:121)
    at com.test.system.integration.messaging.dispatch.MessageWriter.executeSendAndAfterSendInTxn(MessageWriter.java:332)
    at com.test.system.integration.messaging.dispatch.MessageWriter.sendNextMessage(MessageWriter.java:272)
    at com.test.system.integration.messaging.dispatch.MessageSenderRunnable.trySendMessage(MessageSenderRunnable.java:52)
    at com.test.system.integration.messaging.dispatch.MessageSenderRunnable.send(MessageSenderRunnable.java:42)
    at com.test.system.integration.messaging.dispatch.MessageSenderRunnable.run(MessageSenderRunnable.java:30)
    at com.test.system.integration.messaging.dispatch.MessageWriter$CatchesExceptionRunnable.run(MessageWriter.java:603)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:452)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:314)
    at java.util.concurrent.FutureTask.run(FutureTask.java:149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
    at java.lang.Thread.run(Thread.java:736)
4

1 に答える 1