I just encountered a problem with my glassfish installation while preforming a deployment with maven. I was upgrading from a SNAPSHOT version of Glassfish to 3.1.1. I unpacked a brand new version and started getting the following error:

1
Cannot run program "C:\usr\bin\glassfish3\glassfish\bin\asadmin": CreateProcess error=193, %1 is not a valid Win32 application

Here is what I discovered:

When I ran ‘mvn package glassfish:redeploy -DskipTests=true -e’:

1
[ERROR] Failed to execute goal org.glassfish.maven.plugin:maven-glassfish-plugin:2.1:redeploy (default-cli) on project ch03:Undeployment of domain1 failed. IOException: Cannot run program "C:\usr\bin\glassfish3\glassfish\bin\asadmin": CreateProcesserror=193, %1 is not a valid Win32 application -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.glassfish.maven.plugin:maven-glassfish-plugin:2.1:redeploy (default-cli) on project ch03: Undeployment of domain1 failed. IOException: Cannot run program "C:\usr\bin\glassfish3\glassfish\bin\asadmin": CreateProcess error=193, %1 is not a valid Win32 application        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)        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:319)        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:39)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)        at java.lang.reflect.Method.invoke(Method.java:597)        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.MojoExecutionException: Undeployment of domain1 failed. IOException: Cannot run program "C:\usr\bin\glassfish3\glassfish\bin\asadmin": CreateProcess error=193, %1 is not a valid Win32 application        at org.glassfish.maven.plugin.command.AsadminCommand.execute(AsadminCommand.java:124)        at org.glassfish.maven.plugin.RedeployGlassfishMojo.doExecute(RedeployGlassfishMojo.java:61)        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

Here was my maven plugin:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<plugin>
    <groupId>org.glassfish.maven.plugin</groupId>
    <artifactId>maven-glassfish-plugin</artifactId>
    <version>2.1</version>
 
    <configuration>
        <glassfishDirectory>${glassfish.domain.home}</glassfishDirectory>
        <user>${glassfish.adminUser}</user>
        <passwordFile>${glassfish.passwordFile}</passwordFile>
        <autoCreate>true</autoCreate>
        <debug>true</debug>
        <echo>true</echo>
        <skip>${test.int.skip}</skip>
        <domain>
            <name>${glassfish.domain.name}</name>
            <host>${glassfish.domain.host}</host>
            <httpPort>${glassfish.domain.port}</httpPort>
            <adminPort>4848</adminPort>
        </domain>
        <components>
            <component>
                <name>${glassfish.domain.name}</name>
                <artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
            </component>
        </components>
    </configuration>
</plugin>

And my corresponding properties:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<properties>
    <glassfish.domain.home>C:/usr/bin/glassfish3/glassfish</glassfish.domain.home>
    <glassfish.domain.name>domain1</glassfish.domain.name>
    <glassfish.domain.host>localhost</glassfish.domain.host>
    <glassfish.domain.port>8888</glassfish.domain.port>
    <glassfish.adminUser>admin</glassfish.adminUser>
    <glassfish.passwordFile>${glassfish.domain.home}/domains/domain1/config/domain-passwords
    </glassfish.passwordFile>
 
    <glassfish.command>deploy</glassfish.command>
 
    <database.password>qwerty</database.password>
 
    <domain.log.dir>${project.build.directory}</domain.log.dir>
</properties>

The subtlety was regarding where the admin.sh was located and which one to delete.
Initially I assumed that C:\usr\bin\glassfish3\bin\*.sh was where the shell script was that I needed to delete as I was not remembering that there is a second set of shell scripts in C:\usr\bin\glassfish3\glassfish\bin\* that also needed to be removed to run on windows.

I found a JIRA ticket for this and appears to be resolved: http://java.net/jira/browse/MAVEN_GLASSFISH_PLUGIN-5 but I am not sure when a valid release outside of the svn (Fixed in svn revision#84) fix will be available.

Conclusion

On a new Glassfish install on a windows machine, delete the corresponding shell scripts to avoid conflict.

Mick Knutson

Java, JavaEE, J2EE, WebLogic, WebSphere, JBoss, Tomcat, Oracle, Spring, Maven, Architecture, Design, Mentoring, Instructor and Agile Consulting. http://www.baselogic.com/blog/resume

View all posts

Java / JavaEE / Spring Boot Channel

BLiNC Supporters

BLiNC Adsense

Archives

Newsletter