2015-02-09 102 views
0

我已經部署在jboss-eap-6.3會話bean它返回一個僱員對象時getEmployeeById(int)方法是調用。java.lang.NoSuchMethodError:org.jboss.ejb.client.EJBClientContext.registerEJBClientContextListener(Lorg/JBoss的/ EJB /客戶端/ EJBClientContextListener;)z

我正在通過遠程客戶端調用此方法(使用依賴關係:jboss-as-ejb-client-bom)。雖然它返回了預期的結果,但它在結果之前給出了java.lang.NoSuchMethodError:異常。這個例外背後的原因是什麼?

完全控制檯輸出:

Looking EJB via JNDI 
    ejb:/OMS_POC_1//EmployeeManagerImpl!com.test.oms.facade.EmployeeManager 
    log4j: reset attribute= "false". 
    log4j: Threshold ="null". 
    log4j: Level value for root is [DEBUG]. 
    log4j: root level set to DEBUG 
    log4j: Class name: [org.apache.log4j.ConsoleAppender] 
    log4j: Parsing layout of class: "org.apache.log4j.PatternLayout" 
    log4j: Setting property [conversionPattern] to [%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n]. 
    log4j: Adding appender named [console] to category [root]. 
    2015-02-09 09:53:31 DEBUG logging:48 - Logging Provider: org.jboss.logging.Log4jLoggerProvider 
    2015-02-09 09:53:31 INFO client:42 - JBoss EJB Client version 1.0.5.Final 
    2015-02-09 09:53:31 DEBUG EJBClientPropertiesLoader:101 - Looking for jboss-ejb-client.properties using classloader [email protected] 
    2015-02-09 09:53:31 DEBUG EJBClientPropertiesLoader:105 - Found jboss-ejb-client.properties using classloader sun.misc.Launcher$AppClassLoa[email protected] 
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:177 - endpoint.create.options. has the following options {} 
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:177 - remote.connectionprovider.create.options. has the following options {org.xnio.Options.SSL_ENABLED=>false} 
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:177 - remote.connection.default.connect.options. has the following options {org.xnio.Options.SASL_POLICY_NOANONYMOUS=>false} 
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:177 - remote.connection.default.channel.options. has the following options {} 
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:412 - Connection org.jboss.ejb.client.Properties[email protected]79929190 successfully created for connection named default 
    2015-02-09 09:53:31 DEBUG PropertiesBasedEJBClientConfiguration:230 - No clusters configured in properties 
    2015-02-09 09:53:31 DEBUG EJBClientContext:112 - EJB client context initializer [email protected]99a failed to initialize context [email protected] 
    java.lang.NoSuchMethodError: org.jboss.ejb.client.EJBClientContext.registerEJBClientContextListener(Lorg/jboss/ejb/client/EJBClientContextListener;)Z 
     at org.jboss.ejb.client.TransactionRecoveryContextInitializer.initialize(TransactionRecoveryContextInitializer.java:36) 
     at org.jboss.ejb.client.EJBClientContext.init(EJBClientContext.java:110) 
     at org.jboss.ejb.client.EJBClientContext.create(EJBClientContext.java:164) 
     at org.jboss.ejb.client.EJBClientContext.create(EJBClientContext.java:145) 
     at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.<init>(ConfigBasedEJBClientContextSelector.java:70) 
     at org.jboss.ejb.client.EJBClientContext.<clinit>(EJBClientContext.java:77) 
     at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:120) 
     at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:104) 
     at com.sun.proxy.$Proxy0.getEmployeeById(Unknown Source) 
     at com.test.rmi.RMIClient.main(RMIClient.java:29) 
    2015-02-09 09:53:31 INFO xnio:63 - XNIO Version 3.0.3.GA 
    2015-02-09 09:53:31 INFO nio:55 - XNIO NIO Implementation Version 3.0.3.GA 
    2015-02-09 09:53:31 INFO remoting:70 - JBoss Remoting version 3.2.3.GA 
    2015-02-09 09:53:31 DEBUG nio:88 - Started channel thread 'Remoting "client-endpoint" write-1', selector [email protected] 
    2015-02-09 09:53:31 DEBUG nio:88 - Started channel thread 'Remoting "client-endpoint" read-1', selector [email protected] 
    2015-02-09 09:53:32 DEBUG RemotingConnectionEJBReceiver:145 - Channel Channel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447 opened for context EJBReceiverContext{[email protected], receiver=Remoting connection EJB receiver [connection=Remoting connection <7669929e>,channel=jboss.ejb,nodename=isurug]} Waiting for version handshake message from server 
    2015-02-09 09:53:32 INFO VersionReceiver:101 - Received server version 2 and marshalling strategies [river] 
    2015-02-09 09:53:32 INFO RemotingConnectionEJBReceiver:162 - Successful version handshake completed for receiver context EJBReceiverContext{[email protected], receiver=Remoting connection EJB receiver [connection=Remoting connection <7669929e>,channel=jboss.ejb,nodename=isurug]} on channel Channel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447 
    2015-02-09 09:53:32 DEBUG RemotingConnectionEJBReceiver:427 - Received module availability report for 1 modules 
    2015-02-09 09:53:32 DEBUG RemotingConnectionEJBReceiver:429 - Registering module EJBModuleIdentifier{appName='', moduleName='OMS_POC_1', distinctName=''} availability for receiver context EJBReceiverContext{[email protected], receiver=Remoting connection EJB receiver [connection=Remoting connection <7669929e>,channel=jboss.ejb,nodename=isurug]} 
    2015-02-09 09:53:32 DEBUG ConfigBasedEJBClientContextSelector:142 - Registered 1 remoting EJB receivers for EJB client context [email protected] 
    2015-02-09 09:53:32 WARN ChannelAssociation:392 - Unsupported message received with header 0xffffffff 
    2015-02-09 09:53:32 DEBUG EJBClientContext:557 - [email protected] deployment node selector selected isurug node for appname=,modulename=OMS_POC_1,distinctname= 
    _______[ {Name: test}, {Age: 87}, {Description: tesfgsgs} ] 
    2015-02-09 09:53:32 DEBUG AutoConnectionCloser:91 - Closing Remoting connection <7669929e> 
    2015-02-09 09:53:32 INFO ChannelAssociation:370 - Channel Channel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447 can no longer process messages 
    2015-02-09 09:53:32 DEBUG ChannelAssociation:105 - Closing channel Channel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447 
    2015-02-09 09:53:32 DEBUG ChannelAssociation:336 - Registering a re-connect handler org.jboss[email protected]4a776482 for broken channel Channel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447 in EJB client context [email protected] 
    2015-02-09 09:53:32 DEBUG RemotingConnectionEJBReceiver:141 - Closing channelChannel ID b56abf2c (outbound) of Remoting connection 30ec6243 to localhost/127.0.0.1:4447 
    2015-02-09 09:53:32 DEBUG AutoConnectionCloser:91 - Closing endpoint "client-endpoint" <5a5dae04> 

以下是遠程客戶端代碼:

/** 
* 
*/ 
package com.test.rmi; 

import java.util.Hashtable; 

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

import com.test.oms.facade.EmployeeManager; 
import com.test.oms.facade.EmployeeManagerImpl; 

public class RMIClient { 

    public static void main(String[] args) { 

     try { 
      EmployeeManager manager = lookupRemoteEJB(); 
      System.out.println("_______" 
        + manager.getEmployeeById(3).toString()); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 

    @SuppressWarnings({ "unchecked", "rawtypes" }) 
    private static EmployeeManager lookupRemoteEJB() throws NamingException { 
     final Hashtable jndiProperties = new Hashtable(); 
     jndiProperties.put(Context.URL_PKG_PREFIXES, 
       "org.jboss.ejb.client.naming"); 

     final Context context = new InitialContext(jndiProperties); 

     final String appName = ""; 
     final String moduleName = "OMS_POC_1"; 
     final String distinctName = ""; 
     final String beanName = EmployeeManagerImpl.class.getSimpleName(); 
     final String viewClassName = EmployeeManager.class.getName(); 

     System.out.println("Looking EJB via JNDI "); 
     System.out.println("ejb:" + appName + "/" + moduleName + "/" 
       + distinctName + "/" + beanName + "!" + viewClassName); 

     return (EmployeeManager) context.lookup("ejb:" + appName + "/" 
       + moduleName + "/" + distinctName + "/" + beanName + "!" 
       + viewClassName); 

    } 
} 

更新:

繼在我的pom.xml爲jboss-as-ejb-client-bom是行家依賴

<dependency> 
     <groupId>org.jboss.as</groupId> 
     <artifactId>jboss-as-ejb-client-bom</artifactId> 
     <version>7.1.1.Final</version> 
     <type>pom</type> 
</dependency> 
+1

與版試玩'7.1.1.Final-紅帽 - 1'對'的jboss-AS-EJB-客戶bom'是認證 與JBoss EAP的工作釋放6.它需要你有機會到JBoss EAP 6 maven倉庫。請參閱https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.2/html/Development_Guide/Configure_the_JBoss_Enterprise_Application_Platform_Maven_Repository_Using_the_Maven_Settings.html – 2015-02-09 12:51:47

+0

@FedericoSierra我更新了「jboss-as-ejb-client-bom」依賴性的問題。這就是我目前使用的。 – 2015-02-09 13:11:59

+1

您正在使用'7.1.1.Final',建議從RedHat maven倉庫中爲EAP提供'7.1.1.Final-redhat-1'。請參閱https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.2/html/Development_Guide/Configure_the_JBoss_Enterprise_Application_Platform_Maven_Repository_Using_the_Maven_Settings.html – 2015-02-10 02:28:41

回答

0

正如Federico在上面的評論中提到的那樣,我遵循鏈接並將settings.xml添加到M2_HOME。但版本7.1.1.Final-redhat-1不會鍛鍊,因爲它會使構建失敗。依賴關係爲我工作。

<dependency> 
     <groupId>org.jboss.as</groupId> 
     <artifactId>jboss-as-ejb-client-bom</artifactId> 
     <version>7.4.0.Final-redhat-19</version> 
     <type>pom</type> 
     <scope>import</scope> 
    </dependency>