Bugs item #603238, was opened at 2002-09-01 20:05
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=603238&group_id=22866

Category: CatalinaBundle
Group: v2.4 (stable)
Status: Open
Resolution: None
Priority: 5
Submitted By: Harald Gliebe (hagl)
Assigned to: Scott M Stark (starksm)
Summary: Unpacked EARs can't be redeployed

Initial Comment:
When redeploying an unpacked EAR that contains an 
unpacked WAR on JBoss-2.4.8_Catalina-4.0.4, the 
deployment fails with 

[ERROR,EmbeddedCatalinaServiceSX] Cause
java.lang.IllegalArgumentException: addChild:  Child 
name '/webapp' is not unique
        at 
org.apache.catalina.core.ContainerBase.addChild
(ContainerBase.java:779)
        at 
org.apache.catalina.core.StandardHost.addChild
(StandardHost.java:478)
        at 
org.jboss.web.catalina.EmbeddedCatalinaServiceSX.crea
teWebContext(EmbeddedCatalinaServiceSX.java:328)
        at 
org.jboss.web.catalina.EmbeddedCatalinaServiceSX.perf
ormDeploy(EmbeddedCatalinaServiceSX.java:246)
        at 
org.jboss.web.AbstractWebContainer.deploy
(AbstractWebContainer.java:211)
        at java.lang.reflect.Method.invoke(Native 
Method)
        at 
com.sun.management.jmx.MBeanServerImpl.invoke
(MBeanServerImpl.java:1628)
        at 
com.sun.management.jmx.MBeanServerImpl.invoke
(MBeanServerImpl.java:1523)
        at 
org.jboss.deployment.J2eeDeployer.startModules
(J2eeDeployer.java:505)
        at 
org.jboss.deployment.J2eeDeployer.startApplication
(J2eeDeployer.java:459)
        at org.jboss.deployment.J2eeDeployer.deploy
(J2eeDeployer.java:190)
        at java.lang.reflect.Method.invoke(Native 
Method)
        at 
com.sun.management.jmx.MBeanServerImpl.invoke
(MBeanServerImpl.java:1628)
        at 
com.sun.management.jmx.MBeanServerImpl.invoke
(MBeanServerImpl.java:1523)
        at org.jboss.deployment.AutoDeployer.deploy
(AutoDeployer.java:395)
        at org.jboss.deployment.AutoDeployer.run
(AutoDeployer.java:233)
        at java.lang.Thread.run(Unknown Source)
[ERROR,J2eeDeployer] Starting webapp failed!

To reproduce the error, unpack the attached Zip-file in 
the deploy directory, wait for JBoss to deploy the 
application and then touch the app/META-
INF/application.xml to trigger a redeployment.

The reason for this error is that an unpacked deployment 
isn't correctly undeployed before it is redeployed and 
therefore Catalina complains that a web application with 
the same context is already deployed. The 
undeployment fails because InstallerFactory looks for 
a 'deployment.cfg' file, that is only written for packed 
deployments.

As a fix/workaround I changed 
org.jboss.deployment.LocalDirInstaller to also write a 
deployment.cfg in tmp/<appname> and changed 
InstallerFactory to not delete the deployment on 
uninstall.
(The latter can probably be better done by moving the 
uninstall method from InstallerFactory into 
LegacyInstaller and LocalDirInstaller, and using the 
corresponding installer for installation and uninstallation, 
but would require some refactoring)

diff -u -r1.1.2.3 LocalDirInstaller.java
--- LocalDirInstaller.java      3 May 2002 01:09:07 -
0000    1.1.2.3
+++ LocalDirInstaller.java      1 Sep 2002 19:42:21 -
0000
@@ -10,6 +10,8 @@
 import java.io.FileInputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.ObjectOutputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -37,7 +39,10 @@
    // the resulting Deployment
    Deployment d;
    
-   // the log4j category for output
+    // to get the temprary deployment dir
+   InstallerFactory factory;
+
+  // the log4j category for output
    Logger log;
 
    // flag to not run execute twice
@@ -52,6 +57,7 @@
       throws J2eeDeploymentException, IOException
    {
       this.log = factory.log;
+      this.factory = factory;
       d = new Deployment();
       d.name = Util.getName(src.toString());
       d.sourceUrl=src;
@@ -193,7 +199,7 @@
             }
             break;
          }
-         //saveConfig();
+        saveConfig();
 
       }
       catch(Throwable t)
@@ -266,5 +272,21 @@
       }
       return libs;
    }
+
+   /** Serializes the Deployment object.
+    *  @throws IOException
+    */
+   private void saveConfig() throws IOException
+   {
+         File tmpDir = new File(factory.baseDir, 
d.name);
+               tmpDir.mkdirs();
+
+      ObjectOutputStream out = new 
ObjectOutputStream(new FileOutputStream(new File
(tmpDir, J2eeDeployer.CONFIG)));
+      
+      out.writeObject(d);
+      out.flush();
+      out.close();
+   }
+
 
 }

diff -u -r1.3.6.5 InstallerFactory.java
--- InstallerFactory.java       10 Dec 2001 02:35:37 -
0000    1.3.6.5
+++ InstallerFactory.java       1 Sep 2002 19:47:56 -
0000
@@ -126,9 +126,12 @@
     */
    public void uninstall(Deployment _d) throws 
IOException
    {
-      File appDir = new File(_d.localUrl.getFile());
-      
-      deleteRecursive(appDir);
+          if (_d.localUrl.equals(_d.sourceUrl)) {
+                  // exploded archive -> do not 
delete
+          } else {
+                  File appDir = new File
(_d.localUrl.getFile());
+                  deleteRecursive(appDir);
+          }
    }
    
    /** Finds all Deployments currently installed.



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=603238&group_id=22866


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to