Cant' lookup an EJB via JNDI into java application under EAP6
akrima Sep 26, 2014 6:55 AMI have Tow separated applications :
1=> The first named : my-services (contains Remote Interfaces and Implementations) and this is an example:
@Remote(IPersonRemote.class)
@Local(IPersonLocal.class)
@Stateless
public class PersonFactory implements IPersonLocal, IPersonRemote {
private static final long serialVersionUID = 1L;
@Override
public voif findByCostumer(final String cId) {
System.out.println("The client id is "+cId);
}
}
I marked a clean and install (maven) and that generated a jar file in the target folder and I deployed it on the jboss EAP6:
my-services.jar
my-services.jar.deployed
2=> I have a another java project named : MyProject with a main methode like this:
public class RemoteEJBClient {
public static void main(String[] args) throws Exception {
invokeStatelessBean();
}
private static void invokeStatelessBean() 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 = "my-services-all";
final String distinctName = "";
final String beanName = PersonFactory.class.getSimpleName();
final String viewClassName = IPersonFactoryRemote.class.getName();
final IPersonFactoryRemote statelessRemoteCalculator = (IPersonFactoryRemote) context
.lookup("ejb:" + appName + "/" + moduleName + "/"
+ distinctName + "/" + beanName + "!" + viewClassName);
}
}
but when I try to execute the programme it gives me the following errors :
DEBUG org.jboss.logging - EjbNamingContext.java:59 - Logging Provider: org.jboss.logging.Log4jLoggerProvider
INFO org.jboss.ejb.client - EJBClient.java:45 - JBoss EJB Client version 1.0.24.Final-redhat-1
Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/ejb/EJBException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.jboss.ejb.client.EJBClient.createProxy(EJBClient.java:150)
at org.jboss.ejb.client.naming.ejb.EjbNamingContext.doCreateProxy(EjbNamingContext.java:221)
at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createEjbProxy(EjbNamingContext.java:193)
at org.jboss.ejb.client.naming.ejb.EjbNamingContext.lookup(EjbNamingContext.java:176)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at RemoteEJBClient.invokeStatelessBean(RemoteEJBClient.java:29)
at RemoteEJBClient.main(RemoteEJBClient.java:16)
I can't understand no think in that exceptions.
Any explications & sollutions please.