Deployment failed on jboss 6 netbeans 7.0.1 - deployment

I have created a sample resteasy application
The web service is like this:
package com.mycompany.mavenproject1;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
#Path("/")
public class HelloService {
#GET
#Path("/Hello/{name}")
public Response printMessage(#PathParam("name") String name) {
return Response.status(200).entity("Hello " + name).build();
}
}
pom.xml
<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>com.mycompany</groupId>
<artifactId>mavenproject1</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>mavenproject1 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>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs-all</artifactId>
<version>2.2.1.GA</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>
</plugins>
<finalName>mavenproject1</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>
<properties>
<netbeans.hint.deploy.server>JBoss4</netbeans.hint.deploy.server>
</properties>
</project>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_3_0.xsd"
version="3.0">
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/</param-value>
</context-param>
<servlet>
<servlet-name>HelloService</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet-mapping>
<servlet-name>HelloService</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
resteasy 2.2.1GA, jboss-as-disstribution-6.1.0-final, netbeans 7.0.1
please tell am I missing any parts?
I am new with it. please help me..
output in netbeans:
cd C:\Users\admin\Desktop\mavenproject1; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.6.0_23" "\"C:\\Program Files\\NetBeans 7.0.1\\java\\maven\\bin\\mvn.bat\"" -Dnetbeans.deploy=true package
Scanning for projects...
------------------------------------------------------------------------
Building mavenproject1 Java EE 6 Webapp 1.0-SNAPSHOT
------------------------------------------------------------------------
[resources:resources]
Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
Copying 0 resource
[compiler:compile]
Compiling 1 source file to C:\Users\admin\Desktop\mavenproject1\target\classes
[resources:testResources]
Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
skip non existing resourceDirectory C:\Users\admin\Desktop\mavenproject1\src\test\resources
[compiler:testCompile]
Nothing to compile - all classes are up to date
[surefire:test]
No tests to run.
Surefire report directory: C:\Users\admin\Desktop\mavenproject1\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[war:war]
Packaging webapp
Assembling webapp[mavenproject1] in [C:\Users\admin\Desktop\mavenproject1\target\mavenproject1]
Processing war project
Copying webapp resources[C:\Users\admin\Desktop\mavenproject1\src\main\webapp]
Webapp assembled in [90 msecs]
Building war: C:\Users\admin\Desktop\mavenproject1\target\mavenproject1.war
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 2.961s
Finished at: Sun Jun 17 17:09:09 IST 2012
Final Memory: 8M/19M
------------------------------------------------------------------------
NetBeans: Deploying on JBoss Application Server
profile mode: false
debug mode: false
force redeploy: true
Distributing C:\Users\admin\Desktop\mavenproject1\target\mavenproject1.war to [org.jboss.deployment.spi.LocalhostTarget#1e8a877]
Deploying C:\Users\admin\Desktop\mavenproject1\target\mavenproject1.war
Failed
The module has not been deployed.
at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:173)
at org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:125)
at org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:202)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)

Related

maven surefire plugin not finding Junit tests written in Scala

In a blank slate maven scala project, we're trying to get a Junit4 testcase identified up by maven surefire plugin. Where are we going wrong?
Inside src/test/scala/Main.scala we have:
import org.junit.Assert._
import org.junit.Test
class main {
#Test
def myTestCase {
assertTrue("#1 is greater than 0", 1>0)
}
}
Our POM is as follows.
<?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>
<groupId>groupId</groupId>
<artifactId>junitTestProject</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.22.0</version>
</dependency>
</dependencies>
<configuration>
<includes>
<include>**/*.scala</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Running maven test lifecycle within intelliJ, we get:
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) # junitTestProject ---
[INFO] No tests to run.
In case they were required, we tried experimenting also (probably incorrectly) with:
junit-interface
org.scalatestplus
junit-vintage-engine
Note: In an alternative project, we have tried with scalatest (and can get scalatest testcases identified by the scalatest-maven-plugin) but had project performance issues, so wanted to compare with just Junit & maven surefire

deploying kieserver in Cloud foundry

I need to deploy Kie server in Cloudfoundry. I tried to push the war file (https://download.jboss.org/drools/release/7.0.0.Final/kie-server-distribution-7.0.0.Final.zip) to CF.
The application is starting up, but crashes as it launches.
Error:
2017-07-17T15:53:27.720-04:00 [APP/PROC/WEB/0] [OUT] [CONTAINER] org.apache.jasper.servlet.TldScanner INFO At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2017-07-17T15:53:27.746-04:00 [APP/PROC/WEB/0] [ERR] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
2017-07-17T15:53:27.746-04:00 [APP/PROC/WEB/0] [ERR] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2017-07-17T15:53:27.746-04:00 [APP/PROC/WEB/0] [ERR] SLF4J: Defaulting to no-operation (NOP) logger implementation
2017-07-17T15:53:28.042-04:00 [APP/PROC/WEB/0] [OUT] at org.kie.server.services.jbpm.JbpmKieServerExtension.getPersistenceProperties(JbpmKieServerExtension.java:665)
2017-07-17T15:53:28.042-04:00 [APP/PROC/WEB/0] [OUT] java.lang.BootstrapMethodError: java.lang.IllegalAccessError: no such method: org.kie.server.services.jbpm.jpa.PersistenceUnitInfoLoader.isValidPersistenceKey(String)Boolean/invokeStatic
and as an other option, I tried to deploy a doccker image, because of infrastructure and firewall, its taking some time from the cloud team.
Can someone suggest me how to host kie server in CF and a docker image(kieserver) that works in CF.
UPDATE
I am also trying to deploy this using a spring boot, adding kie server as a dependency in pom.xml. I am trying this in my local, before deploying this to CF.
Correct me if I am wrong.
pom.xml
<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>com.proj</groupId>
<artifactId>proj-kie-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>proj-kie-server</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- Compile -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> -->
<!-- <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency> -->
<!-- Provided (for embedded war support) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.kie.server</groupId>
<artifactId>kie-server</artifactId>
<type>pom</type>
<version>7.0.0.Final</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.kie.server</groupId>
<artifactId>kie-server</artifactId>
<version>7.0.0.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.projectodd.jrapidoc
</groupId>
<artifactId>
jrapidoc-rest-plugin
</artifactId>
<versionRange>
[0.5.0.Final,)
</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_3_0.xsd"
version="3.0">
<display-name>KieServer</display-name>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<filter>
<filter-name>capture-request-filter</filter-name>
<filter-class>org.kie.server.services.impl.security.web.CaptureHttpRequestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>capture-request-filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.kie.server.remote.rest.common.KieServerApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/services/rest/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/services/rest</param-value>
</context-param>
<security-constraint>
<web-resource-collection>
<web-resource-name>REST web resources</web-resource-name>
<url-pattern>/services/rest/*</url-pattern>
<http-method>GET</http-method>
<http-method>PUT</http-method>
<http-method>POST</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>kie-server</role-name>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>KIE Server</realm-name>
</login-config>
<security-role>
<role-name>kie-server</role-name>
</security-role>
<security-role>
<role-name>user</role-name>
</security-role>
</web-app>
Application.yml
logging:
level:
root: DEBUG
server:
port: 8080
contextPath: /proj-kie-server
So according to this doc.
I am trying my this url -> http://localhost:8080/proj-kie-server/services/rest/server
Response is suppose to be, if the kie server is started.
<response type="SUCCESS" msg="KIE Server info">
<kie-server-info>
<version>6.2.0.redhat-1</version>
</kie-server-info>
</response>
But I am seeing error.
{"timestamp":1500581006629,"status":404,"error":"Not Found","message":"No message available","path":"/proj-kie-server/services/rest/server"}
How should I kickstart kie server using a spring boot app.
Thank you.

resteasy javax.ws.rs.NotFoundException: Could not find resource for full path

Condition
1.resteasy 3.0.4.Final
2.eclipse
3.maven
Action
I got war package into tomcat7(window x64) webapps and server run normally.
Visit http://localhost:8080/test-resteasy/rest/message/hello, and browser print "Restful example : hello".
But when I maven build tomcat7:run tomcat7-maven-plugin in eclipse,visit the same url throws:
javax.ws.rs.NotFoundException: Could not find resource for full path
Source (web.xml)
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app version="3.0" 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_3_0.xsd">
<display-name>Archetype Created Web Application</display-name>
<!-- Auto scan REST service -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!-- this need same with resteasy servlet url-pattern -->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest</param-value>
</context-param>
<servlet>
<servlet-name>resteasy-servlet</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
(pom.xml)
<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>top.crowley.rest</groupId>
<artifactId>resteasy</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>resteasy Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-servlet-initializer</artifactId>
<version>3.0.4.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.4.Final</version>
</dependency>
</dependencies>
<build>
<finalName>test-resteasy</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<port>8080</port>
<path>/test-resteasy</path>
<uriEncoding>UTF-8</uriEncoding>
<finalName>test resteasy</finalName>
<server>tomcat7</server>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
MessageRestService
package top.crowley.resteasy;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
#Path("/message")
public class MessageRestService {
#GET
#Path("/{param}")
public Response printMessage(#PathParam("param") String msg) {
String result = "Restful example : " + msg;
return Response.status(200).entity(result).build();
}
}
Conjecture
I think of source code is correct, because of run war package in single tomcat 7 server successful. Maybe lack of some dependencies in pom.xml.
Thanks!
Really long post to analyze each POM dependency....but why don't you give a try to compile maven in this way, suggested by official resteasy team?
mvn clean install
mvn jetty:run
https://github.com/resteasy/resteasy-examples/tree/3.1.1.Final/resteasy-springMVC

SEVERE: Servlet /JAXRS-HelloWorld threw load() exception java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer

I read through plenty of posts related to this issue but couldn't get any help .
ERROR
Appreciate if someone can help me out.
enter image description here
This is how my POM and web looks like . I have tried copying the required war file to C:\appache tomcat 7 but no luck. Even deploying it within the eclipse also gives me the same error.
WEb
enter image description here
POM.xML:-
<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>com.tutorialacademy.rest</groupId>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>helloworld Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-apache-client</artifactId>
<version>1.19</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
By the exception, it looks like the com.sun.jersey.spi.container.servlet.ServletContainer class is not available in your classpath.
Note that Jersey 1.x and Jersey 2.x use different package names:
Jersey 1.x: com.sun.jersey
Jersey 2.x: org.glassfish.jersey
So, I understand you are using Jersey 1.x.
Jersey 1.x depencency
To use Jersey 1.x, you need the following dependecy in your pom.xml:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
To read more about Jersey 1.x dependencies, have a look at the documentation.
You can check the latest version of the jersey-server artifactId in the Maven Repository.
Jersey 2.x depencency
If you want to use Jersey 2.x, you have to add the following dependency to your pom.xml:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- if your container implements Servlet API older than 3.0,
use "jersey-container-servlet-core" -->
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.1</version>
</dependency>
You can check the latest version of the jersey-container-servlet artifactId in the Maven Repository.
Read more about Jersey 2.x dependencies in the documentation.
UPDATE
If you can, I do recommend using Jersey 2.x rather than Jersey 1.x.
To do it, use the following pom.xml:
<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>com.tutorialacademy.rest</groupId>
<artifactId>helloworld</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Hello World</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- if your container implements Servlet API older than 3.0,
use "jersey-container-servlet-core" -->
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
And the following web.xml:
<web-app 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_3_0.xsd"
version="3.0">
</web-app>
If you are trying to make a Web application to provide web service using Jersey library in Tomcat and Eclipse and still getting problem after adding jersey-server.jar in the classpath. You can follow these steps to add dependency on deployment assembly.
Project -> properties -> development assembly -> add -> java build path entries -> maven dependency
This should work.

Create an "Application Client" with Maven in Java EE

I am trying to create a maven based Enterprise Application with an Application Client which runs in the Application Client Container from GlassFish. It should fit togheter as the Project template from Netbeans "Enterprise Application" + "Enterprise Application Client" but with maven and not ant.
Until now I have following projects
Assembly Maven Project
EAR-Module
EJB-Module
WEB-Module (works well with inside the ear)
Swing Client Module
The Assembly pom.xml looks like:
<project xml...
<modules>
<module>shop-ear</module>
<module>shop-web</module>
<module>shop-ejb</module>
<module>shop-client</module>
</modules>
</project>
The ear pom.xml contain
<project ...>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>shop</artifactId>
<groupId>my.package.name</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>ch.hslu.edu.enapp</groupId>
<artifactId>shop-ear</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>ear</packaging>
<!-- ... -->
<dependencies>
<dependency>
<groupId>my.package.name</groupId>
<artifactId>shop-ejb</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>my.package.name</groupId>
<artifactId>shop-web</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>my.package.name</groupId>
<artifactId>shop-client</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
And the Swing Client pom.xml contains
<project xmlns=....>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>shop</artifactId>
<groupId>my.package.name</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>my.package.name</groupId>
<artifactId>shop-client</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>shop-client</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<archive>
<manifest>
<mainClass>my.package.name.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<url>http://download.java.net/maven/2/</url>
<id>java.net</id>
<layout>default</layout>
<name>java.net</name>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jdesktop</groupId>
<artifactId>beansbinding</artifactId>
<version>1.2.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Currently I have no dependencies between the Swing Client and the EJB Module. I just want to get a simple Swing form up and running out of the ACC form GlassFish (v 3.1.1).
But this doesn't work. The Swing-Client is packed into the lib folder inside the ear-file and I can not start it.
Do you know a tutorial or example which fulfill this task?
Your ear pom needs to configure the ear plugin like (maybe you just left it out when you put it into your question?):
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<version>6</version>
<generateApplicationXml>true</generateApplicationXml>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>com.foo</groupId>
<artifactId>shop-web</artifactId>
<contextRoot>webstuff</contextRoot>
</webModule>
<ejbModule>
<groupId>com.foo</groupId>
<artifactId>shop-ejb</artifactId>
<classifier>single</classifier>
<bundleFileName>shop-ejb.jar</bundleFileName>
</ejbModule>
<jarModule>
<groupId>com.foo</groupId>
<artifactId>shop-client</artifactId>
<bundleDir>/</bundleDir>
<bundleFileName>shop-client.jar</bundleFileName>
<includeInApplicationXml>true</includeInApplicationXml> <!-- i don't remember if this was absolutely necessary -->
</jarModule>
</modules>
</configuration>
</plugin>
That will package your application client jar outside the lib folder, and will help you define the context roots for your war modules (there isn't another way that I could find). The bundleFileName was important to get the URL to launch the client to make more sense.
I don't know of a single tutorial that puts this all together, but some resources are:
http://blogs.steeplesoft.com/2011/02/java-ees-buried-treasure-the-application-client-container/
http://java.sun.com/developer/technicalArticles/J2EE/jws-glassfish/part3.html
http://blogs.oracle.com/quinn/entry/customizing_generated_java_web_start
Now, there is official maven support for app clients
http://maven.apache.org/plugins/maven-acr-plugin/
http://maven.apache.org/plugins/maven-ear-plugin/examples/using-app-client.html
http://web.anahata-it.com/2011/09/09/java-jee-desktop-maven-enterprise-application-client/
NetBeans 7.1 will add support for maven app clients too.