Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taglet blocks javadoc generation with ClassNotFoundException #19

Open
jeremydouglass opened this issue Sep 20, 2018 · 8 comments
Open

Comments

@jeremydouglass
Copy link
Contributor

When I run the Processing template targeting Java SE-1.8, the

[javadoc] Constructing Javadoc information...
[javadoc] Standard Doclet version 10.0.1
[javadoc] Building tree for all the packages and classes...
[javadoc] javadoc: error - Error - Exception java.lang.ClassNotFoundException thrown while trying to register Taglet ExampleTaglet...

In the Processing Library template there is a file

resources > code > ExampleTaglet.java

It begins with

import com.sun.tools.doclets.Taglet;

I think that in Java 8+ that would instead would be:

import java.jdk.Taglet;

...I'm not sure if there are other changes that would need to be made.

I am not familiar with doclets and Taglets -- looking over the code, it isn't clear to me why ExampleTaglet would actually be used -- although is referenced in Ant's build.xml:

<taglet name="ExampleTaglet" path="resources/code" />

Anyway, when it fails the documentation as a whole fails to build.

Assuming this is a problem for others, it seems like either ExampleTaglet should be fixed or it should be removed from build.xml to not block javadoc generation.

My solution was to remove the above line from build.xml.

@prisonerjohn
Copy link
Member

The ExampleTaglet is used to allow the use of @example tags in the javadocs for the class. The HelloLibrary class uses this, and when it's successful you'll notice that the contents of the Hello.pde example are included at the top of the javadoc for that class.

I just tested an Ant build in IntelliJ targeting Java 1.8 and it worked as expected (with no changes). Note that you need to keep the ExampleTaglet.class file in the code folder.

@jeremydouglass Can you give me more details on your environment so I can try to see why it failed for you?

@federico-pepe
Copy link

federico-pepe commented Sep 6, 2019

I'm developing a Processing Library for the first time and I got this problem too while generating the javadoc. Everything works correctly but the docs aren't created automatically.

 [javadoc] Generating Javadoc
  [javadoc] Javadoc execution
  [javadoc] Loading source file /Users/federicopepe/GitHub/nice-color-palettes/tmp/NiceColorPalettes/src/nice/palettes/ColorPalette.java...
  [javadoc] Constructing Javadoc information...
  [javadoc] 1 error
  [javadoc] javadoc: error - An internal exception has occurred. 
  [javadoc] 	(java.lang.NoClassDefFoundError: com/sun/tools/doclets/Taglet)
  [javadoc] Please file a bug against the javadoc tool via the Java bug reporting page
  [javadoc] (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)
  [javadoc] for duplicates. Include error messages and the following diagnostic in your report. Thank you.
  [javadoc] java.lang.NoClassDefFoundError: com/sun/tools/doclets/Taglet
  [javadoc] 	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
  [javadoc] 	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
  [javadoc] 	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
  [javadoc] 	at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550)
  [javadoc] 	at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
  [javadoc] 	at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
  [javadoc] 	at java.base/java.security.AccessController.doPrivileged(Native Method)
  [javadoc] 	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
  [javadoc] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
  [javadoc] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager.addCustomTag(TagletManager.java:229)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.BaseConfiguration.initTagletManager(BaseConfiguration.java:837)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.BaseConfiguration.finishOptionSettings0(BaseConfiguration.java:777)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration.finishOptionSettings0(HtmlConfiguration.java:861)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.BaseConfiguration.setOptions(BaseConfiguration.java:798)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:200)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.doclets.toolkit.AbstractDoclet.run(AbstractDoclet.java:114)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.doclet.StandardDoclet.run(StandardDoclet.java:72)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.tool.Start.parseAndExecute(Start.java:582)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:431)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.tool.Start.begin(Start.java:344)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.tool.Main.execute(Main.java:63)
  [javadoc] 	at jdk.javadoc/jdk.javadoc.internal.tool.Main.main(Main.java:52)
  [javadoc] Caused by: java.lang.ClassNotFoundException: com.sun.tools.doclets.Taglet
  [javadoc] 	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
  [javadoc] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
  [javadoc] 	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
  [javadoc] 	... 23 more

@jeremydouglass
Copy link
Contributor Author

jeremydouglass commented Sep 6, 2019

@jeremydouglass Can you give me more details on your environment so I can try to see why it failed for you?

I was using Eclipse 4(.8?) on OS X 10.12.

I believe the issue may have been (?) that I had JDK 10 and was using it to target 8. This largely works, except when it doesn't.

Possibly related: processing/processing-library-template#20

@jeremydouglass
Copy link
Contributor Author

@nakednous
Copy link

same error. The ExampleTaglet.class and ExampleTaglet.java are there in the code folder. Tested environments in archlinux:

  1. java-8-openjdk and Processing-3.5.4 (which used to work fine); and,
  2. java-11-openjdk and Processing4.0.0alpha3. Tried removing the <taglet name="ExampleTaglet" path="resources/code" /> workaround, but it produces almost totally incomplete docs.

@clankill3r
Copy link

I also have this problem.

If you look at:
https://docs.oracle.com/javase/9/docs/api/com/sun/tools/doclets/Taglet.html

Then it states:

Note: This interface has been superseded by its replacement, Taglet.

The file ExampleTarget.java is the only file referencing com.sun.tools.doclets.Taglet;.
But even if I change that then an error about com.sun.tools.doclets.Taglet; still shows up.

I suspect that the file resources/ant-contrib-1.0b3.jar is referencing this.

For now I commented the following lines in build.xml so the creation of the javadoc is skipped:

<antcall target="generate.javadoc" />
<mkdir dir="${project.tmp}/${project.name}/reference" />

@clankill3r
Copy link

This is work in progress, but if I change generate.javadoc to the following:

        <target name="generate.javadoc" if="is.normal">
	  	<!-- create the java reference of the Library -->
		<javadoc sourcepath="${project.src}" 
				destdir="${project.tmp}/${project.name}/reference"
				classpath="${classpath.local.location}/core.jar;{project.bin}" 
				/>
	</target>

And in terminal: ant generate.javadoc (else the tmp directory with the javadoc gets deleted directly).

But it creates a javadoc!
I have to dig further of that the other settings did, but it's more fun to fix things from something that is working.

@clankill3r
Copy link

Ok, actually this is the offending line:

<taglet name="ExampleTaglet" path="resources/code" />

Also I removed

stylesheetfile="resources/stylesheet.css"

With the stylesheet it looks like this for me:

Screenshot 2022-12-14 at 17 27 24

and without:

Screenshot 2022-12-14 at 17 27 14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants