在阅读了几个教程(例如ocpsoft、oracle)后,我开始使用嵌入式 glassfish 来运行我的 hello-world 应用程序。它确实适用于远程服务器,但由于某种原因,在使用嵌入式服务器时没有部署任何内容。
1.)“找不到javadb客户端jar文件,derby jdbc驱动默认不可用。” 我正在使用德比,虽然例如变量 AS_DERBY_INSTALL 已设置并导出,但似乎找不到罐子。为什么?
2.) "INFO: Deployed null" 为什么我的应用没有部署???
运行时的 maven 输出,例如“mvn clean install”(无论我运行“mvn install embedded-glassfish:run”还是“mvn install embedded-glassfish:deploy”都没有区别)。
行家输出
[...]
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>
使用时
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.0</version>
maven 抛出一个 LifecycleExecutionException,原因是:java.io.FileNotFoundException: test.war。查看文件系统 test.war 甚至没有创建。如果我更改为 3.1 版,则不会引发异常,但会再次“部署为空”。为什么没有生成war文件?