Avatar billede fredand Forsker
23. august 2010 - 21:23 Der er 1 løsning

How to solve this classnotfound exception with maven?

Hello!

I might not have been so informative at may last post concerning this problem, so I post a new one. I will close the other one.

But if you got any idea how to solve this please let me know!

I have struggled with this problem for a month now with out any progress.

I got 3 projects to lab with, actually right now the problem only concerns 2 of them.

annotations.pom - a project that got a simple runtime annotation and annotation processor (out of the picture of the problem)

common.pom - a project with a taglet used for javadoc

test.pom - a project to test tha annotations and the taglet.

How ever, the idea is to let the taglet produce a special javadoc for all code that uses the annotation. It will use reflection to get the class where it is used and print out info about the annotation it uses.

At this sketch you can see the dependency between the projects:
http://fredand44.webs.com/bilder/javadoc_problem.jpg

In the class test.Tester I use the taglet for javadoc.
But when I run mvn javadoc:javadoc in project test I just get

[WARNING] java.lang.ClassNotFoundException: test.Tester                                                                                                                                                 
[WARNING] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)                                                                                                                                     
[WARNING] at java.security.AccessController.doPrivileged(Native Method)                                                                                                                                 
[WARNING] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[WARNING] at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
[WARNING] at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
[WARNING] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
[WARNING] at java.lang.Class.forName0(Native Method)
[WARNING] at java.lang.Class.forName(Class.java:169)
[WARNING] at common.javadoctaglet.TestJavadocTaglet.toString(TestJavadocTaglet.java:61)

At row 61 I got this line:
Class c = Class.forName(tags[0].text());

In some how when maven run javadoc for test, it can not find the classes inside the project?

I have tried several diffrent ways to add test-1.0.0.jar to the classpath for maven:
    <additionalClasspathElements>
          <additionalClasspathElement>/home/fredrik/workspaces/eclipse_workspaces/annotation_javadoc_workspace/test/target/test-1.0.0.jar</additionalClasspathElement>
        </additionalClasspathElements>
   
    <bootclasspath>/home/fredrik/workspaces/eclipse_workspaces/annotation_javadoc_workspace/test/target/test-1.0.0.jar:/usr/lib/jvm/java-1.6.0-sun-1.6.0.16/jre/lib/rt.jar</bootclasspath>
   
    <bootclasspathArtifacts>
     

      <bootclasspathArtifact>
      <groupId>test</groupId>
      <artifactId>test</artifactId>
      <version>1.0.0</version>
      </bootclasspathArtifact>
</bootclasspathArtifacts>

But no luck.

If you guys got any idea how to solve this please let me know!

Best regards
Fredrik
Avatar billede fredand Forsker
24. august 2010 - 15:36 #1
Hello guys!

I had to solve this in a very bad solution.

I had to create an own JarClassLoader and search for suitable jars and add them to classpath during runtime.

I'm not sure I will stick to this plan...but for now I guess I have to.

Best regards
Fredrik
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester