users@jersey.java.net

Re: [Jersey] Questoin about Jersey integration with Jetty + Eclipse using maven

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 23 Sep 2009 17:22:26 +0200

Hi Roan,

 From the console Jersey is not finding any root resource classes in
the package "com.citespace".

Is the class UsuarioResource annotated with a @Path?

If not, then it needs to be so.

If yes, then i am guessing the Jersey's package scanning algorithm is
not working correctly when using Jetty on Eclipse, but as Jakub shows
is works OK when using "mvn jetty:war-run".

As a work around you could try using:

         <init-param>
             <param-
name>com.sun.jersey.config.property.resourceConfigClass</param-name>
             <param-
value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
         </init-param>
         <init-param>
             <param-name>com.sun.jersey.config.property.classnames</
param-name>
             <param-value>com.citespace.UsuarioResource</param-value>
         </init-param>

Paul.


On Sep 15, 2009, at 9:24 PM, Roan Brasil Monteiro wrote:

>
> Hello Everyone,
>
> I just started a Maven Project archetype webapp using Jersey + Jetty
> on Eclipse. Well I am getting an error that I cannot solve. I would
> like to have some help of someone here that already had this issue.
> Let's start with my pom.xml
>
> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance
> "
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd
> ">
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.citespace</groupId>
> <artifactId>citespace</artifactId>
> <packaging>war</packaging>
> <version>0.0.1-SNAPSHOT</version>
> <name>citespace Maven Webapp</name>
> <url>http://maven.apache.org</url>
> <dependencies>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>3.8.1</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-server</artifactId>
> <version>1.1.3-ea-SNAPSHOT</version>
> </dependency>
> <dependency>
> <groupId>maven</groupId>
> <artifactId>maven-jetty-plugin</artifactId>
> <version>1.1</version>
> </dependency>
> <dependency>
> <groupId>org.mortbay.jetty</groupId>
> <artifactId>jetty</artifactId>
> <version>6.1.20</version>
> </dependency>
> </dependencies>
> <build>
> <finalName>citespace</finalName>
> </build>
> </project>
>
>
> After that I have my web.xml
>
> <!DOCTYPE web-app PUBLIC
> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd" >
>
> <web-app>
> <display-name>Archetype Created Web Application</display-name>
> <servlet>
> <servlet-name>Jersey Web Application</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.citespace</param-value>
> </init-param>
> <load-on-startup>1</load-on-startup>
> </servlet>
> <servlet-mapping>
> <servlet-name>Jersey Web Application</servlet-name>
> <url-pattern>/*</url-pattern>
> </servlet-mapping>
>
> </web-app>
>
>
> and the print screen of my project and the error I am getting.
>
> [INFO] Starting jetty 6.1.20 ...
> 2009-09-15 16:12:03.005::INFO: jetty-6.1.20
> 2009-09-15 16:12:03.194::INFO: No Transaction manager found - if
> your webapp requires one, please configure one.
> 2009-09-15 16:12:03.487:/citespace:WARN: unavailable
> java.lang.IllegalArgumentException:
> com.sun.jersey.config.property.packages contains no packages
> at
> com
> .sun
> .jersey
> .api
> .core.PackagesResourceConfig.getPackages(PackagesResourceConfig.java:
> 145)
> at
> com
> .sun
> .jersey
> .api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:
> 89)
> at
> com
> .sun
> .jersey
> .spi
> .container
> .servlet.WebComponent.createResourceConfig(WebComponent.java:571)
> at
> com
> .sun
> .jersey
> .spi
> .container
> .servlet.WebComponent.createResourceConfig(WebComponent.java:549)
> at
> com
> .sun
> .jersey.spi.container.servlet.WebComponent.init(WebComponent.java:194)
> at
> com
> .sun
> .jersey
> .spi.container.servlet.ServletContainer.init(ServletContainer.java:
> 308)
> at
> com
> .sun
> .jersey
> .spi.container.servlet.ServletContainer.init(ServletContainer.java:
> 471)
> at javax.servlet.GenericServlet.init(GenericServlet.java:241)
> at
> org
> .mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:
> 431)
> at
> org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:
> 263)
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> 50)
> at
> org
> .mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:
> 681)
> at org.mortbay.jetty.servlet.Context.startContext(Context.java:
> 140)
> at
> org
> .mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:
> 1250)
> at
> org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:
> 517)
> at
> org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
> at
> org
> .mortbay
> .jetty
> .plugin
> .Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:124)
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> 50)
> at
> org
> .mortbay
> .jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
> at
> org
> .mortbay
> .jetty
> .handler
> .ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> 50)
> at
> org
> .mortbay
> .jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> 50)
> at
> org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:
> 130)
> at org.mortbay.jetty.Server.doStart(Server.java:224)
> at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:
> 50)
> at
> org
> .mortbay
> .jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
> at
> org
> .mortbay
> .jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
> at
> org
> .mortbay
> .jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
> at
> org
> .mortbay
> .jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:
> 210)
> at
> org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
> at
> org
> .apache
> .maven
> .plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:
> 579)
> at
> org
> .apache
> .maven
> .lifecycle
> .DefaultLifecycleExecutor
> .executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:498)
> at
> org
> .apache
> .maven
> .lifecycle
> .DefaultLifecycleExecutor
> .executeTaskSegmentForProject(DefaultLifecycleExecutor.java:265)
> at
> org
> .apache
> .maven
> .lifecycle
> .DefaultLifecycleExecutor
> .executeTaskSegments(DefaultLifecycleExecutor.java:191)
> at
> org
> .apache
> .maven
> .lifecycle
> .DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:149)
> at
> org.apache.maven.DefaultMaven.execute_aroundBody0(DefaultMaven.java:
> 223)
> at
> org
> .apache
> .maven.DefaultMaven.execute_aroundBody1$advice(DefaultMaven.java:304)
> at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:1)
> at
> org
> .apache
> .maven.embedder.MavenEmbedder.execute_aroundBody2(MavenEmbedder.java:
> 904)
> at
> org
> .apache
> .maven
> .embedder
> .MavenEmbedder.execute_aroundBody3$advice(MavenEmbedder.java:304)
> at
> org.apache.maven.embedder.MavenEmbedder.execute(MavenEmbedder.java:1)
> at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:176)
> at org.apache.maven.cli.MavenCli.main(MavenCli.java:63)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun
> .reflect
> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun
> .reflect
> .DelegatingMethodAccessorImpl
> .invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org
> .codehaus
> .plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:
> 289)
> at
> org
> .codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:
> 229)
> at
> org
> .codehaus
> .plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:
> 408)
> at
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
> 351)
> at org.codehaus.classworlds.Launcher.main(Launcher.java:31)
> 2009-09-15 16:12:03.511::INFO: Started
> SelectChannelConnector_at_0.0.0.0:8080
> [INFO] Started Jetty Server
> --
> Atenciosamente,
>
> Roan Brasil Monteiro
> http://roanbrasil.wordpress.com/
> <
> Screenshot
> .png
> >---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net