0

I'm deploying my app on a Wildfly server, but for some reason I can't see the persistence units deployed. I can't even access my REST services using the URI.

EDIT
Since the app is still in development stages, I deploy it using eclipse + maven as dependency management system. In order to register the REST services I've created a class named RESTConfig that extends Application and added @ApplicationPath(value = "resources") annotation to it.
The UserHandlerResource class is annotated with @Path(value = "users") and contains a single GET method returning a String type (also annotated accordingly with @GET, @Path and @Produces) returning "works!".

I can see the app deployed in the admin-web-ui

Folder structure

MyProject  
   ear
   domain - all jpa entities  
   ejb - several ejb's
   war - holds RESTConfig and UserHandlerResource

war pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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>

    <parent>
        <groupId>group</groupId>
        <artifactId>MyProject</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>war</artifactId>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- project dependencies -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>ejb</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <!-- <configuration>
                    <archive>
                        <manifestEntries>
                            <Class-Path>domain-${project.version}.jar</Class-Path>
                        </manifestEntries>
                    </archive>
                </configuration> -->
            </plugin>
        </plugins>
    </build>

</project>

MyProject pom.xml http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>group</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>MyProject</name>

<modules>
    <module>ear</module>
    <module>ejb</module>
    <module>war</module>
    <module>domain</module>
</modules>

<properties>
    <!-- Java version -->
    <java-version>1.7</java-version>

    <!-- plugin versions -->
    <ejb-plugin-version>2.3</ejb-plugin-version>
    <war-plugin-version>2.4</war-plugin-version>
    <ear-plugin-version>2.9.1</ear-plugin-version>
    <compiler-plugin-version>3.1</compiler-plugin-version>
    <surefire-plugin-version>2.17</surefire-plugin-version>
    <dependency-plugin-version>2.8</dependency-plugin-version>

    <!-- project config -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!-- dependency version -->
    <javaee-api-version>7.0</javaee-api-version>
    <ejb-spec-version>3.2</ejb-spec-version>

    <!-- Libraries version -->
    <testng-version>6.8.8</testng-version>
    <arquillian-version>1.1.5.Final</arquillian-version>
    <arquillian-wildfly-version>8.1.0.Final</arquillian-wildfly-version>
    <arquillian-transaction-version>1.0.1.Final</arquillian-transaction-version>

    <log4j2-version>2.0.1</log4j2-version>
</properties>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>${javaee-api-version}</version>
        </dependency>

        <!-- Logging dependencies -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-bom</artifactId>
            <version>${log4j2-version}</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-web</artifactId>
            <version>${log4j2-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-1.2-api</artifactId>
            <version>${log4j2-version}</version>
        </dependency>


        <!-- testing dependencies -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>${testng-version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian</groupId>
            <artifactId>arquillian-bom</artifactId>
            <version>${arquillian-version}</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.testng</groupId>
            <artifactId>arquillian-testng-container</artifactId>
            <version>${arquillian-version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.extension</groupId>
            <artifactId>arquillian-transaction-bom</artifactId>
            <version>${arquillian-transaction-version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-arquillian-container-embedded</artifactId>
            <version>${arquillian-wildfly-version}</version>
        </dependency>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-embedded</artifactId>
            <version>${arquillian-wildfly-version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${compiler-plugin-version}</version>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>${ejb-plugin-version}</version>
                <configuration>
                    <ejbVersion>${ejb-spec-version}</ejbVersion>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>${war-plugin-version}</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                    </archive>
                    <webResources>
                        <resource>
                            <filtering>true</filtering>
                            <directory>src/main/webapp</directory>
                            <includes>
                                <include>**/web.xml</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire-plugin-version}</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>${dependency-plugin-version}</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

I followed this tutorial in order to construct the app

Royi Freifeld
  • 629
  • 2
  • 11
  • 31
  • Was your app deployed correctly? How did you Register your rest Service? What Type of deployment so you use? Please provide more Info! – shillner Aug 16 '14 at 19:37
  • I deploy the application using eclipse (at the moment) + maven as dependency management - so I guess as standalone. I'm not doing anything special to register the REST services, just extend the Application class and use ApplicationPath annotation in addition to annotating the service itself with Path. – Royi Freifeld Aug 18 '14 at 18:46
  • Ok, Rest Service seems to be correct. Don't you see the deployment in the web ui under 'manage deployments'? Is there anything in the server log? What does eclipse say ehem deploying? Also try to deploy using the maven plugin and if this also doesn't work, using the filescanner mode. And please post your setup (pom.xml, project structure, ...) – shillner Aug 19 '14 at 05:12
  • Added the details you requested, hopefully it could give you some more info. As for the server logs, there's nothing out of the ordinary (to my knowledge). I haven't tried it with maven plugin or file scanner. I'll try and post the results soon – Royi Freifeld Aug 23 '14 at 15:15

2 Answers2

0

Your main problem might be that you are missing the leading slashes at your path declarations (@ApplicationPath and @Path) but I was not yet able to try this out.

Then I'm not quite sure about why you are adding this line:

<Class-Path>domain-${project.version}.jar</Class-Path>
to the manifest of your war!?
If you want to add a deployed jar as a dependency to your war within the container, you must use this line:
<Dependencies>domain-${project.version}.jar</Dependencies>

Furthermore, I think this dependency is also not written to the manifest file if you deploy your app using the Run-On-Server action of the Eclipse Java EE Tools since this is a maven-specific build instruction.

I would try to build and deploy the project using maven, change the paths to include leading slashes and replace the manifest entry.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
shillner
  • 1,806
  • 15
  • 24
  • According to Path and ApplicationPath API, the leading "/" is ignored. Regarding the Class-Path entry, it is currently a comment, and according to http://stackoverflow.com/questions/9237485/how-to-set-up-manifest-class-path-properly-in-maven-war-plugin , not adding it could be a problem, but currently leaving it as a comment or adding it doesn't really matter... – Royi Freifeld Aug 26 '14 at 08:53
0

I have added maven-wildfly-plugin in order to deploy to Wildfly from Maven. Still didn't work. Among several other problems, the most critical one was that I was running it from Eclipse. While running my code from native CLI maven, everything worked.
In addition to that, apparently it had something to do with the Eclipse's "add/remove resources to the server". I added the ear that was created and I think it collided with the maven deployment. Once removed, the maven configuration for clean install ran smoothly.

Royi Freifeld
  • 629
  • 2
  • 11
  • 31