Skip to main content

asadmin restart-domain not working for war inside ear as the default-web-module

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
typek_pb
Offline
Joined: 2010-09-26

I need to have war inside ear to be deployed as a default-web-module.
It works but only till server restart. I'm inspired in my solution by the suggestions present on: http://stackoverflow.com/questions/127492/how-do-you-deploy-a-war-thats-...

My use case:
1. deploy ear (foo) containing war (my-webapp) using asadmin
2. set war as a default-web-module

asadmin set server.http-service.virtual-server.server.default-web-module=foo#my-webapp-1.0-SNAPSHOT.war

3. works as expected, I can see war deployed to root
4. try to restart domain:
asadmin restart-domain

I see following error in logs and war is not deployed any more to root url:
[#|2013-04-18T09:17:25.744+0200|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=10;_ThreadName=Thread-2;|java.lang.Exception: WEB0145: Unable to deploy web module [foo#my-webapp-1.0-SNAPSHOT.war] at root context of virtual server [server], because this virtual server declares a default-web-module
java.lang.Exception: WEB0145: Unable to deploy web module [foo#my-webapp-1.0-SNAPSHOT.war] at root context of virtual server [server], because this virtual server declares a default-web-module
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1758)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)
at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:219)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:78)
at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:253)
at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:145)
at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:136)
at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:69)
at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117)
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 com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)
|#]

My environment:
GlassFish Server Open Source Edition 3.1.2.2 (build 5)

java -version
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
typek_pb
Offline
Joined: 2010-09-26

OK, never mind, got it :)

the problem was, that my ear contained application.xml that already had:
<context-root/>

that was enough for glassfish to publish it on the root of the virtual server's HTTP url.

So all the confusion came from the: http://stackoverflow.com/questions/127492/how-do-you-deploy-a-war-thats-inside-an-ear-as-the-root-context-in-glassfis

Based on that I set it explicitly as the default-web-module.

That was not needed a reading sources of the: WebContainer.java gave me the hint:

if (wmContextPath.length() == 0 &&
        vs.getDefaultWebModuleID() != null) {
    String msg = rb.getString("webcontainer.defaultWebModuleConflict");
    msg = MessageFormat.format(msg,
            new Object[]{wmName, vs.getID()});
    throw new Exception(msg);
}

So thanks for letting Glassfish been open source!