after reading several tutorials (e.g. ocpsoft, oracle) I started to use embedded glassfish for running my hello-world app. It does work with the remote server but for some reason nothing is deployed when using the embedded server.
1.) "Cannot find javadb client jar file, derby jdbc driver will not be available by default." I am using derby and although e.g. variable AS_DERBY_INSTALL is set and exported it seems the jars cannot be found. Why?
2.) "INFO: Deployed null" Why is my app not deployed???
maven output when run e.g. as "mvn clean install" (doesn't make a difference whether I run "mvn install embedded-glassfish:run" or "mvn install embedded-glassfish:deploy").
maven output
[...]
There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ transact ---
[INFO] Packaging webapp
[INFO] Assembling webapp [transact] in [/Users/grudom/Daten/IDE/EclipseProjects/workspace/transact/target/transact]
[INFO] Processing war project
[INFO] Copying webapp resources [/Users/grudom/Daten/IDE/EclipseProjects/workspace/transact/src/main/webapp]
[INFO] Webapp assembled in [117 msecs]
[INFO] Building war: /Users/grudom/Daten/IDE/EclipseProjects/workspace/transact/target/transact.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ transact ---
[INFO] Installing /Users/grudom/Daten/IDE/EclipseProjects/workspace/transact/target/transact.war to /Users/grudom/.m2/repository/de/exim/transact/1.0-SNAPSHOT/transact-1.0-SNAPSHOT.war
[INFO] Installing /Users/grudom/Daten/IDE/EclipseProjects/workspace/transact/pom.xml to /Users/grudom/.m2/repository/de/exim/transact/1.0-SNAPSHOT/transact-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-embedded-glassfish-plugin:3.1.2.2:run (default) @ transact ---
Created New Bootstrap ClassLoader. ServerId = maven, ClassPaths =
ClassPath Element : file:/Users/grudom/.m2/repository/org/glassfish/main/extras/glassfish-embedded-all/3.1.2.2/glassfish-embedded-all-3.1.2.2.jar
ClassPath Element : file:/Users/grudom/.m2/repository/org/glassfish/embedded/maven-embedded-glassfish-plugin/3.1.2.2/maven-embedded-glassfish-plugin-3.1.2.2.jar
ClassPath Element : file:/Users/grudom/.m2/repository/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar
ClassPath Element : file:/Users/grudom/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
ClassPath Element : file:/Users/grudom/.m2/repository/org/glassfish/main/common/simple-glassfish-api/3.1.2.2/simple-glassfish-api-3.1.2.2.jar
03.09.2012 16:28:18 com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.
03.09.2012 16:28:18 org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 4.3.0.Final
03.09.2012 16:28:18 PluginUtil getGlassFish
INFO: Created GlassFish ServerId = maven, BootstrapProperties = {GlassFish_Platform=Static}, GlassFishRuntime = com.sun.enterprise.glassfish.bootstrap.StaticGlassFishRuntime@7cb9e9a3, GlassFishProperties = {embedded-glassfish-config.server.network-config.network-listeners.network-listener.http-listener.enabled=true, embedded-glassfish-config.server.network-config.network-listeners.network-listener.http-listener.port=8080}, GlassFish = com.sun.enterprise.glassfish.bootstrap.StaticGlassFishRuntime$1@119a0c4e, GlassFish Status = INIT, TimeTaken = 876 ms
03.09.2012 16:28:18 com.sun.enterprise.v3.services.impl.GrizzlyService createNetworkProxy
INFO: Network listener https-listener on port 0 disabled per domain.xml
03.09.2012 16:28:19 com.sun.enterprise.v3.services.impl.GrizzlyProxy$2$1 onReady
INFO: Grizzly Framework 1.9.50 started in: 52ms - bound to [0.0.0.0:8080]
03.09.2012 16:28:19 com.sun.enterprise.v3.server.AppServerStartup run
INFO: GlassFish Server Open Source Edition 3.1.2.2 (java_re) startup time : Embedded (678ms), startup services(523ms), total(1.201ms)
03.09.2012 16:28:19 PluginUtil startGlassFish
INFO: Started GlassFish ServerId = maven, GlassFish = com.sun.enterprise.glassfish.bootstrap.StaticGlassFishRuntime$1@119a0c4e, TimeTaken = 747 ms
03.09.2012 16:28:19 PluginUtil doDeploy
INFO: Deployed null
Hit ENTER to redeploy, X to exit
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>de.exim</groupId>
<artifactId>transact</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>transact Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
<glassfish.home>/Users/grudom/Programme/glassfish</glassfish.home>
<glassfish.adminUser>admin</glassfish.adminUser>
<glassfish.adminPassword>admin</glassfish.adminPassword>
<glassfish.domain.name>domain1</glassfish.domain.name>
<glassfish.domain.host>localhost</glassfish.domain.host>
<glassfish.domain.adminPort>4848</glassfish.domain.adminPort>
<eclipselink.version>2.4.0</eclipselink.version>
</properties>
<repositories>
<repository>
<id>EclipseLink</id>
<url>http://download.eclipse.org/rt/eclipselink/maven.repo</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/glassfish/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>${eclipselink.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.9.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<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>
<encoding>ISO-8859-1</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<wtpversion>1.5</wtpversion>
<downloadSources>true</downloadSources>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>glassfish</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
<configuration>
<terse>false</terse>
<echo>true</echo>
<debug>true</debug>
<glassfishDirectory>${glassfish.home}</glassfishDirectory>
<user>${glassfish.adminUser}</user>
<adminPassword>${glassfish.adminPassword}</adminPassword>
<domain>
<name>${glassfish.domain.name}</name>
<host>${glassfish.domain.host}</host>
<adminPort>${glassfish.domain.adminPort}</adminPort>
</domain>
<components>
<component>
<name>${project.artifactId}</name>
<artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
</component>
</components>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>embeddedglassfish</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.glassfish.embedded</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.1.2.2</version>
<configuration>
<goalPrefix>embedded-glassfish</goalPrefix>
<app>test.war</app>
<port>8080</port>
<contextRoot>test</contextRoot>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
When using
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.0</version>
maven throws a LifecycleExecutionException with caused by: java.io.FileNotFoundException: test.war. Looking on the file system test.war wasn't even created. If I change to version 3.1 then no exception is thrown but again "deployed null". Why is no war file being generated?
At last I found the problem. The correct configuration would be
<build>
<plugins>
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.1</version>
<configuration>
<goalPrefix>embedded-glassfish</goalPrefix>
<app>target/${project.build.finalName}.war</app>
<port>8080</port>
<contextRoot>${project.build.finalName}</contextRoot>
<autoDelete>true</autoDelete>
<configFile>path_to_File/domain.xml</configFile>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Apart from referencing the correct groupId and version the element "app" needed a change. Additionally, in order to use a non-embedded instance of javadb the configFile element is pointing to the domain.xml of the non-embedded glassfish server.
Further documentation: http://docs.oracle.com/cd/E26576_01/doc.312/e24932/toc.htm
Hope, it helps others, too.