1

I'm getting a java.lang.ClassNotFoundException: javax.ejb.EJBObject error when I'm running my application as a JAR file. When running it in Eclipse everything is working fine.

The application properly access the main class and the main method. But when it tries to load the application context it cannot resolve a reference to an EJB bean. I then get the following error:

Error creating bean with name 'bc' defined in class path resource [blabla.xml]:
    Initialization of bean failed; 
nested exception is 
    java.lang.NoClassDefFoundError: javax/ejb/EJBObject 
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) 
        ... 
Caused by: 
    java.lang.ClassNotFoundException: javax.ejb.EJBObject

I've included all runtime-scoped dependencies with Maven in the JAR file.

Do you know any further information regarding this error?

1
  • When I specify the classpath through the command line instead of in the MANIFEST.MF, I'm still getting the same error. Commented May 7, 2010 at 12:14

1 Answer 1

1

A little list of things to check:

  • Is the EJBObjectclass located in a dependency with provided scope?
  • Is the JAR containing the EJBObject class really on the classpath? I.e., do you either add it to the class path when running the JAR, or do you use the onejar-plugin to put your dependencies into the JAR?
  • If you are using onejar: Are you really running the JAR created by onejar (myproject.one-jar.jar), and not the one without the dependencies (myproject.jar)?
Sign up to request clarification or add additional context in comments.

1 Comment

Of course the JAR containing EJBObject was not on the classpath. Although specified in the pom.xml with the scope "compile", the maven-jar-plugin didn't include it in the classpath. This was due to the JAR being also specified in the parent pom als "provided". Strangely the setting of the parent pom did overrule the one of the child.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.