Skip to Content

NoClassDefFoundError referencing Java Project

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 ?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    May 11, 2007 at 03:22 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • @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

  • avatar image
    Former Member
    May 11, 2007 at 11:34 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 11, 2007 at 11:17 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • @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.

  • avatar image
    Former Member
    May 11, 2007 at 11:26 AM

    Hi Michael,

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

    Regards,

    Gianluca Barile

    Add comment
    10|10000 characters needed characters exceeded

    • @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