AS7において、Remote EJBを使ってDataSourceをLookupする件
kuribara Nov 20, 2012 5:32 AMいつもお世話になっております。
当方、JBossAS7.1.1 Finalで構築した環境がありまして、JBossの管理コンソールを操作して作成したデータソースを
RemoteEJB(jboss-ejb-client.jarを参照)を使って、クライアントのJavaアプリケーションからlookupさせて、SQLを発行
するアプリケーションを移植中ですが、lookupする所で、エラーが生じてしまっております。
(元々WebLogicでできていましたアプリケーションを、今回JBossに移植)
スタックトレースとしては以下です。
11 20, 2012 2:46:29 午後 org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
11 20, 2012 2:46:29 午後 org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
11 20, 2012 2:46:29 午後 org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
11 20, 2012 2:46:29 午後 org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: Received server version 1 and marshalling strategies [river]
11 20, 2012 2:46:29 午後 org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@5f1843c0, receiver=Remoting connection EJB receiver [connection=Remoting connection <116cf35>,channel=jboss.ejb,nodename=server]} on channel Channel ID d0342560 (outbound) of Remoting connection 2f29271e to server/10.xxx.xxx.xxx:4447
11 20, 2012 2:46:29 午後 org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver handleMessage
WARN: Unsupported message received with header 0xffffffff
11 20, 2012 2:46:29 午後 org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: Received server version 1 and marshalling strategies [river]
11 20, 2012 2:46:29 午後 org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@491782f1, receiver=Remoting connection EJB receiver [connection=Remoting connection <292c5f73>,channel=jboss.ejb,nodename=server]} on channel Channel ID e333975d (outbound) of Remoting connection 72696ece to ebid-ap02/10.83.145.85:4447
11 20, 2012 2:46:29 午後 org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver handleMessage
WARN: Unsupported message received with header 0xffffffff
11 20, 2012 2:46:29 午後 org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 1.0.5.Final
javax.naming.NameNotFoundException: Invalid name:jboss/datasources/myDS
at com.sun.enterprise.naming.java.javaURLContext.getRelativeName(javaURLContext.java:424)
at com.sun.enterprise.naming.java.javaURLContext.getComponentContext(javaURLContext.java:382)
at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:51)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
・
・
・
NameNotFoundExceptionが発生する原因として、考えられるとすれば
そもそもJNDI名の指定方法が間違っている?
java:jboss/datasources/myDS
以外に、
ejb:jboss/datasources/myDS
を試したりしましたが、
java.lang.ClassCastException: org.jboss.ejb.client.naming.ejb.EjbNamingContext cannot be cast to javax.sql.DataSource
が生じてエラーです。
lookupさせているコードは以下です。
DataSource ds=null;
ds=(javax.sql.DataSource)ctx.lookup("ejb:jboss/datasources/myDS");
RemoteEJBの場合、ejb:から始まるJNDIの指定を行う必要があると思うのですが、データセット用の記述方法があるのかどうか
ヘルプを見ても特に記載が有りませんでした。
https://docs.jboss.org/author/display/AS71/JNDI+Reference
https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI
もしかして、JBossAS7では、そもそもデータソースをlookupするというのは不可能な仕様になってしまったんでしょうか?
以前のJBossでは行えたはずなのですが。
下記気になる記事がありました。
To my knowledge, AS7 doesn't support remote access to JCA JDBC datasources.
https://community.jboss.org/message/727218
→To my knowledge, AS7 doesn't support remote access to JCA JDBC datasources.
Not able to connect to Remote DataSource via JNDI while upgrading to AS7 and Hibernate 4
https://community.jboss.org/message/764939
→You can't use datasources remotely on AS 7. Although you could do it on AS 5, it was not a good idea to do so - it causes performance problems, causes potential transaction problems, can easily starve the connection pool, and assorted other issues.
What you should do instead is to deploy an EJB or web service on the server that has the datasource, and call that from the remote machine.
Cannot lookup datasource remotely in Jboss 7.10 final
https://community.jboss.org/thread/196876
→Remote lookup of datasources is not supported in AS7.
ご存じの方がおいでなら、是非ご教授のほどを。。。