Question

J'ai configuré une application de test très simple pour essayer de reposer sur JBOSS comme 7.1.

Environnement:

  • jboss-as-7.1.0.Final
  • Eclipse 3.7 avec des outils JBoss
  • maven 3

J'ai suivi les étapes du tutoriel mais je n'ai pas obtenu le même résultat. Le WebApp est déployé correctement et il apparaît dans la console d'administration, mais il ne fonctionne pas comme prévu.

Le serveur me dit invariablement la ressource 404 non disponible lorsque j'essaie d'accéder http://localhost:8080/SeamSertalVision/services/test

Il y a 4 fichiers dans tout le projet:

  • pom.xml
  • web.xml
  • Restapplication.java
  • Login.java

Le pom.xml a une dépendance qui résout bien:

<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>

le web.xml est vide:

<?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>

le restapplication.java est vide:

package ch.sertal.vision.server;

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

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

Le login.java ne contient qu'une seule méthode pour tester:

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();
   }

}

C'est le tout, comme il a été décrit dans le tutoriel (je crois). Le déploiement fonctionne bien. Si j'ajoute un welcome-file Entrée sur web.xml Il s'affiche.

Voici le journal JBoss après le déployé de l'application:

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"

Ma question est: comment puis-je vérifier que mon service Web est enregistré? Il n'y a aucun indice dans le sien dans le journal mais aucune erreur non plus. Il doit y avoir quelque chose qui ne va pas mais je ne vois pas ce que c'est.

J'ai une application sur Tomcat avec Jersey et le journal montre clairement quelles classes effectuent des services RESTful.

Merci pour votre aide.

Était-ce utile?

La solution

Vous ne verrez pas si le service de repos est enregistré pendant le démarrage car le service ne commence qu'à la demande, alors vous verrez quelque chose comme ceci:

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

Je ne vois pas d'erreur significative dans votre configuration, mais il est possible que vous manquiez un WEB-INF/beans.xml?

Pour obtenir un exemple de travail d'un JBoss7 avec un service de repos, vous pouvez créer un nouveau projet en utilisant l'archétype suivant: org.jboss.spec.archetypes:jboss-javaee6-ear-webapp:7.0.2.CR2(Vous devez modifier la version de toutes les dépendances JBoss de 7.0.2.CR2 à 7.1.0.Final).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top