2

I am working on a web app project written in Java (1.6) using Eclipse IDE (3.6), and have decided to use Jetty (8.0.4) as the web server and servlet container. I am using maven (2) for dependency and build management. To get started, I decided to write a simple test application to make sure I had things working end-to-end. This is working fine, and I am able to start up the server and create some simple servlets. However, the source and Javadoc jars were not downloaded by maven, so when the mouse hovers over method names or classes, no documentation is found. It just reports the following:

Open Declaration javax.servlet.http.HttpServletResponse Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.

I've searched for how to do this, and all I could find was this page on the Eclipse website describing how to configure maven to download the source modules as well. It says that the source module jars have the same name as the binary jars, with the suffix "-sources". I added source module dependencies to my maven config for each binary module, like so:

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-server</artifactId>
    <version>${jettyVersion}</version>
</dependency>

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-server-sources</artifactId>
    <version>${jettyVersion}</version>
</dependency>

However, maven failed to find the source module dependencies:

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Jetty Servlet Example 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-server-sources/8.0.4.v20111024/jetty-server-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlet-sources/8.0.4.v20111024/jetty-servlet-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-servlet-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util-sources/8.0.4.v20111024/jetty-util-sources-8.0.4.v20111024.pom
[WARNING] The POM for org.eclipse.jetty:jetty-util-sources:jar:8.0.4.v20111024 is missing, no dependency information available
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-server-sources/8.0.4.v20111024/jetty-server-sources-8.0.4.v20111024.jar
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-servlet-sources/8.0.4.v20111024/jetty-servlet-sources-8.0.4.v20111024.jar
Downloading: http://repo1.maven.org/maven2/org/eclipse/jetty/jetty-util-sources/8.0.4.v20111024/jetty-util-sources-8.0.4.v20111024.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.098s
[INFO] Finished at: Sun Apr 15 15:42:59 PDT 2012
[INFO] Final Memory: 5M/180M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project hello-world: Could not resolve dependencies for project org.example:hello-world:jar:0.1-SNAPSHOT: The following artifacts could not be resolved: org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024, org.eclipse.jetty:jetty-servlet-sources:jar:8.0.4.v20111024, org.eclipse.jetty:jetty-util-sources:jar:8.0.4.v20111024: Could not find artifact org.eclipse.jetty:jetty-server-sources:jar:8.0.4.v20111024 in central (http://repo1.maven.org/maven2) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Any pointers on how to configure maven to download the Jetty sources and javadocs?

2
  • Ugh... sorry for the badlly-formatted quotes containing sample configuration and output. The draconian code format checker forced me to revise it so many times to get it to allow me to post, and this was the result, and now it looks horrible. I'll read up on how to do this properly for future posts.
    – boshea
    Apr 15, 2012 at 23:19
  • Ok, just noticed the "Edit" link, so I've fixed up the formatting a bit. The <code> and <pre> tags appear in the output though, which is odd since they didn't appear in the preview display while I was editing.
    – boshea
    Apr 16, 2012 at 2:53

1 Answer 1

3

Try to recreate your Eclipse project with this Maven command:

mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true

Another option is to update your pom.xml:

<plugin>
    <artifactId>org.eclipse.jetty</artifactId>
    <version>${jettyVersion}</version>
    <configuration>
        <downloadSources>true</downloadSources>
        <downloadJavadocs>true</downloadJavadocs>
    </configuration>
</plugin>

Both solutions only work if the source and javadocs were provided to the repo you're downloading from.

In your case (and your version) it should work because you can find the sources.jar in the Jetty repository.

7
  • Excellent, thank you Martin! Using the mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true command did exactly what I needed, although I got some errors adding the <configuration> sections to my pom.xml file. I'll try to work through those, but it looks like I have the answer that I needed. Thank you very much.
    – boshea
    Apr 16, 2012 at 3:16
  • @boshea You're welcome. As you are a new user I take the freedom to remind you to vote up for my reply if you like it and/or accept the reply if it solved your problem. Apr 16, 2012 at 3:24
  • I did try to vote up your reply, but it didn't allow me to because I am a new user (well, a new poster) and don't yet have 15 reputation points or some such. I accepted the reply as having solved my problem. Thanks again and Regards,
    – boshea
    Apr 16, 2012 at 3:56
  • @boshea to accept you have to click to accept button √ on the bottom. It's on the bottom of the vote up/vote down button... Apr 16, 2012 at 5:46
  • Yes, I have already done that. What I was not able to do is vote up your reply. Regards.
    – boshea
    Apr 16, 2012 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.