Question

I have setup a very simple test application to try RESTeasy on Jboss AS 7.1.

Environment:

  • jboss-as-7.1.0.Final
  • eclipse 3.7 with Jboss Tools
  • maven 3

I followed the steps in the tutorial but did not get the same result. The webapp is deployed correctly and it appears in the admin console but it does not work as intended.

The server invariably tells me 404 Resource not available when I try to access http://localhost:8080/SeamSertalVision/services/test

There are 4 files in the whole project:

  • pom.xml
  • web.xml
  • RestApplication.java
  • Login.java

the pom.xml has one dependency which resolves fine:

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>ch.sertal</groupId>
    <artifactId>SertalVision</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>SertalVision</name>
    <description />

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <resteasy.version>2.3.1.GA</resteasy.version>
   </properties>

    <build>
        <sourceDirectory>${basedir}/src</sourceDirectory>
        <outputDirectory>${basedir}/build/classes</outputDirectory>
        <resources>
            <resource>
                <directory>${basedir}/src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- Include the JBoss Maven repository so we can access JBoss artifacts -->
    <repositories>
        <repository>
            <id>jboss-public-repository</id>
            <name>JBoss Repository</name>
            <url>https://repository.jboss.org/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

    </repositories>

   <pluginRepositories>
      <pluginRepository>
         <id>jboss-public-repository</id>
         <name>JBoss Repository</name>
         <url>https://repository.jboss.org/nexus/content/groups/public</url>
         <releases>
            <enabled>true</enabled>
         </releases>
         <snapshots>
            <enabled>false</enabled>
         </snapshots>
      </pluginRepository>
   </pluginRepositories>

   <dependencies>
      <dependency>
         <groupId>org.jboss.resteasy</groupId>
         <artifactId>resteasy-jaxrs</artifactId>
         <version>${resteasy.version}</version>
         <scope>provided</scope>
      </dependency>

   </dependencies>   

</project>

the web.xml is empty:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name>Sertal Vision</display-name>

</web-app>

the RestApplication.java is empty:

package ch.sertal.vision.server;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;

@ApplicationPath("/services")
public class RestApplication extends Application {
}

the Login.java contains just one method for testing:

package ch.sertal.vision.server;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Path( "/test" )
public class Login {

   @GET
   @Produces(MediaType.TEXT_HTML)
   public Response login()  {
      return Response.ok( "logged in" ).build();
   }

}

that's the whole thing, as it was described in the tutorial (I believe). The deployment works fine. If I add a welcome-file entry to the web.xml it is displayed.

here is the jboss log after teh application is deployed:

WARNING: -logmodule is deprecated. Please use the system property 'java.util.logging.manager' or the 'java.util.logging.LogManager' service loader.
11:35:17,819 INFO  [org.jboss.modules] JBoss Modules version 1.1.1.GA
11:35:18,016 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA
11:35:18,060 INFO  [org.jboss.as] JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
11:35:18,721 INFO  [org.xnio] XNIO Version 3.0.3.GA
11:35:18,722 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
11:35:18,732 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
11:35:18,743 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.2.GA
11:35:18,755 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
11:35:18,758 INFO  [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
11:35:18,770 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
11:35:18,779 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
11:35:18,780 INFO  [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
11:35:18,781 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
11:35:18,796 INFO  [org.jboss.as.security] (MSC service thread 1-10) JBAS013100: Current PicketBox version=4.0.6.final
11:35:18,803 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
11:35:18,829 INFO  [org.jboss.as.connector] (MSC service thread 1-9) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
11:35:18,856 INFO  [org.jboss.as.naming] (MSC service thread 1-11) JBAS011802: Starting Naming Service
11:35:18,861 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-12) JBAS015400: Bound mail session [java:jboss/mail/Default]
11:35:18,911 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
11:35:18,937 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-4) JBoss Web Services - Stack CXF Server 4.0.1.GA
11:35:19,014 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-2) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
11:35:19,288 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-13) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
11:35:19,556 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-8) JBAS015012: Started FileSystemDeploymentService for directory /Development/jboss-as-7.1.0.Final/standalone/deployments
11:35:19,561 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found SeamSertalVision.war in deployment directory. To trigger deployment create a file called SeamSertalVision.war.dodeploy
11:35:19,574 INFO  [org.jboss.as.remoting] (MSC service thread 1-5) JBAS017100: Listening on /127.0.0.1:9999
11:35:19,574 INFO  [org.jboss.as.remoting] (MSC service thread 1-11) JBAS017100: Listening on /127.0.0.1:4447
11:35:19,664 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.0.Final "Thunder" started in 2145ms - Started 134 of 205 services (70 services are passive or on-demand)
11:35:19,676 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-14) JBAS015876: Starting deployment of "SeamSertalVision.war"
11:35:20,028 INFO  [org.jboss.web] (MSC service thread 1-13) JBAS018210: Registering web context: /SeamSertalVision
11:35:20,066 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "SeamSertalVision.war"

My question is: how can I verify that my Webservice is being registered? There is no hint to his in the log but no error either. There must be something wrong but I can't see what it is.

I have an application on Tomcat with Jersey and there the log clearly shows which classes perform RESTful services.

thank you for your help.

Was it helpful?

Solution

You will not see if the REST service is registered during startup because the service only starts on-demand, then you will see something like this:

INFO  [org.jboss.resteasy.cdi.CdiInjectorFactory] (http--127.0.0.1-8080-1)
      Found BeanManager at java:comp/BeanManager
INFO  [org.jboss.resteasy.spi.ResteasyDeployment] (http--127.0.0.1-8080-1)
      Deploying javax.ws.rs.core.Application:
      class my.rest.JaxRsActivator$Proxy$_$$_WeldClientProxy

I don't see a significant error in your configuration, but it's possible that you are missing a WEB-INF/beans.xml?

To get a working example of a JBoss7 with a REST service you can create a new project using the following archetype: org.jboss.spec.archetypes:jboss-javaee6-ear-webapp:7.0.2.CR2 (you have to change the version of all JBoss dependencies from 7.0.2.CR2 to 7.1.0.Final).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top