roy_sanu
asked on
JAX-RS and Jersey web services application error
Hello,
I am using jersey jars
: asm-3.3.1.jar, jersey-bundle-1.14.jar, json.jar, jersey-simple-server-1.8.j ar,
Is it i have to use some jars ?
I have added my web-inf/lib folder and to my classpath
when i run the restful web services url
http://localhost:8080/CrunchywebServices/crunchify/ctofservice/
getting an error as
HTTP Status 500 - Servlet.init() for servlet Jersey Web Application threw exception
type Exception report
message Servlet.init() for servlet Jersey Web Application threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletExcep tion: Servlet.init() for servlet Jersey Web Application threw exception
org.apache.catalina.authen ticator.Au thenticato rBase.invo ke(Authent icatorBase .java:472)
org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:99)
org.apache.catalina.valves .AccessLog Valve.invo ke(AccessL ogValve.ja va:953)
org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:408)
org.apache.coyote.http11.A bstractHtt p11Process or.process (AbstractH ttp11Proce ssor.java: 1008)
org.apache.coyote.Abstract Protocol$A bstractCon nectionHan dler.proce ss(Abstrac tProtocol. java:589)
org.apache.tomcat.util.net .JIoEndpoi nt$SocketP rocessor.r un(JIoEndp oint.java: 310)
java.util.concurrent.Threa dPoolExecu tor.runWor ker(Unknow n Source)
java.util.concurrent.Threa dPoolExecu tor$Worker .run(Unkno wn Source)
java.lang.Thread.run(Unkno wn Source)
root cause
com.sun.jersey.api.contain er.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:1300 )
com.sun.jersey.server.impl .applicati on.WebAppl icationImp l.access$7 00(WebAppl icationImp l.java:163 )
com.sun.jersey.server.impl .applicati on.WebAppl icationImp l$13.f(Web Applicatio nImpl.java :769)
com.sun.jersey.server.impl .applicati on.WebAppl icationImp l$13.f(Web Applicatio nImpl.java :765)
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:765)
com.sun.jersey.server.impl .applicati on.WebAppl icationImp l.initiate (WebApplic ationImpl. java:760)
com.sun.jersey.spi.contain er.servlet .ServletCo ntainer.in itiate(Ser vletContai ner.java:4 89)
com.sun.jersey.spi.contain er.servlet .ServletCo ntainer$In ternalWebC omponent.i nitiate(Se rvletConta iner.java: 319)
com.sun.jersey.spi.contain er.servlet .WebCompon ent.load(W ebComponen t.java:609 )
com.sun.jersey.spi.contain er.servlet .WebCompon ent.init(W ebComponen t.java:210 )
com.sun.jersey.spi.contain er.servlet .ServletCo ntainer.in it(Servlet Container. java:374)
com.sun.jersey.spi.contain er.servlet .ServletCo ntainer.in it(Servlet Container. java:557)
javax.servlet.GenericServl et.init(Ge nericServl et.java:16 0)
org.apache.catalina.authen ticator.Au thenticato rBase.invo ke(Authent icatorBase .java:472)
org.apache.catalina.valves .ErrorRepo rtValve.in voke(Error ReportValv e.java:99)
org.apache.catalina.valves .AccessLog Valve.invo ke(AccessL ogValve.ja va:953)
org.apache.catalina.connec tor.Coyote Adapter.se rvice(Coyo teAdapter. java:408)
org.apache.coyote.http11.A bstractHtt p11Process or.process (AbstractH ttp11Proce ssor.java: 1008)
org.apache.coyote.Abstract Protocol$A bstractCon nectionHan dler.proce ss(Abstrac tProtocol. java:589)
org.apache.tomcat.util.net .JIoEndpoi nt$SocketP rocessor.r un(JIoEndp oint.java: 310)
java.util.concurrent.Threa dPoolExecu tor.runWor ker(Unknow n Source)
java.util.concurrent.Threa dPoolExecu tor$Worker .run(Unkno wn Source)
java.lang.Thread.run(Unkno wn Source)
My web.xml
========================== ========== ========== ========== =======
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jer sey.spi.co ntainer.se rvlet.Serv letContain er</servle t-class>
<load-on-startup>1</load-o n-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/crunchify/*< /url-patte rn>
</servlet-mapping>
========================== ========== ========== ========== ========== =====
One of the class is
public class CtoFService {
@GET
@Produces("application/xml ")
public String convertCtoF() {
Double fahrenheit;
Double celsius = 36.8;
fahrenheit = ((celsius * 9) / 5) + 32;
String result = "@Produces(\"application/x ml\") Output: \n\nC to F Converter Output: \n\n" + fahrenheit;
return "<ctofservice>" + "<celsius>" + celsius + "</celsius>" + "<ctofoutput>" + result + "</ctofoutput>" + "</ctofservice>";
}
@Path("{c}")
@GET
@Produces("application/xml ")
public String convertCtoFfromInput(@Path Param("c") Double c) {
Double fahrenheit;
Double celsius = c;
fahrenheit = ((celsius * 9) / 5) + 32;
String result = "@Produces(\"application/x ml\") Output: \n\nC to F Converter Output: \n\n" + fahrenheit;
return "<ctofservice>" + "<celsius>" + celsius + "</celsius>" + "<ctofoutput>" + result + "</ctofoutput>" + "</ctofservice>";
}
}
Thanks,
I am using jersey jars
: asm-3.3.1.jar, jersey-bundle-1.14.jar, json.jar, jersey-simple-server-1.8.j
Is it i have to use some jars ?
I have added my web-inf/lib folder and to my classpath
when i run the restful web services url
http://localhost:8080/CrunchywebServices/crunchify/ctofservice/
getting an error as
HTTP Status 500 - Servlet.init() for servlet Jersey Web Application threw exception
type Exception report
message Servlet.init() for servlet Jersey Web Application threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletExcep
org.apache.catalina.authen
org.apache.catalina.valves
org.apache.catalina.valves
org.apache.catalina.connec
org.apache.coyote.http11.A
org.apache.coyote.Abstract
org.apache.tomcat.util.net
java.util.concurrent.Threa
java.util.concurrent.Threa
java.lang.Thread.run(Unkno
root cause
com.sun.jersey.api.contain
com.sun.jersey.server.impl
com.sun.jersey.server.impl
com.sun.jersey.server.impl
com.sun.jersey.server.impl
com.sun.jersey.server.impl
com.sun.jersey.spi.inject.
com.sun.jersey.server.impl
com.sun.jersey.server.impl
com.sun.jersey.spi.contain
com.sun.jersey.spi.contain
com.sun.jersey.spi.contain
com.sun.jersey.spi.contain
com.sun.jersey.spi.contain
com.sun.jersey.spi.contain
javax.servlet.GenericServl
org.apache.catalina.authen
org.apache.catalina.valves
org.apache.catalina.valves
org.apache.catalina.connec
org.apache.coyote.http11.A
org.apache.coyote.Abstract
org.apache.tomcat.util.net
java.util.concurrent.Threa
java.util.concurrent.Threa
java.lang.Thread.run(Unkno
My web.xml
==========================
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jer
<load-on-startup>1</load-o
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/crunchify/*<
</servlet-mapping>
==========================
One of the class is
public class CtoFService {
@GET
@Produces("application/xml
public String convertCtoF() {
Double fahrenheit;
Double celsius = 36.8;
fahrenheit = ((celsius * 9) / 5) + 32;
String result = "@Produces(\"application/x
return "<ctofservice>" + "<celsius>" + celsius + "</celsius>" + "<ctofoutput>" + result + "</ctofoutput>" + "</ctofservice>";
}
@Path("{c}")
@GET
@Produces("application/xml
public String convertCtoFfromInput(@Path
Double fahrenheit;
Double celsius = c;
fahrenheit = ((celsius * 9) / 5) + 32;
String result = "@Produces(\"application/x
return "<ctofservice>" + "<celsius>" + celsius + "</celsius>" + "<ctofoutput>" + result + "</ctofoutput>" + "</ctofservice>";
}
}
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
There was an issue with the jars. i added some more right jars ...well i was guessing on that. it is working fine now..
thanks
thanks
ASKER
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jer
<init-param>
<param-name>com.sun.jersey
<param-value>com.crunchify
</init-param>
<load-on-startup>1</load-o
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/crunchify/*<
</servlet-mapping>
</web-app>
still the wired error comes
========================
SEVERE: StandardWrapper.Throwable
com.sun.jersey.api.contain
at com.sun.jersey.server.impl
at com.sun.jersey.server.impl
at com.sun.jersey.server.impl
at com.sun.jersey.server.impl
at com.sun.jersey.server.impl
at com.sun.jersey.spi.inject.
at com.sun.jersey.server.impl
at com.sun.jersey.server.impl
at com.sun.jersey.spi.contain
at com.sun.jersey.spi.contain
at com.sun.jersey.spi.contain
at com.sun.jersey.spi.contain
at com.sun.jersey.spi.contain
at com.sun.jersey.spi.contain
at javax.servlet.GenericServl
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.util.L
at org.apache.catalina.core.C
at org.apache.catalina.core.C
at java.util.concurrent.Futur
at java.util.concurrent.Futur
at java.util.concurrent.Threa
at java.util.concurrent.Threa
at java.lang.Thread.run(Unkno
=========================