使用Netbeans将maven项目部署到glassfish

时间:2013-05-18 21:59:52

标签: maven netbeans deployment glassfish

这是我在这里发表的第一篇文章,所以我想对这个精彩的社区说声。这里找到的提示帮助了我很多次,但现在我需要提出一个问题

所以这是我的问题。我正在努力将一个简单的maven应用程序部署到Glassfish服务器,只是为了检查我的配置是否适合进一步开发。我使用Netbeans IDE,但由于它提供了小而且几乎不可读的控制台日志,我尝试使用系统终端(我使用Fedora)。

我正在尝试部署的应用程序包含一个无状态EJB bean(称为DziekanatBean,当前什么都不做)和一个Maven POM项目(简称为maven),它包含这个EJB bean作为模块。我尝试使用

部署整个项目
mvn -e glassfish:deploy

项目未部署,我发生以下错误:

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] maven
[INFO] DziekanatBean
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building maven 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-glassfish-plugin:2.1:deploy (default-cli) @ maven ---
Downloading: http://maven.ocean.net.au/release/org/apache/maven/maven-plugin-api/maven-metadata.xml
Downloading: http://maven.ocean.net.au/external/org/apache/maven/maven-plugin-api/maven-metadata.xml
Downloading: http://maven.ocean.net.au/snapshot/org/apache/maven/maven-plugin-api/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven:maven-plugin-api/maven-metadata.xml from/to release.ocean.net.au (http://maven.ocean.net.au/release): maven.ocean.net.au: Ta nazwa lub usługa jest nieznana
[WARNING] Could not transfer metadata org.apache.maven:maven-plugin-api/maven-metadata.xml from/to external.ocean.net.au (http://maven.ocean.net.au/external): maven.ocean.net.au
[WARNING] Could not transfer metadata org.apache.maven:maven-plugin-api/maven-metadata.xml from/to snapshot.ocean.net.au (http://maven.ocean.net.au/snapshot): maven.ocean.net.au
[INFO] asadmin --host localhost --port 4848 --user anonymous --passwordfile /tmp/mgfp3352576098599531177.tmp --interactive=false --echo=true --terse=true deploy --name maven --force=false --precompilejsp=false --verify=false --generatermistubs=false --availabilityenabled=false --asyncreplication=true --keepreposdir=false --keepfailedstubs=false --isredeploy=false --logreportederrors=true --upload=false "/mnt/D/Studia/Semestr 4/java/projekt/maven/target/Dziekanat.jar"
[ERROR] remote failure: File not found : /mnt/D/Studia/Semestr 4/java/projekt/maven/target/Dziekanat.jar
[ERROR] Deployment of /mnt/D/Studia/Semestr 4/java/projekt/maven/target/Dziekanat.jar failed.
[ERROR] For more detail on what might be causing the problem try running maven with the --debug option 
[ERROR] or setting the maven-glassfish-plugin "echo" property to "true".
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] maven ............................................. FAILURE [16.724s]
[INFO] DziekanatBean ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.893s
[INFO] Finished at: Sat May 18 23:45:39 CEST 2013
[INFO] Final Memory: 12M/172M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.glassfish.maven.plugin:maven-glassfish-plugin:2.1:deploy (default-cli) on project maven: Deployment of /mnt/D/Studia/Semestr 4/java/projekt/maven/target/Dziekanat.jar failed. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.glassfish.maven.plugin:maven-glassfish-plugin:2.1:deploy (default-cli) on project maven: Deployment of /mnt/D/Studia/Semestr 4/java/projekt/maven/target/Dziekanat.jar failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoFailureException: Deployment of /mnt/D/Studia/Semestr 4/java/projekt/maven/target/Dziekanat.jar failed.
    at org.glassfish.maven.plugin.command.AsadminCommand.execute(AsadminCommand.java:121)
    at org.glassfish.maven.plugin.DeployGlassfishMojo.doExecute(DeployGlassfishMojo.java:66)
    at au.net.ocean.maven.plugin.OceanMojo.execute(OceanMojo.java:67)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

这些是我的设置:
〜/ .m2目录/ settings.xml中

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <localRepository/>
    <interactiveMode/>
    <usePluginRegistry/>
    <offline/>
    <pluginGroups/>
    <servers/>
    <mirrors/>
    <priveProfiles>
    <activeProfile>glassfish-context</activeProfile>
</activeProfoxies/>
    <profiles>
        <profile>
            <id>glassfish-context</id>
            <properties>
                <local.glassfish.home>/usr/lib64/glassfish</local.glassfish.home>
                <local.glassfish.user>admin</local.glassfish.user>
                <local.glassfish.domain>domain1</local.glassfish.domain>
                <local.glassfish.httpPort>8080</local.glassfish.httpPort>
                <local.glassfish.adminPort>4848</local.glassfish.adminPort>
            </properties>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>glassfish-context</activeProfile>
    </activeProfiles>
</settings>

的pom.xml

<?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>com.zulik</groupId>
    <artifactId>maven</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>maven</name>
    <modules>
        <module>DziekanatBean</module>
    </modules>
    <pluginRepositories>
        <pluginRepository>

            <id>maven.java.net</id>
            <name>Java.net Maven2 Repository</name>
            <url>http://download.java.net/maven/2</url>
        </pluginRepository>
    </pluginRepositories>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>Dziekanat</finalName>
        <plugins>
            <plugin>
                <groupId>org.glassfish.maven.plugin</groupId>
                <artifactId>maven-glassfish-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <glassfishDirectory>${local.glassfish.home}</glassfishDirectory>
                    <echo>true</echo>
                    <debug>true</debug>
                    <autoCreate>true</autoCreate>
                    <glassfishDirectory>${local.glassfish.home}</glassfishDirectory>
                    <user>anonymous</user>
                    <adminPassword>password_here</adminPassword>

                    <domain>
                        <name>${local.glassfish.domain}</name>
                        <httpPort>${local.glassfish.httpPort}</httpPort>
                        <adminPort>${local.glassfish.adminPort}</adminPort>
                    </domain>
                    <components>
                        <component>
                            <name>${project.artifactId}</name>
                            <artifact>${project.build.directory}/${project.build.finalName}.jar</artifact>
                        </component>
                    </components>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您是否检查过该文件

/mnt/D/Studia/Semestr 4/java/projekt/maven/target/Dziekanat.jar

真的吗?如果没有,请执行

mvn clean install 

部署之前。

希望它有所帮助。