cancel
Showing results for 
Search instead for 
Did you mean: 

NoClassDefFoundError referencing Java Project

michael_voss2
Participant
0 Kudos

Hello!

I created a WebDynpro project and want to reference some classes from an existing Java project created in NWDS. I added a Project Reference to the Java project, added the project to the Java Build Path and selected it for export in the project properties of the WebDynpro project.

During design time, everything ist fine; I can reference all packages and classes in my Java project from the WebDynpro project. Deployment shows no errors, but at Runtime, I get a NoClassDefFoundError when I hit the first reference to one of the Java projects classes.

Any hints on what I'm missing or doing wrong or any links to ressources where I might find something helpful ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I suggest to use DC's instead of simple projects.

So Solution for DCs:

1. go to Java project and create public part with type 'assembly' - include to it all the classes you need (and there dependences also)

2. go to the WD project. open used DC and add reference to the JavaDC (use pp from the step 1) with parameter build time

3. build WD DC - and go to the \_comp\gen\default\deploy\*.ear file. open it, open wda file inside it. Than \PORTAL-INF\lib\ - it should contain jar file from java dc

4. deploy WD dc

now all should work fine.

Former Member
0 Kudos

I've te same problem, and the wda file doesn't contain the specific jar file. Is it possible to add this jar automatically?

(the error is solved when I add the jar manually)

Also I heard that the problem is caused by the developer studio version.

michael_voss2
Participant
0 Kudos

Thanks a lot! After creating DC's (one of type "Java" and one of type "WebDynpro"), exposing all classes in a public part of type "compilation" and in another public part of type "assembly" and adding the DC as UsedDC in the WebDynpro DC, the Java classes are being found in the WebDynpro.

Now, I do have another problem since the Java DC needs to use an external jar. I put this into another DC of type "External Library", exposed the jar file in two public parts (one assembly, one compilation) and selected the Library DC as a used DC to my Java DC.

At runtime, I get an error from the class loader; the jar doesn't seem to be present after deployment.

Any hints ?

Former Member
0 Kudos

Solution the same:

1. From Java DC add reference to external lib pp with type 'compilation' - it will make Java dc compilable

2. From WD DC add reference to external lib pp with type 'assembly' - after building WD DC will contain external library also.

Former Member
0 Kudos

I am having a similar problem.

I have a Java DC, External Library DC and a Web Dynpro DC.

I've exposed the Java DC and External Library DC stuff with Public Parts. Then I've defined Used DCs in the Java DC pointing to External Library DC and Used DCs in the Web Dynpro DC pointing to the Java DC (and later to the External Library DC also just in case).

When I deploy the Web Dynpro DC the jar file for the Java DC is in the .wda file but the jar from the External Library is NOT!

When I try to run the Web Dynpro app on server it fails with class not found.

Has anyone been able to make this work?

Thanks!

michael_voss2
Participant
0 Kudos

@David:

Finally, I made all this work in the following way:

Create two public parts for your External Library DC, one of type assembly, one of type compilation. Add your jar as an entity in both public parts.

Create two public parts for your Java DC, one of type assembly, one of type compilation. Add your java packages as entities in both public parts.

In your Java DC, set the compilation public part of your External Library DC as Used DC.

In your WebDynpro DC, set the assembly public part of your External Library DC as Used DC.

In your WebDynpro DC, set the assembly public part of your Java DC as Used DC.

In your WebDynpro DC, set the compilation public part of your Java DC as Used DC.

This should be sufficient, but I also set the Java DC itself as used DC in the WebDynpro DC.

Make sure your jar entity has the subtype "Java Library" in the External Library DC public parts.

HTH

Michael

Answers (3)

Answers (3)

Former Member
0 Kudos

Michael,

If you indeed use "Java Project" type, then the problem is obvious -- your classes is never deployed on server.

Instead, create WD project, place Java classes here, expose them via public part, __build and deploy__ WD project. Now you can refere your classes from other WD projects, just add Used DC for compilation and project reference (as you did previously).

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

michael_voss2
Participant
0 Kudos

@Valery:

This sonds helpful. I'll try to put my packages into a WebDynpro DC.

Former Member
0 Kudos

Hi Michael,

can you post the error trace please you obtain at runtime?

Regards,

Gianluca Barile

michael_voss2
Participant
0 Kudos

@Gianluca:

Is that the information you wanted ? The is the complete runtime exception chain.

java.lang.NoClassDefFoundError: myReferencedJavaNamespace/MyReferencedClassName
	at lvr.ecmzu.mv.ECMZUAuskunftInputView.myWebDynproMethod(ECMZUAuskunftInputView.java:583)
	at lvr.ecmzu.mv.ECMZUAuskunftInputView.onActionfindResults(ECMZUAuskunftInputView.java:231)
	at lvr.ecmzu.mv.wdp.InternalECMZUAuskunftInputView.wdInvokeEventHandler(InternalECMZUAuskunftInputView.java:278)
	at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
	at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
	at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:101)
	at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:304)
	at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:659)
	at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
	at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:251)
	at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
	at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
	at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java(Compiled Code))
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java(Compiled Code))
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java(Inlined Compiled Code))
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java(Compiled Code))
	at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java(Compiled Code))
	at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java(Compiled Code))
	at com.sap.engine.services.httpserver.server.Client.handle(Client.java(Compiled Code))
	at com.sap.engine.services.httpserver.server.Processor.request(Processor.java(Compiled Code))
	at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java(Compiled Code))
	at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java(Compiled Code))
	at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java(Compiled Code))
	at java.security.AccessController.doPrivileged1(Native Method)
	at java.security.AccessController.doPrivileged(AccessController.java(Compiled Code))
	at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java(Compiled Code))
	at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java(Compiled Code))

Thanks

Michael

Former Member
0 Kudos

Michael,

please check the row 583 of the file ECMZUAuskunftInputView.java.

<b>lvr.ecmzu.mv.ECMZUAuskunftInputView.myWebDynproMethod(ECMZUAuskunftInputView.java:583)</b>

or post the code you've written there.

Regards,

Gianluca Barile

michael_voss2
Participant
0 Kudos

@Gianluca:

This is the line I reference one of the classes from my Java project, so no surprise the error occurs there

myArrayList.addAll(myReferencedPackage.MyReferencedClass.someMethod(...);

I'm going to give Valery's hint a try...

Thank you very much

Former Member
0 Kudos

Hi,

I think no need to import the classes from other java projects.

If u want to import any classes by

Right click->Source->Organize Imports..

Automatically it will import the classes.

Try this one.

Regards,

Lavanya.G

michael_voss2
Participant
0 Kudos

@Lavanya:

No, sorry, this doesn't solve the problem. All I can see is that "Oragnize Imports" restricts the "imports" directives to the absolute minimum. Nevertheless I tried it , but still get the error.