使用嵌入式glassfish服务器时部署为null [英] Deployed null when using embedded glassfish server

查看:181
本文介绍了使用嵌入式glassfish服务器时部署为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读了几篇教程(例如 ocpsoft oracle )我开始使用嵌入式glassfish运行我的你好世界的应用程序。它确实可以与远程服务器一起使用,但由于某种原因,在使用嵌入式服务器时没有部署任何内容。

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。)无法找到javadb客户端jar文件,derby jdbc驱动程序将默认不可用。
我正在使用德比,尽管如此变量AS_DERBY_INSTALL设置并导出似乎无法找到jar。为什么?

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
为什么我的应用程序没有部署???

2.) "INFO: Deployed null" Why is my app not deployed???

运行时的maven输出,例如作为mvn clean install(无论我运行mvn install embedded-glassfish:run还是mvn install embedded-glassfish:deploy)都没有区别。)

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输出

[...]
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,则不会抛出任何异常,但再次部署为null。为什么没有生成war文件?

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>

除了引用正确的groupId和版本外,元素app还需要更改。此外,为了使用非嵌入式javadb实例,configFile元素指向非嵌入式glassfish服务器的domain.xml。

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.

进一步的文档:< a href =http://docs.oracle.com/cd/E26576_01/doc.312/e24932/toc.htm =nofollow> http://docs.oracle.com/cd/E26576_01/doc。 312 / e24932 / toc.htm

希望,它也有助于其他人。

Hope, it helps others, too.

这篇关于使用嵌入式glassfish服务器时部署为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆