Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

jersey import error

Hi,

I am working on below example

http://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/

I donnloaded and extracted code to
C:\Users\ganesha\workingSession_mkyong\jesey\RESTfulExample

Then i imported as maven project.

Then i did Maven Clean then Maven Instal. I got error as attached.
please advise
jerseyEx.docx
Avatar of gudii9
gudii9
Flag of United States of America image

ASKER

says

its working by adding @Produces


I need to see if that helps solving this issue
Avatar of gudii9

ASKER

package com.mkyong.rest;
 
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
 
@Path("/hello")
public class HelloWorldService {
 
	@GET
	@Path("/{param}")
	@Produces(MediaType.TEXT_PLAIN)
	public Response getMsg(@PathParam("param") String msg) {
 
		String output = "Jersey say : " + msg;
 
		return Response.status(200).entity(output).build();
 
	}
 
}

Open in new window

i addedd still getting same error.



HTTP Status 404 - /RESTfulExample/


type Status report

message /RESTfulExample/

description The requested resource is not available.


Apache Tomcat/8.0.24


when i navigate to this URL

http://localhost:8080/RESTfulExample/

Please advise
Avatar of gudii9

ASKER

when i go to below url

http://localhost:8080/RESTfulExample/rest/hello/john
i got below error

HTTP Status 500 - Servlet.init() for servlet jersey-serlvet threw exception


type Exception report

message Servlet.init() for servlet jersey-serlvet threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception
javax.servlet.ServletException: Servlet.init() for servlet jersey-serlvet threw exception
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
	java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Unknown Source)


root cause
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
	com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99)
	com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1298)
	com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:169)
	com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:775)
	com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:771)
	com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
	com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:771)
	com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:766)
	com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:488)
	com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:318)
	com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:609)
	com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
	com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
	com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
	javax.servlet.GenericServlet.init(GenericServlet.java:158)
	org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
	org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
	java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	java.lang.Thread.run(Unknown Source)


note The full stack trace of the root cause is available in the Apache Tomcat/8.0.24 logs.


Apache Tomcat/8.0.24

Open in new window


please advise
Avatar of gudii9

ASKER

when i go to below url

http://localhost:8080/RESTfulExample/rest/hello/mkyong

i still get same error
HTTP Status 500 - Servlet.init() for servlet jersey-serlvet threw exception


type Exception report

message Servlet.init() for servlet jersey-serlvet threw exception

description The server encountered an internal error that prevented it from fulfilling this request.

exception
javax.servlet.ServletException: Servlet.init() for servlet jersey-serlvet threw exception
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Unknown Source)


root cause
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
      com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99)
      com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1298)
      com.sun.jersey.server.impl.application.WebApplicationImpl.access$700(WebApplicationImpl.java:169)
      com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:775)
      com.sun.jersey.server.impl.application.WebApplicationImpl$13.f(WebApplicationImpl.java:771)
      com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:193)
      com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:771)
      com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:766)
      com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:488)
      com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:318)
      com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:609)
      com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:210)
      com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
      com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
      javax.servlet.GenericServlet.init(GenericServlet.java:158)
      org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
      org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
      org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
      org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
      org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
      java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Unknown Source)


note The full stack trace of the root cause is available in the Apache Tomcat/8.0.24 logs.


Apache Tomcat/8.0.24
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

my web.xml exactly same as

http://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/

I will post it once i reach my personal laptop at home.
Avatar of gudii9

ASKER

is this example working OK for you? please advise
Avatar of gudii9

ASKER

Mean time i wil try this once again on one other laptop and let you know.