2016-03-21 21 views
1

Java 8 & WildFly(JBoss)10.0がインストールされています。私はemsa.jarファイルを "リモート"サーバー上のリモートEJBと共に展開しました。WildFly 10 JNDIを使用したリモートEJB呼び出しClassNotFoundException javax.ejb.EJBException

私は、EclipseでJavaアプリケーションとして、クライアントのmainメソッドを実行して、別のクライアントアプリの中からEJBのメソッドを呼び出すためにJNDIを使用しようとしていますが、次のエラーを取得しています:

INFO: EJBCLIENT000013: Successful version handshake completed for receiver context EJBReceiverContext{[email protected], receiver=Remoting connection EJB receiver [connection=Remoting connection <545ebbdd>,channel=jboss.ejb,nodename=skb]} on channel Channel ID d234d46a (outbound) of Remoting connection 395b72b3 to localhost/127.0.0.1:8080 
Exception in thread "naming-client-message-receiver-1-thread-1" java.lang.NoClassDefFoundError: javax/ejb/EJBException 
    at org.jboss.ejb.client.SerializedEJBInvocationHandler.readResolve(SerializedEJBInvocationHandler.java:110) 
    at org.jboss.ejb.client.SerializedEJBInvocationHandler.readResolve(SerializedEJBInvocationHandler.java:106) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:497) 
    at org.jboss.marshalling.reflect.SerializableClass.callReadResolve(SerializableClass.java:417) 
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1299) 
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276) 
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:213) 
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNestedObject(RiverUnmarshaller.java:169) 
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1254) 
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276) 
    at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:213) 
    at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:45) 
    at org.jboss.naming.remote.protocol.v1.Protocol$1$3.read(Protocol.java:156) 
    at org.jboss.naming.remote.protocol.v1.Protocol$1$3.read(Protocol.java:149) 
    at org.jboss.naming.remote.protocol.v1.BaseProtocolCommand.readResult(BaseProtocolCommand.java:59) 
    at org.jboss.naming.remote.protocol.v1.Protocol$1.handleClientMessage(Protocol.java:149) 
    at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1$MessageReceiver$1.run(RemoteNamingStoreV1.java:232) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: java.lang.ClassNotFoundException: javax.ejb.EJBException 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 23 more 
javax.naming.NamingException: Unable to invoke lookup, status=WAITING 
    at org.jboss.naming.remote.protocol.v1.Protocol$1.execute(Protocol.java:98) 
    at org.jboss.naming.remote.protocol.v1.RemoteNamingStoreV1.lookup(RemoteNamingStoreV1.java:95) 
    at org.jboss.naming.remote.client.HaRemoteNamingStore$1.operation(HaRemoteNamingStore.java:276) 
    at org.jboss.naming.remote.client.HaRemoteNamingStore.namingOperation(HaRemoteNamingStore.java:132) 
    at org.jboss.naming.remote.client.HaRemoteNamingStore.lookup(HaRemoteNamingStore.java:272) 
    at org.jboss.naming.remote.client.RemoteContext.lookupInternal(RemoteContext.java:104) 
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:93) 
    at org.jboss.naming.remote.client.RemoteContext.lookup(RemoteContext.java:146) 
    at javax.naming.InitialContext.lookup(InitialContext.java:417) 
    at com.kelly_ann.employeemgmt.Main.main(Main.java:38) 

クライアントのメインクラスのコードは次のとおりです。

package com.k_a.employeemgmt; 

import java.util.List; 
import java.util.Properties; 

import javax.naming.Context; 
import javax.naming.InitialContext; 
import javax.naming.NamingException; 

import com.k_a.employeemgmt.EmployeeMgmtService; 
import com.k_a.employeemgmt.domain.Employee; 

public class Main { 

    // this remotely invokes the server's EmployeeMgmtService.getAllEmployees() method. 
    public static void main(String[] args) { 
     try { 
      Properties jndiProperties = new Properties(); 
      jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); 
      jndiProperties.put(Context.PROVIDER_URL, "http-remoting://localhost:8080"); 
      jndiProperties.put("jboss.naming.client.ejb.context", true); 
      System.out.println("MYTESTjndiProperties: " + jndiProperties); // gets here 
      Context jndi = new InitialContext(jndiProperties); 
      System.out.println("MYTESTjndi: " + jndi); // gets here 

      EmployeeMgmtService service = (EmployeeMgmtService)jndi.lookup("emsa/EmployeeMgmtImpl!com.k_a.employeemgmt.EmployeeMgmtService"); 
      System.out.println("MYTESTservice: " + service); // doesn't get to here 
      List<Employee> employees = service.getAllEmployees(); 
      for(Employee employee : employees) { 
       System.out.println(employee); 
      } 
     } 

私のクライアントアプリケーションのGradleのは、ファイル(build.gradle)を構築することで、次の依存関係があります。

apply plugin: 'java' 

defaultTasks 'clean', 'compileJava', 'test', 'jar' 

jar { 
    archiveName = "emtc.jar" 
} 

test.useJUnit() 

repositories { 
    mavenCentral() 
} 

dependencies { 
    compile 'jboss:jboss-client:4.0.2' 
    compile 'org.jboss:jboss-remote-naming:2.0.4.Final' 
    compile 'org.jboss.xnio:xnio-nio:3.3.6.Final' 
    testCompile 'junit:junit:4.12' 
} 

最後の日はWildFly/JBossのドキュメントhereに従ってみましたが、運がありません。

アイデア?

答えて

1

最終的な解決策:

は、問題は、私はhere上場'application'プラグインを適用し、'run'タスクを呼び出すために必要な私のGradleのbuild.gradleファイルでした。それが完了したら、それは魅力のように働いた! Gradleビルド・ファイルのMavenリポジトリBOM(here)を使用して終了しました。これは、適切な依存性管理を確実にする最善の方法であったからです。すべての助けをありがとう!とても有難い。 build.gradleファイル内:-)

最終的なコードは以下の通りです:wildfly-のejb-クライアント-BOMのための

apply plugin: 'java' 
apply plugin: 'application' 

defaultTasks 'clean', 'compileJava', 'test', 'jar', 'run' 

mainClassName = 'com.k_a.employeemgmt.Main' 

jar { 
    archiveName = "emtc.jar" 
} 

test.useJUnit() 

repositories { 
    mavenCentral() 
} 

dependencies { 
    compile 'org.wildfly:wildfly-ejb-client-bom:10.0.0.Final' 
    testCompile 'junit:junit:4.12' 
} 
2

私は、Maven for Wildfly 9.0.2.Finalで行う方法について、小文字のtutorialを書いています。だから私はGradleの方法に変換しようとしました(申し訳ありませんがGradleの経験はありません)、Wildflow 10.0.0に準拠するように依存関係を調整しました。あなたの必要性を尊重して、NoClassDefException組み合わせ:

dependencies { 
    org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.0.Final 
    org.jboss:jboss-remote-naming:2.0.4.Final 
    org.jboss:jboss-ejb-client:2.1.4.Final 
    org.jboss.xnio:xnio-nio:3.3.4.Final 
    org.jboss.marshalling:jboss-marshalling-river:1.4.10.Final 
    org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final 
} 

それとも使用:

dependencies { 
    org.wildfly:wildfly-client-all:10.0.0.Final 
} 

しかし、後者の場合には、あなたがJMSのために他の推移の依存関係を持っているでしょう...

ところで、Mavenの方法で、私はしばしば自動を意味するBOM依存関係を使用します依存関係のための "正しい"バージョンをmaticallyではありますが、Gradleに似たものがあるかどうかはわかりません。可能であれば、このBOMを使用することができます:

org.wildfly:wildfly-ejb-client-bom:10.0.0.Final 

そして、上記の依存関係のバージョンを省略することができます。

フィードバックをお送りください。

+0

ありがとう!それはたくさんの助けになりました。 問題はGradle build.gradleファイルで、アプリケーションプラグインを適用して「実行」タスクを呼び出す必要がありました。それが完了したら、それは魅力のように働いた! – specialk1st

関連する問題