Jersey Web Service is not working in Gatein 3.6 with JBOSS AS7
josdel Nov 28, 2013 11:52 PMHi All,
I have created a sample jersey server in my gatein 3.6 (with Jboss AS7). Here follows the steps for creating jersey server.
I have added the following lines of code in web.xml file.
<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>de.vogella.jersey.first</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
The class file is
package de.vogella.jersey.first;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
// Plain old Java Object it does not extend as class or implements
// an interface
// The class registers its methods for the HTTP GET request using the @GET annotation.
// Using the @Produces annotation, it defines that it can deliver several MIME types,
// text, XML and HTML.
// The browser requests per default the HTML MIME type.
//Sets the path to base URL + /hello
@Path("/hello")
public class Hello {
// This method is called if TEXT_PLAIN is request
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayPlainTextHello() {
return "Hello Jersey";
}
// This method is called if XML is request
@GET
@Produces(MediaType.TEXT_XML)
public String sayXMLHello() {
return "<?xml version=\"1.0\"?>" + "<hello> Hello Jersey" + "</hello>";
}
// This method is called if HTML is request
@GET
@Produces(MediaType.TEXT_HTML)
public String sayHtmlHello() {
return "<html> " + "<title>" + "Hello Jersey" + "</title>"
+ "<body><h1>" + "Hello Jersey" + "</body></h1>" + "</html> ";
}
}
But unfortunately i got an exception while starting the server
17:17:22,649 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/cisms]] (MSC service thread 1-6) StandardWrapper.Throwable: com.sun.jersey.core.spi.scanning.ScannerException: The URI scheme vfs of the URI vfs:/E:/BMITDevelopment/GateIn-3.6.0.Final-jbossas7/standalone/deployments/cisms.war/WEB-INF/classes/com/radiant/cisms/workFlow/core/ is not supported. Package scanning deployment is not supported for such URIs.
Try using a different deployment mechanism such as explicitly declaring root resource and provider classes using an extension of javax.ws.rs.core.Application
at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:225) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:139) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:78) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:116) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:81) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:92) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:677) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:655) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:206) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:342) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:516) [jersey-bundle-1.4.jar:1.4]
at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_30]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_30]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_30]
17:17:22,665 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/cisms]] (MSC service thread 1-6) Servlet /cisms threw load() exception: com.sun.jersey.core.spi.scanning.ScannerException: The URI scheme vfs of the URI vfs:/E:/BMITDevelopment/GateIn-3.6.0.Final-jbossas7/standalone/deployments/cisms.war/WEB-INF/classes/com/radiant/cisms/workFlow/core/ is not supported. Package scanning deployment is not supported for such URIs.
Try using a different deployment mechanism such as explicitly declaring root resource and provider classes using an extension of javax.ws.rs.core.Application
at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:225) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:139) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:78) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:116) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:81) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:92) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:677) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:655) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:206) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:342) [jersey-bundle-1.4.jar:1.4]
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:516) [jersey-bundle-1.4.jar:1.4]
at javax.servlet.GenericServlet.init(GenericServlet.java:242) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1102) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3655) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3873) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_30]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_30]
at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_30]