gudii9
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\workingSe ssion_mkyo ng\jesey\R ESTfulExam ple
Then i imported as maven project.
Then i did Maven Clean then Maven Instal. I got error as attached.
please advise
jerseyEx.docx
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\workingSe
Then i imported as maven project.
Then i did Maven Clean then Maven Instal. I got error as attached.
please advise
jerseyEx.docx
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();
}
}
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
ASKER
when i go to below url
http://localhost:8080/RESTfulExample/rest/hello/john
i got below error
please advise
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
please advise
ASKER
when i go to below url
http://localhost:8080/RESTfulExample/rest/hello/mkyong
i still get same error
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.Au thenticato rBase.invo ke(Authent icatorBase .java:502)
org.apache.catalina.valves.ErrorRepo rtValve.in voke(Error ReportValv e.java:79)
org.apache.catalina.valves.AbstractA ccessLogVa lve.invoke (AbstractA ccessLogVa lve.java:6 17)
org.apache.catalina.connector.Coyote Adapter.se rvice(Coyo teAdapter. java:518)
org.apache.coyote.http11.AbstractHtt p11Process or.process (AbstractH ttp11Proce ssor.java: 1091)
org.apache.coyote.AbstractProtocol$A bstractCon nectionHan dler.proce ss(Abstrac tProtocol. java:668)
org.apache.tomcat.util.net.NioEndpoi nt$SocketP rocessor.d oRun(NioEn dpoint.jav a:1527)
org.apache.tomcat.util.net.NioEndpoi nt$SocketP rocessor.r un(NioEndp oint.java: 1484)
java.util.concurrent.ThreadPoolExecu tor.runWor ker(Unknow n Source)
java.util.concurrent.ThreadPoolExecu tor$Worker .run(Unkno wn Source)
org.apache.tomcat.util.threads.TaskT hread$Wrap pingRunnab le.run(Tas kThread.ja va:61)
java.lang.Thread.run(Unknown Source)
root cause
com.sun.jersey.api.container.Contain erExceptio n: The ResourceConfig instance does not contain any root resource classes.
com.sun.jersey.server.impl.applicati on.RootRes ourceUriRu les.<init> (RootResou rceUriRule s.java:99)
com.sun.jersey.server.impl.applicati on.WebAppl icationImp l._initiat e(WebAppli cationImpl .java:1298 )
com.sun.jersey.server.impl.applicati on.WebAppl icationImp l.access$7 00(WebAppl icationImp l.java:169 )
com.sun.jersey.server.impl.applicati on.WebAppl icationImp l$13.f(Web Applicatio nImpl.java :775)
com.sun.jersey.server.impl.applicati on.WebAppl icationImp l$13.f(Web Applicatio nImpl.java :771)
com.sun.jersey.spi.inject.Errors.pro cessWithEr rors(Error s.java:193 )
com.sun.jersey.server.impl.applicati on.WebAppl icationImp l.initiate (WebApplic ationImpl. java:771)
com.sun.jersey.server.impl.applicati on.WebAppl icationImp l.initiate (WebApplic ationImpl. java:766)
com.sun.jersey.spi.container.servlet .ServletCo ntainer.in itiate(Ser vletContai ner.java:4 88)
com.sun.jersey.spi.container.servlet .ServletCo ntainer$In ternalWebC omponent.i nitiate(Se rvletConta iner.java: 318)
com.sun.jersey.spi.container.servlet .WebCompon ent.load(W ebComponen t.java:609 )
com.sun.jersey.spi.container.servlet .WebCompon ent.init(W ebComponen t.java:210 )
com.sun.jersey.spi.container.servlet .ServletCo ntainer.in it(Servlet Container. java:373)
com.sun.jersey.spi.container.servlet .ServletCo ntainer.in it(Servlet Container. java:556)
javax.servlet.GenericServlet.init(Ge nericServl et.java:15 8)
org.apache.catalina.authenticator.Au thenticato rBase.invo ke(Authent icatorBase .java:502)
org.apache.catalina.valves.ErrorRepo rtValve.in voke(Error ReportValv e.java:79)
org.apache.catalina.valves.AbstractA ccessLogVa lve.invoke (AbstractA ccessLogVa lve.java:6 17)
org.apache.catalina.connector.Coyote Adapter.se rvice(Coyo teAdapter. java:518)
org.apache.coyote.http11.AbstractHtt p11Process or.process (AbstractH ttp11Proce ssor.java: 1091)
org.apache.coyote.AbstractProtocol$A bstractCon nectionHan dler.proce ss(Abstrac tProtocol. java:668)
org.apache.tomcat.util.net.NioEndpoi nt$SocketP rocessor.d oRun(NioEn dpoint.jav a:1527)
org.apache.tomcat.util.net.NioEndpoi nt$SocketP rocessor.r un(NioEndp oint.java: 1484)
java.util.concurrent.ThreadPoolExecu tor.runWor ker(Unknow n Source)
java.util.concurrent.ThreadPoolExecu tor$Worker .run(Unkno wn Source)
org.apache.tomcat.util.threads.TaskT hread$Wrap pingRunnab le.run(Tas kThread.ja va: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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
http://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/
I will post it once i reach my personal laptop at home.
ASKER
is this example working OK for you? please advise
ASKER
Mean time i wil try this once again on one other laptop and let you know.
ASKER
its working by adding @Produces
I need to see if that helps solving this issue