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,
Open in new window
You need to change that param-value to the package that contains the class "CtoFService". Also I think the URL to access it would be...http://localhost:8080/CrunchywebServices/crunchify/