users@jersey.java.net

[Jersey] Re: Deploying on Jetty

From: Dário Abdulrehman <dario.rehman_at_gmail.com>
Date: Wed, 25 May 2011 11:40:13 +0100

I added the jersey-server-module dependency.
Here is my pom:



<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>sdlink</groupId>
    <artifactId>sparql</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>sparql Java EE 6 Webapp</name>
    <url>http://maven.apache.org</url>
    <repositories>
        <repository>
            <id>java.net2</id>
            <name>Repository hosting the jee6 artifacts</name>
            <url>http://download.java.net/maven/2</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>us.monoid.web</groupId>
            <artifactId>resty</artifactId>
            <version>0.2.0</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>20020423</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.7-ea07</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>6.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.2</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1-beta-1</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.24</version>
                <configuration>
                    <webApp>${basedir}/target/sparql.war</webApp>
                    <contextPath>sparql</contextPath>
                </configuration>
            </plugin>
        </plugins>
        <finalName>sparql</finalName>
    </build>
    <profiles>
        <profile>
            <id>endorsed</id>
            <activation>
                <property>
                    <name>sun.boot.class.path</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>2.0.2</version>
                        <configuration>
                            <!-- javaee6 contains upgrades of APIs
contained within the JDK itself.
                                 As such these need to be placed on
the bootclasspath, rather than classpath of the
                                 compiler.
                                 If you don't make use of these new
updated API, you can delete the profile.
                                 On non-SUN jdk, you will need to
create a similar profile for your jdk, with the similar property as
sun.boot.class.path in Sun's JDK.-->
                            <compilerArguments>

<bootclasspath>${settings.localRepository}/javax/javaee-endorsed-api/6.0/javaee-endorsed-api-6.0.jar${path.separator}${sun.boot.class.path}</bootclasspath>
                            </compilerArguments>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>6.0</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>



Now starting jetty issues the following:


SEVERE: The ResourceConfig instance does not contain any root resource classes.
2011-05-25 11:35:06.876:WARN:/sparql:unavailable
com.sun.jersey.api.container.ContainerException: The ResourceConfig
instance does not contain any root resource classes.
        at com.sun.jersey.server.impl.application.RootResourceUriRules.<init>(RootResourceUriRules.java:99)
        at com.sun.jersey.server.impl.application.WebApplicationImpl._initiate(WebApplicationImpl.java:1299)
        .....





On Wed, May 25, 2011 at 7:20 AM, Jakub Podlesak
<jakub.podlesak_at_oracle.com> wrote:
> Hi Dario,
>
> On 05/24/2011 06:36 PM, Dário Abdulrehman wrote:
>>
>> I added the maven-jetty-plugin to the pom as in your example but I get
>> an error when running mvn jetty:run:
>>
>> java.lang.ClassNotFoundException:
>> com.sun.jersey.spi.container.servlet.ServletContainer
>
> This class is from the jersey-server module. Do you have
> the following dependency defined in your pom?
> The ${jersey.version} refers to the actual Jersey version
> you want to use...
>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>jersey-server</artifactId>
> <version>${jersey.version}</version>
> <scope>compile</scope>
> </dependency>
>
> ?
>
> The best would be if you could send out your pom file
> to the list, so that others could review.
>
> ~Jakub
>
>> Also I added the configuration manually to the pom.  If I add the
>> dependency through netbeans Libraries ->  Add dependency it adds the
>> plugin as a<dependency></dependency>  and not as a<plugin></plugin>.
>> I don't know if this is important.
>>
>> On Tue, May 24, 2011 at 4:01 PM, Pavel Bucek<pavel.bucek_at_oracle.com>
>>  wrote:
>>>
>>> Hello,
>>>
>>> yes, it is possible, see helloworld-webapp sample [1] and execute mvn
>>> clean
>>> package jetty:run.
>>>
>>> Jetty:run doesn't work out of the box, it must be configured, see pom
>>> file
>>> of that sample.
>>>
>>> Regards,
>>> Pavel
>>>
>>> [1]
>>>
>>> http://download.java.net/maven/2/com/sun/jersey/samples/helloworld-webapp/1.7/helloworld-webapp-1.7-project.zip
>>>
>>> On 5/24/11 4:56 PM, Dário Abdulrehman wrote:
>>>>
>>>> I would include some services in a VM but glassfish is very big and I
>>>> would like to keep the VM as small as possible.
>>>> Is it possible to deploy the web services on the Jetty web server?
>>>>
>>>> I tried to add jetty to the project dependencies and then running mvn
>>>> jetty:run but I get a
>>>> [ERROR] No plugin found for prefix 'jetty' in the current project and
>>>> in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] ...
>>>>
>>>>
>>>> Is it possible to deploy a Jersey web services on Jetty?
>>>>
>>>> Thanks.
>>>>
>>>
>
>