Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » SeMantic Information Logistics Architecture (SMILA) » com.sun.jersey.api.container.ContainerException(The ResourceConfig instance does not contain any root resource classes. )
com.sun.jersey.api.container.ContainerException [message #633204] Fri, 15 October 2010 16:08 Go to next message
Andrej Rosenheinrich is currently offline Andrej RosenheinrichFriend
Messages: 22
Registered: August 2010
Junior Member
i am trying to make jax-rs working in SMILKA via jersey.
after several attempts i got at least the
com.sun.jersey.spi.container.servlet.ServletContainer loaded.

but on ever startup, tomcat/SMILA fails with the message

"com.sun.jersey.api.container.ContainerException: The ResourceConfig
instance does not contain any root resource classes."

after all, it boils down, to the
com.sun.jersey.spi.container.servlet.ServletContainer's classloader being
unable to find classes/packages exposed from bundles.

jersey offers several "resourceConfigClasses" looking up classes via
either classpath (looks in
SMILA.application/configuration/org.eclipse.smila.tomcat/web apps/SMILA/WEB-INF/lib
and
SMILA.application/configuration/org.eclipse.smila.tomcat/web apps/SMILA/WEB-INF/classes),
class name (fails with CNF), packages (same thing), ...

none of these is available to load classes exposed by my bundle.

simple question: what else do i have to do?

a quick solution would probably be, to deploy indeed to
SMILA.application/configuration/org.eclipse.smila.tomcat/web apps/SMILA/WEB-INF/[classes|lib]
-- but how?

below a stack trace

SEVERE: Servlet /SMILA threw load() exception
java.lang.ClassNotFoundException: foo.bar.restlookup.RestTest
at
org.apache.catalina.loader.WebappClassLoader.loadClass(Webap pClassLoader.java:1387)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(Webap pClassLoader.java:1233)
at
com.sun.jersey.api.core.ClassNamesResourceConfig.convertToSe t(ClassNamesResourceConfig.java:118)
at
com.sun.jersey.api.core.ClassNamesResourceConfig.getClasses( ClassNamesResourceConfig.java:107)
at
com.sun.jersey.api.core.ClassNamesResourceConfig.getClasses( ClassNamesResourceConfig.java:99)
at
com.sun.jersey.api.core.ClassNamesResourceConfig.<init>(ClassNamesResourceConfig.java:90)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Nativ e Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(Native ConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(De legatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:5 13)
at
com.sun.jersey.spi.container.servlet.WebComponent.createReso urceConfig(WebComponent.java:705)
at
com.sun.jersey.spi.container.servlet.WebComponent.createReso urceConfig(WebComponent.java:655)
at
com.sun.jersey.spi.container.servlet.WebComponent.init(WebCo mponent.java:206)
at
com.sun.jersey.spi.container.servlet.ServletContainer.init(S ervletContainer.java:342)
at
com.sun.jersey.spi.container.servlet.ServletContainer.init(S ervletContainer.java:516)
at javax.servlet.GenericServlet.init(GenericServlet.java:241)
at
org.apache.catalina.core.StandardWrapper.loadServlet(Standar dWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.load(StandardWrappe r.java:992)
at
org.apache.catalina.core.StandardContext.loadOnStartup(Stand ardContext.java:4058)
at
org.apache.catalina.core.StandardContext.start(StandardConte xt.java:4371)
at
org.apache.catalina.core.ContainerBase.addChildInternal(Cont ainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBas e.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost. java:525)
at
org.apache.catalina.startup.HostConfig.deployDirectory(HostC onfig.java:926)
at
org.apache.catalina.startup.HostConfig.deployDirectories(Hos tConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig .java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java :1149)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostCo nfig.java:311)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent (LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.j ava:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.jav a:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.j ava:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine .java:443)
at
org.apache.catalina.core.StandardService.start(StandardServi ce.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer .java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578 )
at
org.eclipse.smila.tomcat.starter.TomcatServiceImpl.start(Tom catServiceImpl.java:106)
at
org.eclipse.smila.tomcat.starter.TomcatServiceImpl.activate( TomcatServiceImpl.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.eclipse.equinox.internal.ds.model.ServiceComponent.activ ate(ServiceComponent.java:234)
at
org.eclipse.equinox.internal.ds.model.ServiceComponentProp.a ctivate(ServiceComponentProp.java:139)
at
org.eclipse.equinox.internal.ds.model.ServiceComponentProp.b uild(ServiceComponentProp.java:339)
at
org.eclipse.equinox.internal.ds.InstanceProcess.buildCompone nt(InstanceProcess.java:588)
at
org.eclipse.equinox.internal.ds.InstanceProcess.buildCompone nts(InstanceProcess.java:196)
at
org.eclipse.equinox.internal.ds.Resolver.buildNewlySatisfied (Resolver.java:441)
at
org.eclipse.equinox.internal.ds.Resolver.enableComponents(Re solver.java:213)
at
org.eclipse.equinox.internal.ds.SCRManager.performWork(SCRMa nager.java:800)
at
org.eclipse.equinox.internal.ds.SCRManager$QueuedJob.dispatc h(SCRManager.java:767)
at org.eclipse.equinox.internal.ds.WorkThread.run(WorkThread.ja va:89)
at
org.eclipse.equinox.internal.util.impl.tpt.threadpool.Execut or.run(Executor.java:70)


.. the servlet configuration from web.xml:

<servlet>
<servlet-name>rest</servlet-name>

<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer </servlet-class>
<init-param>

<param-name>com.sun.jersey.config.property.resourceConfigClass </param-name>

<param-value>com.sun.jersey.api.core.ClassnamesResourceConfig </param-value><!--
one of several possible resource configs ... -->
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.classnames</param-name ><!--
and some params for the chosen resource config -->
<param-value>foo.bar.restlookup.RestTest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

... the MANIFEST.MF


Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Restlookup
Bundle-SymbolicName: foo.bar.restlookup;singleton:=true
Bundle-Version: 0.0.1
Bundle-Activator: foo.bar.restlookup.Activator
Bundle-Vendor: UNISTER
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0"
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: lib/asm-3.1.jar,
lib/jersey-bundle-1.4.jar,
lib/jsr311-api-1.1.1.jar
Export-Package: com.sun.jersey.api,
com.sun.jersey.api.client,
com.sun.jersey.api.client.async,
com.sun.jersey.api.client.config,
com.sun.jersey.api.client.filter,
com.sun.jersey.api.container,
com.sun.jersey.api.container.filter,
com.sun.jersey.api.container.grizzly,
com.sun.jersey.api.container.httpserver,
com.sun.jersey.api.core,
com.sun.jersey.api.json,
com.sun.jersey.api.model,
com.sun.jersey.api.representation,
com.sun.jersey.api.uri,
com.sun.jersey.api.view,
com.sun.jersey.api.wadl,
com.sun.jersey.api.wadl.config,
com.sun.jersey.atom.rome.impl,
com.sun.jersey.atom.rome.impl.provider.entity,
com.sun.jersey.client.impl,
com.sun.jersey.client.impl.async,
com.sun.jersey.client.osgi,
com.sun.jersey.client.proxy,
com.sun.jersey.client.urlconnection,
com.sun.jersey.core.header,
com.sun.jersey.core.header.reader,
com.sun.jersey.core.impl.provider.entity,
com.sun.jersey.core.impl.provider.header,
com.sun.jersey.core.impl.provider.xml,
com.sun.jersey.core.osgi,
com.sun.jersey.core.provider,
com.sun.jersey.core.provider.jaxb,
com.sun.jersey.core.reflection,
com.sun.jersey.core.spi.component,
com.sun.jersey.core.spi.component.ioc,
com.sun.jersey.core.spi.factory,
com.sun.jersey.core.spi.scanning,
com.sun.jersey.core.spi.scanning.uri,
com.sun.jersey.core.util,
com.sun.jersey.fastinfoset.impl.provider.entity,
com.sun.jersey.impl,
com.sun.jersey.json.impl,
com.sun.jersey.json.impl.provider.entity,
com.sun.jersey.json.impl.reader,
com.sun.jersey.json.impl.writer,
com.sun.jersey.localization,
com.sun.jersey.server.impl,
com.sun.jersey.server.impl.application,
com.sun.jersey.server.impl.cdi,
com.sun.jersey.server.impl.component,
com.sun.jersey.server.impl.container,
com.sun.jersey.server.impl.container.filter,
com.sun.jersey.server.impl.container.grizzly,
com.sun.jersey.server.impl.container.httpserver,
com.sun.jersey.server.impl.container.servlet,
com.sun.jersey.server.impl.ejb,
com.sun.jersey.server.impl.inject,
com.sun.jersey.server.impl.managedbeans,
com.sun.jersey.server.impl.model,
com.sun.jersey.server.impl.model.method,
com.sun.jersey.server.impl.model.method.dispatch,
com.sun.jersey.server.impl.model.parameter,
com.sun.jersey.server.impl.model.parameter.multivalued,
com.sun.jersey.server.impl.modelapi.annotation,
com.sun.jersey.server.impl.modelapi.validation,
com.sun.jersey.server.impl.monitoring,
com.sun.jersey.server.impl.provider,
com.sun.jersey.server.impl.resource,
com.sun.jersey.server.impl.template,
com.sun.jersey.server.impl.uri,
com.sun.jersey.server.impl.uri.rules,
com.sun.jersey.server.impl.uri.rules.automata,
com.sun.jersey.server.impl.wadl,
com.sun.jersey.server.osgi,
com.sun.jersey.server.probes,
com.sun.jersey.server.spi.component,
com.sun.jersey.server.wadl,
com.sun.jersey.server.wadl.generators,
com.sun.jersey.server.wadl.generators.resourcedoc,
com.sun.jersey.server.wadl.generators.resourcedoc.model,
com.sun.jersey.server.wadl.generators.resourcedoc.xhtml,
com.sun.jersey.spi,
com.sun.jersey.spi.container,
com.sun.jersey.spi.container.servlet,
com.sun.jersey.spi.dispatch,
com.sun.jersey.spi.inject,
com.sun.jersey.spi.monitoring,
com.sun.jersey.spi.resource,
com.sun.jersey.spi.scanning,
com.sun.jersey.spi.service,
com.sun.jersey.spi.template,
com.sun.jersey.spi.uri.rules,
com.sun.research.ws.wadl,
com.sun.ws.rs.ext,
foo.bar.restlookup,
javax.ws.rs,
javax.ws.rs.core,
javax.ws.rs.ext,
org.objectweb.asm,
org.objectweb.asm.signature
Eclipse-RegisterBuddy: org.apache.tomcat, org.eclipse.smila.tomcat
Require-Bundle: org.eclipse.smila.tomcat;bundle-version="0.7.0"
Re: com.sun.jersey.api.container.ContainerException [message #644829 is a reply to message #633204] Tue, 14 December 2010 11:29 Go to previous messageGo to next message
Martin Röbert is currently offline Martin RöbertFriend
Messages: 16
Registered: December 2010
Location: Leipzig, Germany
Junior Member
This is actually not a SMILA problem. The solution would be: Deploying the servlets as a war file into the embedded tomcat. The WEB-INF/web.xml should contain the following content:

<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>com.yourpackage.somewhat</param-value>
	</init-param>
	<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
	<servlet-name>Jersey REST Service</servlet-name>
	<url-pattern>/*</url-pattern>
</servlet-mapping>


where the package com.yourpackage.somewhat points to the classes which are the Jersey resources, eg:

@Path("/foo")
public class Fool {
	@GET
	@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
	@Path("{aParam}")
	public List<Object> getFoo(@PathParam("aParam") final String param) {
		return List<Object>;
	}
}


this works fine for me.


Regards,

Martin
Re: com.sun.jersey.api.container.ContainerException [message #1040158 is a reply to message #644829] Sat, 13 April 2013 05:21 Go to previous message
Sega Diop is currently offline Sega DiopFriend
Messages: 1
Registered: April 2013
Junior Member
Thanx a lot ..... u save me Smile
Previous Topic:1.2-M1 available
Next Topic:SMILA 1.2 released
Goto Forum:
  


Current Time: Thu Apr 25 00:31:37 GMT 2024

Powered by FUDForum. Page generated in 0.02955 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top