Standalone EJB Client application fails with NoSuchMethodError: org.jboss.logging.Logger.getMessageLogger
jshepher Feb 20, 2012 1:14 AMI tried to do a remote EJB lookup from a standalone client, but got the following exception on my client application:
Exception in thread "main" java.lang.NoSuchMethodError: org.jboss.logging.Logger.getMessageLogger(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object; at org.jboss.ejb.client.Logs.<clinit>(Logs.java:44) at org.jboss.ejb.client.EJBClient.<clinit>(EJBClient.java:39) at org.jboss.ejb.client.naming.ejb.EjbNamingContext.doCreateProxy(EjbNamingContext.java:139) at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:113) at org.jboss.ejb.client.naming.ejb.EjbNamingContext.lookup(EjbNamingContext.java:96) at javax.naming.InitialContext.lookup(InitialContext.java:392) at EjbClient.main(EjbClient.java:30)
I followed this guide to creating the client:
https://docs.jboss.org/author/display/AS71/EJB+invocations+from+a+remote+client+using+JNDI
My environment:
Server: JBoss AS 7.1.0.Final
Client VM: JavaSE 1.6 Mac OS X VM
Client libraries:
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
jboss-ejb-api_3.1_spec-1.0.1.Final.jar
jboss-ejb-client-1.0.2.Final.jar
jboss-marshalling-1.3.9.GA.jar"/>
jboss-sasl-1.0.0.Final.jar"/>
jboss-marshalling-river-1.3.9.GA.jar
jboss-logging-3.1.0.GA.jar
xnio-nio-3.0.3.GA.jar
jboss-remoting-3.2.2.GA.jar
xnio-api-3.0.3.GA.jar
My client side code:
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.myapp.ejb.Greeter;
import org.myapp.ejb.GreeterRemote;
public class EjbClient {
public static void main(String[] args) throws NamingException{
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
Context context = new InitialContext(jndiProperties);
String beanName = Greeter.class.getSimpleName();
String viewClassName = GreeterRemote.class.getName();
GreeterRemote greeter = (GreeterRemote) context.lookup("ejb:" + "myejb/" + beanName + "/" + "!" + viewClassName);
System.out.println(greeter.greet("Jason"));
}
}
jboss-ejb-client.properties
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false remote.connections=default remote.connection.default.host=localhost remote.connection.default.port = 4447 remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false remote.connection.default.username=appuser remote.connection.default.password=apppassword
My Server side EJB:
Greeter.java
package org.myapp.ejb;
import javax.ejb.Stateless;
/**
* Session Bean implementation class Greeter
*/
@Stateless
public class Greeter implements GreeterRemote {
/**
* Default constructor.
*/
public Greeter() {
// TODO Auto-generated constructor stub
}
@Override
public String greet(String user){
return "Hello " + user;
}
}
GreeterRemote.java
package org.myapp.ejb;
import javax.ejb.Remote;
@Remote
public interface GreeterRemote {
String greet(String user);
}
-
ejbClient.src.zip 15.2 KB