9

通常我会去 java.net 站点并查看我得到的错误代码是什么,但他们的网站目前处于脱机状态。基本上我正在遵循本指南:

http://pookey.co.uk/wordpress/archives/95-getting-started-with-glassfish-using-maven

尝试在我的 GlassFish 应用程序服务器上部署一个示例 maven Web 应用程序。我的POM文件如下:

<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>org.cellnet.test</groupId>
  <artifactId>hello-world</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>hello-world Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <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>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>hello-world</finalName>
    <plugins>
        <plugin>
            <groupId>org.glassfish.maven.plugin</groupId>
            <artifactId>maven-glassfish-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <user>admin</user>
                <adminPassword>password</adminPassword>
                <glassfishDirectory>C:\glassfish3</glassfishDirectory>
                <components>
                    <component>
                        <name>${project.artifactId}</name>
                        <artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
                    </component>
                </components>
                <domain>
                    <name>domain1</name>
                    <adminPort>4848</adminPort>
                    <httpPort>8080</httpPort>
                    <httpsPort>8443</httpsPort>
                </domain>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>

我的 GlassFish 应用程序服务器已启动并正在运行,但我在执行时收到以下错误消息

mvn war:war glassfish:deploy

Failed to execute goal org.glassfish.maven.plugin:maven-glassfish-plugin:2.1:
deploy (default-cli) on project hello-world: Deployment of myPathToMavenProject.war 
has failed. IOException: Cannot run program "myPathToGlassfishFolder\bin\asadmin": 
CreateProcess error=193, %1 is not a valid Win32 application -> [Help 1]
4

2 回答 2

30

这是此处所述的 Windows 下的问题。在修复之前,删除 asadmin(不带扩展名)文件应该会有所帮助。

于 2011-07-14T18:13:44.103 回答
1

使用 Glassfish4 我遇到了这个错误并且重命名\删除文件是不够的。我发现这篇文章as-install-parent/bin和需要从两者中删除 asadminas-install/bin

于 2015-05-11T18:32:02.867 回答