SRy
SRy

Reputation: 2967

No ClassDefFound Error while maven project is added as dependency to a non-maven in java

am trying to develop a Axis2 webservice. I created a dynamic web project to generate my webservice classes from WSDL. Once I implemented my logic in Skelton which has code to query to database.

All this database access logic is in another Maven built Project. I added this Maven build project as dependency in my webservice projectBuildPathto my webservice project which is not a maven built.

When I run this webservice and hit the service from Soap UI , I am getting No ClassDef Found Error as below.

[ERROR] com/sample/test/common/dao/PersonDAO
java.lang.NoClassDefFoundError: com/sample/test/common/dao/PersonDAO
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.newInstance0(Class.java:326)
    at java.lang.Class.newInstance(Class.java:308)
    at org.apache.axis2.util.Utils$8.run(Utils.java:768)
    at org.apache.axis2.java.security.AccessController.doPrivileged(AccessController.java:132)
    at org.apache.axis2.util.Utils.createServiceObject(Utils.java:765)
    at org.apache.axis2.receivers.AbstractMessageReceiver.makeNewServiceObject(AbstractMessageReceiver.java:245)
    at org.apache.axis2.receivers.AbstractMessageReceiver.getTheImplementationObject(AbstractMessageReceiver.java:282)
    at rg.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
    at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)
    at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
    at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

My Webservice Code

     public class EnrollmentServiceSkeleton implements EnrollmentServiceSkeletonInterface{

            @Autowired
            PersonDAO personDao;   // Getters and Setters.

        public EnrollmentServiceRespMessage enrollmentServiceProfile (EnrollmentServiceReqMessage enrollmentService) {

// My WebService Logic
}

Is it the correct way that keeping a maven project as dependency to another non-maven directly in the build path of non-maven project?

Upvotes: 0

Views: 212

Answers (1)

Wes
Wes

Reputation: 7067

Maven works by building a project but not building its dependencies into the package. Therfore the project that uses the library has the option to overide or exclude the maven depedencies.

When included in a non maven project you need to build it including dependencies.

See How can I create an executable JAR with dependencies using Maven? with details on how to do that.

Upvotes: 1

Related Questions