Search code examples
javaejbweblogiclookup

Look-up of remote ejb using client-ejb jar


I have application packed as an .ear file with ejb module inside. There is stateless session bean implementing remote interface. Something like this:

package my.package.ext.impl;  
[...]
@Stateless(name = "MyPropertiesHandler", mappedName = "ejb/MyPropertiesHandler")
public class PropertiesHandler implements PropertiesHandlerRemote {
    [...]
}

and this:

package my.package.ext;  
[...]    
@Remote
public interface PropertiesHandlerRemote {
    [...]
}

There's also client-ejb jar generated, there are business remote interface and some other stuff inside.
This client-ejb jar is attached to other application as a Maven dependency.
I try to look-up PropertiesHandler service from this application:

PropertiesHandlerRemote propertiesHandler = InitialContext.doLookup(
    "ejb/MyPropertiesHandler#my.package.ext.PropertiesHandlerRemote");

At this moment I get following error:

java.lang.NoClassDefFoundError: my/package/ext/PropertiesHandlerRemote
at [...]
at sun.reflect.GeneratedMethodAccessor633.invoke(Unknown Source)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: my.package.ext.PropertiesHandlerRemote
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
Truncated. see log file for complete stacktrace

I run it on Weblogic 10.x as you can see above.
Any ideas that's going wrong?


Solution

  • The problem was that the client-ejb jar was packed in the root of an ear file, not in the /lib folder with other dependencies.
    The solution is to use <classifier>client</classifier> tag instead of <type>ejb-client</type> in the pom of the project where you want to use your client-ejb jar file.
    This problem is also discussed here: http://jira.codehaus.org/browse/MEAR-85
    Strange that this is the first time I met such problem, previously <type>ejb-client</type> tag worked perfect.