Re: REST with Java (JAX-RS) using Jersey - Tutorial

1,550 views
Skip to first unread message

Lars Vogel

unread,
Jan 28, 2013, 1:44:01 PM1/28/13
to vog...@googlegroups.com
Sorry, I don't know. Setup looks ok to me.

Best regards, Lars

2013/1/14 Donald McLachlan <donald.g....@gmail.com>:
> I was just going to use sockets but a colleague suggested I try REST, and
> this tutorial.
>
> First, I am using:
>
> # cat /etc/*-release
> openSUSE 11.4 (x86_64)
> VERSION = 11.4
> CODENAME = Celadon
>
> Preferences show I am building with java-6.6.0-openJDK-1.6.0
>
> I have tomcat6 installed and when I start it and connect via a web browser I
> see the welcome page, and was able to configure it to bring up the
> manager/html page before I shut it down (so eclipse can start it itself.)
>
> I downloaded jersey-bundle-1.16.jar and once I put it into the project's
> WebContent/WEB-INF/lib, (and refreshed eclipse) the section 5.2 Java Class
> example code was error free.
>
> I edited workspace/de.vogella.jersey.first/WebContent/WEB-INF/web.xml so it
> contains:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns="http://java.sun.com/xml/ns/javaee" xmlns
> :web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID"
> version="2.5">
> <display-name>de.vogella.jersey.first</display-name>
> <servlet>
> <servlet-name>Jersey REST Service</servlet-name>
>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
> <init-param>
> <param-name>com.sun.jersey.config.property.packages</param-name>
> <param-value>de.vogella.jersey.first</param-value>
> </init-param>
> <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>Jersey REST Service</servlet-name>
> <url-pattern>/rest/*</url-pattern>
> </servlet-mapping>
> </web-app>
>
> I see there is also a workspace/Servers/Tomcat v6.0 Server at
> localhost-config/web.xml file. Did I edit the wrong file?
>
> Anyway, when I "run" the app from within eclipse I get the following tomcat
> error report. It shows:
>
> http://localhost:8080/de.vogella.jersey.first/WEB-INF/classes/de/vogella/jersey/first/Hello.java
>
> [ Note: that path looks suspeicioys to me - is it? If so, how do I fix it?
> ]
>
> and then:
>
> HTTP Status 404 -
>
> type Status report
>
> message
>
> description The requested resource () is not available.
>
> Apache Tomcat/6.0.32
>
> And using a web brower to
> http://localhost:8080/de.vogella.jersey.first/rest/hello reports:
>
> HTTP Status 500 -
>
> type Exception report
>
> message
>
> description The server encountered an internal error () that prevented it
> from fulfilling this request.
>
> exception
>
> javax.servlet.ServletException: Servlet.init() for servlet Jersey REST
> Service threw exception
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>
> org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
>
> org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
> org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
> java.lang.Thread.run(Thread.java:679)
>
> root cause
>
> java.lang.NoClassDefFoundError: org/objectweb/asm/ClassVisitor
>
> com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79)
>
> com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
>
> com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
>
> com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
>
> com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:700)
>
> com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678)
>
> com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203)
>
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)
>
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557)
> javax.servlet.GenericServlet.init(GenericServlet.java:212)
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>
> org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
>
> org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
> org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
> java.lang.Thread.run(Thread.java:679)
>
> root cause
>
> java.lang.ClassNotFoundException: org.objectweb.asm.ClassVisitor
>
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
>
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
>
> com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:79)
>
> com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
>
> com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
>
> com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
>
> com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:700)
>
> com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678)
>
> com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203)
>
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)
>
> com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557)
> javax.servlet.GenericServlet.init(GenericServlet.java:212)
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>
> org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
>
> org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
> org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
> java.lang.Thread.run(Thread.java:679)
>
> note The full stack trace of the root cause is available in the Apache
> Tomcat/6.0.32 logs.
>
> Any help that can get me up and running greatly appreciated.
>
> Thanks,
> Don
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "vogella" group.
> To post to this group, send email to vog...@googlegroups.com.
> To unsubscribe from this group, send email to
> vogella+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/vogella?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Catalin Gerea

unread,
Jan 29, 2013, 6:26:24 AM1/29/13
to vog...@googlegroups.com
Hello

1. You do not tell us where you see the problem. In Eclipse or in command line.
2. The problem is related to annotations jars (asm.jar) missing from the classpath.
--
Time is what you make of it.
Reply all
Reply to author
Forward
0 new messages