[jetty-dev] Jersey on I-Jetty gives ContainerException: "No WebApplication provider is present"

Giorgio Zamparelli <[email protected]> Mon, 18 Jun 2012 13:30:55 +0200
Newsgroups gmane.comp.java.jetty.general
Message-ID <CAAWDkmSWWySttjy8xCuwBnVesWzRN0f6HH5bq=OX23SMDhoeow@mail.gmail.com>
I'm trying to run Jersey on I-Jetty for Android.

I've managed to create a WAR with all the classes and Jersey dependencies
correctly using the Maven pom file showed below.
Anyway when I start Jetty and visit a REST resource (in my case:
http://192.168.1.129:8080/myapp/api/hello) I get a ContainerException with
message: No WebApplication provider is present (see exception stack trace
below).

Any idea why?

Android LOGcat is giving a warning "WebAppDeployer is deprecated. Use
WebAppProvider".
This is because the I-Jetty example I'm using uses the deprecated
WebAppDeployer instead of the new WebAppProvider.

I'm using Jetty 7.6.0 RC4 and Jersey 1.12
THANKS A LOT FOR ANY HELP!!


*EXCEPTION:*


com.sun.jersey.api.container.ContainerException: No WebApplication
provider is present
	at com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:69)
	at com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:391)
	at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.create(ServletContainer.java:306)
	at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:605)
	at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:208)
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:373)
	at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:556)
	at javax.servlet.GenericServlet.init(GenericServlet.java:241)
	at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:444)
	at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:335)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:523)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:479)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:483)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
	at org.eclipse.jetty.server.Server.handle(Server.java:349)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:449)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:910)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:647)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:233)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:615)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
	at java.lang.Thread.run(Thread.java:1019)


*WEB.XML:*

<welcome-file-list>

		<welcome-file>index.html</welcome-file>

	</welcome-file-list>


	<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.famenu.server.resources</param-value>

		</init-param>

	</servlet>

	<servlet-mapping>

		<servlet-name>Jersey REST Service</servlet-name>

		<url-pattern>/api/*</url-pattern>

	</servlet-mapping>


*MAVEN POM.xml file:*


<dependencies>


		<!-- Jersey -->

		<dependency>

			<groupId>com.sun.jersey</groupId>

			<artifactId>jersey-core</artifactId>

			<version>1.12</version>

		</dependency>

		<dependency>

			<groupId>com.sun.jersey</groupId>

			<artifactId>jersey-json</artifactId>

			<version>1.12</version>

		</dependency>

		<dependency>

			<groupId>com.sun.jersey</groupId>

			<artifactId>jersey-server</artifactId>

			<version>1.12</version>

		</dependency>

		<dependency>

			<groupId>com.sun.jersey</groupId>

			<artifactId>jersey-servlet</artifactId>

			<version>1.12</version>

		</dependency>

		<!-- Jackson -->

		<dependency>

			<groupId>org.codehaus.jackson</groupId>

			<artifactId>jackson-core-asl</artifactId>

			<version>1.9.7</version>

		</dependency>

		<dependency>

			<groupId>org.codehaus.jackson</groupId>

			<artifactId>jackson-jaxrs</artifactId>

			<version>1.9.7</version>

		</dependency>

		<dependency>

			<groupId>org.codehaus.jackson</groupId>

			<artifactId>jackson-mapper-asl</artifactId>

			<version>1.9.7</version>

		</dependency>

		<dependency>

			<groupId>org.codehaus.jackson</groupId>

			<artifactId>jackson-xc</artifactId>

			<version>1.9.7</version>

		</dependency>


		<!-- Jersey's dependencies -->

		<dependency>

			<groupId>com.oracle</groupId>

			<artifactId>jndi</artifactId>

			<version>1.2.1</version>

		</dependency>

		<dependency>

			<groupId>asm</groupId>

			<artifactId>asm</artifactId>

			<version>3.1</version>

		</dependency>

	</dependencies>


	<build>



		<plugins>


			<plugin>

				<groupId>org.apache.maven.plugins</groupId>

				<artifactId>maven-compiler-plugin</artifactId>

				<version>2.5</version>

				<configuration>

					<source>1.6</source>

					<target>1.6</target>

				</configuration>

				<executions>

					<execution>

						<id>default-compile</id>

						<phase>compile</phase>

						<goals>

							<goal>compile</goal>

						</goals>

					</execution>

				</executions>

			</plugin>


			<plugin>

				<groupId>org.apache.maven.plugins</groupId>

				<artifactId>maven-dependency-plugin</artifactId>

				<version>2.3</version>

				<executions>

					<execution>

						<id>unpack-dependencies</id>

						<phase>generate-sources</phase>

						<goals>

							<goal>unpack-dependencies</goal>

						</goals>

						<configuration>

							<excludeArtifactIds>servlet-api,android</excludeArtifactIds>

							<excludeTransitive>true</excludeTransitive>

							<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>

							<outputDirectory>${project.build.directory}/generated-classes</outputDirectory>

						</configuration>

					</execution>

				</executions>

			</plugin>


			<!-- Using dx -->

			<plugin>

				<groupId>org.codehaus.mojo</groupId>

				<artifactId>exec-maven-plugin</artifactId>

				<version>1.2</version>

				<executions>

					<!-- Convert the compiled classes into a clases.dex. -->

					<execution>

						<id>generate-dex</id>

						<phase>process-classes</phase>

						<goals>

							<goal>exec</goal>

						</goals>

						<configuration>

							<executable>java</executable>

							<arguments>

								<argument>-jar</argument>

								<argument>${env.ANDROID_HOME}/platform-tools/lib/dx.jar</argument>

								<argument>--dex</argument>

								<argument>--verbose</argument>

								<argument>--core-library</argument>

								<argument>--output=${project.build.directory}/classes.dex</argument>

								<argument>--positions=lines</argument>

								<argument>${project.build.directory}/classes/</argument>

								<argument>${project.build.directory}/generated-classes/</argument>

							</arguments>

						</configuration>

					</execution>

				</executions>

			</plugin>


			<!-- Zipping the classes.dex file -->


			<plugin>

				<artifactId>maven-antrun-plugin</artifactId>

				<version>1.6</version>

				<executions>

					<execution>

						<id>copydex</id>

						<phase>process-classes</phase>

						<goals>

							<goal>run</goal>

						</goals>

						<configuration>

							<tasks>

								<mkdir

									dir="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib"
/>

								<jar basedir="${project.build.directory}" update="true"

									includes="classes.dex"

									destfile="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib/classes.zip"
/>

							</tasks>

						</configuration>

					</execution>

				</executions>

			</plugin>

		</plugins>

	</build>