1

I am using Eclipse Oxygen, but this was also the issue in the Neon version. I have started new Maven Project and selected webapp-javaee7 archetype. After the creation of the project is done, pom.xml was configured like this:

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>7.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

So, the javaee-endorsed-api-7.0.jar is added to the Endorsed libraries. As I understood from this post that jar file contains Annotations package javax.annotation.

I have imported package javax.annotation to some of my classes inside this project, and used some annotations. When I hover over some of these annotations I get the message: Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

When I try to open "attached" Javadoc in the browser I get warning dialog stating: The documentation location for (annotation name) has not been configured. For elements from libraries specify the Javadoc location URL on properties page of the parent JAR ...\target\endorsed\javaee-endorsed-api-7.0.jar.

It is not possible to attach source code or Javadoc to javaee-endorsed-api-7.0.jar.

When I make plain Java project and use javax.annotation package Javadocs are shown as expected.

How to solve this and make Eclipse show Javadocs for javax.annotation package within this Maven project I am working on?

Thanks.

milijan
  • 387
  • 4
  • 12

4 Answers4

2

I have found the solution for this issue among comments on this post. The solution is on project basis:

  • select particular project
  • go to Project -> Properties -> Java Build Path -> Order and Export
  • reorder libraries until the javadocs appear.

For me it worked to place JRE System Library on top of Endorsed Libraries. Which means that Eclipse is pulling javadocs from libraries in order specified by this tab. And because all javadocs for annotations in question are defined in javadocs placed in proper directory of jdk installation (on this tab annotated as JRE System Library) now they are shown as expected inside Eclipse.

solving issu This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

milijan
  • 387
  • 4
  • 12
0

it may be dependency issue or may be JDK and JRE version, i you can try this on JDK 8 and use 6.0 version of javaee-web-api. you can also refer the answer into stackoverflow link here.

Anshul Sharma
  • 3,432
  • 1
  • 12
  • 17
0

Your solution didn't work for me ( maybe I just didn't reorder them enough times? ) but in case somebody else comes across the same problem, this worked straight away for me:

I removed all the libraries ( Project, libraries ), cleaned the project so that all the missing dependencies would show as error, then added them and cleaned the profile again. Maybe this can help somebody

Dan
  • 530
  • 6
  • 22
0

Maven will not download source for dependencies that are not explicitly decleared in your pom.xml. I was using spring boot,so i did not have to include that java.persistence, as spring boot will include it without mention. What i did to fix it was to explicitly specify java.persistence in pom.xml like this

<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>javax.persistence-api</artifactId>
    <!-- <version>2.2</version> -->
</dependency>

Note: I comented out the version because Spring boot will choose the best version for me.

Adindu Stevens
  • 2,947
  • 3
  • 14
  • 20