Transitive dependencies unresolved at runtime in eclipse wtp - eclipse

I am facing an issue while running a Dynamic Web Project in Eclipse. I have created a Maven Project (archtype - webapp) and then added DWP behaviour in it by adding maven-eclipse-plugin (version 2.9). The I added my project dependencies in POM file which is as follows
<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>au.com.fairfaxdigital</groupId>
<artifactId>accessloganalyzer</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>accessloganalyzer Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>net.sourceforge.wurfl</groupId>
<artifactId>wurfl</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>scientiamobile.public</id>
<name>Scientia Mobile Public repository</name>
<url>http://dev.scientiamobile.com/nexus/content/repositories/public-releases/</url>
</repository>
</repositories>
<build>
<finalName>accessloganalyzer</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<projectNameTemplate>accessloganalyzer-${project.version}</projectNameTemplate>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
<manifest>${basedir}/src/main/resources/META-INF/MANIFEST.MF</manifest>
</configuration>
</plugin>
</plugins>
</build>
</project>
Then I build the project using maven command (clean install). I could see the generated war file in target folder. When try run this application on tomcat within eclipse (project->right click->run one server) tomcat starts with an error.
SEVERE: Exception sending context initialized event to listener
instance of class
net.sourceforge.wurfl.core.web.WURFLServletContextListener
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at
net.sourceforge.wurfl.core.web.WURFLServletContextListener.contextInitialized(WURFLServletContextListener.java:81)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
at
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:866)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:842)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:649)
at
org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1581)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662) Caused by:
java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
... 15 more Starting Introspector initialization...
When I look into the Eclipse Folder from where tomcat runs the app (C:\Deepak\Study\Dev\Practicals\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\accessloganalyzer-1.0-SNAPSHOT), I didn't find any dependencies (including commons-lang which is being referenced in the error) for the third party library wurfl.1.4.jar that I am using in my project.
wurfl library uses the following dependencies which are not present in WEB-INF/lib and hence causing the issue
commons-collections-3.2.1
commons-lang-2.6
jackson-core-asl-1.8.2
jackson-mapper-asl-1.8.2
logback-classic-0.9.28
logback-core-0.9.28
slf4j-api-1.6.1
Can any one please point what I missing why these transitive dependencies are not being copied in WEB-INF/lib folder in the application WAR file?

Install m2e wtp plugin. This plugin can be installed from the Eclipse Marketplace (Help -> Eclipse Marketplace...). That should get you most of the way there. You should then see your dependencies where you are expecting.

Related

eclipse 2018-09 maven can't find dependency but it exists everywhere

I'm using an older version of eclipse 2018-09 with 32-bit Java, not sure that makes a difference. (project limitation for using these older versions)
I have been using the default maven plugin with the project and it all has worked so far, except for the following one:
<!-- https://mvnrepository.com/artifact/com.github.kilianB/JImageHash -->
<dependency>
<groupId>com.github.kilianB</groupId>
<artifactId>JImageHash</artifactId>
<version>3.0.0</version>
</dependency>
https://mvnrepository.com/artifact/com.github.kilianB/JImageHash/3.0.0
I get:
Missing artifact com.github.kilianB:JImageHash:jar:3.0.0
I have done all the maven things, clean, install, etc...
This jar is located at "JCenter repository (https://jcenter.bintray.com/)".
And the url and files are all there.
https://bintray.com/kilianb/maven/JImageHash/3.0.0#files/com%2Fgithub%2FkilianB%2FJImageHash%2F3.0.0
I even downloaded the files and jars.
I have no settings.xml in my .m2, as I'm using the default eclipse maven. The pom.xml is the default one and I added the dependencies I have needed.
What's missing?
Thanks in advance.
FWIW here's my pom I'm using
<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>patmangames</groupId>
<artifactId>carddetect</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j -->
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>4.5.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>4.3.0-1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.0</version>
</dependency>
<!-- FAILS TO FIND AND DOWNLOAD-->
<dependency>
<groupId>com.github.kilianB</groupId>
<artifactId>JImageHash</artifactId>
<version>3.0.0</version>
</dependency>
<!-- FAILS TO FIND AND DOWNLOAD-->
</dependencies>
</project>
Without a settings.xml you only get jars from MavenCentral.
Note that MavenCentral has nothing to do with mvnrepository. Finding a jar on mvnrepository does not mean that it is in MavenCentral.
Indeed, in your case, the jar is in jcenter, so you need to write a settings.xml where you add that repository as <repository>.

Eclipse oxygen 3 maven doesn't compile java files

I'm new to Maven and I'm trying to create a basic Jersey project with Eclipse Oxygen 3 IDE. For some reason when I run the compile or install goal, the target folder copy the java files, and indeed I don't see that Eclipse/Maven is creating any class file.
The Build/Clean options of Eclipse are disable, and using CTRL+B (compile shortcut) doesn't do anything.
The POM is as follows.
<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>some.group.id</groupId>
<artifactId>MyName</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Any name</name>
<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.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
<build>
<finalName>TargetName</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>/home/someuser/java/bin/javac</executable>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Thanks for every help out there.
Edit
The project is created in Eclipse using "New" -> "Other" -> "Maven" -> "Maven project", and in the file system it doesn't contain a .project file.
Also I added the path of the compiler (see the edited pom.xml above), but the result is the same.

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.

mvn install not installing/embedding dependencies

I have been told that the install goal should mean that my resulting jar file will have all required dependencies included into the deployment. This, however, doesn't appear to be working for me.
Here's my 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>org.zone.commandit</groupId>
<artifactId>CommandIt</artifactId>
<version>0.2</version>
<name>CommandIt</name>
<repositories>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public</url>
</repository>
<repository>
<id>milkbowl-repo</id>
<url>http://ci.herocraftonline.com/plugin/repository/everything/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.5.2-R1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>Vault</artifactId>
<version>1.2.26-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>se.krka.kahlua</groupId>
<artifactId>kahlua-cldc11</artifactId>
<version>5.1_2.1.0</version>
</dependency>
<dependency>
<groupId>se.krka.kahlua</groupId>
<artifactId>kahlua-core</artifactId>
<version>5.1_2.1.0</version>
</dependency>
<dependency>
<groupId>se.krka.kahlua</groupId>
<artifactId>kahlua-interpreter</artifactId>
<version>5.1_2.1.0</version>
</dependency>
<dependency>
<groupId>se.krka.kahlua</groupId>
<artifactId>kahlua-j2se</artifactId>
<version>5.1_2.1.0</version>
</dependency>
</dependencies>
</project>
From this, I expect a CommandIt-0.2.jar file with commons-io and the kahlua libraries (which are installed in the local repository). The bukkit and Vault dependencies should not be included as they are provided in the runtime environment.
However, upon inspecting the project jar file with 7zip, I find only META-INF and my own source code. What am I doing wrong?
You can use the Maven Assembly plugin to generate a JAR containing all your dependencies.
Add the following in the build > plugins section:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
The Maven target to run this plugin is assembly:single.
Maven dependencies are downloaded to the local maven repository, it is usually .m2 directory in your user home directory. Packaging JAR doesn't include any other JARs into the result. If you want to make a web application, use packaging WAR (or EAR). In the WAR file there are your JARs inc. all dependencies included.
mvn install executes plugins which simply put whatever artifacts were built, in this case a JAR file with your code, into your local repository, typically located at ~/.m2/repository.
If you want to assemble something to distribute, like a tarball containing JARs and shell scripts, looking into the Maven assembly plugin. If you want to assemble a single JAR file containing your code and the code in your dependencies, the Maven assembly plugin can be run using the jar-with-dependencies descriptor.

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.