Olá,
estou tentando acessar meu EJB em uma aplicação cliente desktop usando RMI, porém esta exception está sendo lançada:
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/ejb/RemoveException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Exception in thread "main" Java Result: 1
Alguém sabe o que pode estar havendo? Estou usando o Glasshfish 3.1 e minhas classes estão assim:
Interface do EJB:
@Remote
public interface NewSessionBeanLocal {
String test();
}
Implementação:
@Stateless
public class NewSessionBean implements NewSessionBeanLocal {
public String test() {
return "Success";
}
}
Código da aplicação cliente:
public static void main(String[] args) throws RemoteException, RemoveException, Exception {
NewSessionBean test = (NewSessionBean) new InitialContext().lookup("java:global/EnterpriseApplication1/EnterpriseApplication1-ejb/NewSessionBean");
test.test();
}
Achei estranho não ter que passar as propriedades na inicialização do contexto, entretanto, no site oficial do Glasshfish, há estas informações:
Step 1. Use the no-arg InitialContext() constructor in your code.
The most common problem developers run into is passing specific JNDI bootstrapping properties to InitialContext(args). Some other vendors require this step but GlassFish does not. Instead, use the no-arg InitialContext() constructor.
Logo depois:
Step 3. Include the appropriate GlassFish .jars in the java client's classpath.
For GlassFish v3
Include $GLASSFISH_HOME/modules/gf-client.jar in the client's classpath.
E.g., assuming the application classes are in /home/user1/myclasses and the main client class is acme.MyClient :
java -classpath $GLASSFISH_HOME/modules/gf-client.jar:/home/user1/myclasses acme.MyClient
Note that the Java EE 6 API classes are automatically included by gf-client.jar so there is no need to explicitly add javaee.jar to the classpath. gf-client.jar refers to many other .jars from the GlassFish installation directory so it is best to refer to it from within the installation directory itself rather than copying it(and all the other .jars) to another location.
Adicionei o jar no classpath.
http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB
Já tentei passar settar as propriedades da aplicação apontando para o Glassfish (ele é local), mas obtive a mesma exceção.
Alguém sabe a solução para isto?
Obrigado!
[]'s