geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiam...@apache.org
Subject svn commit: r1213689 - in /geronimo/server/trunk: framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/ plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/ plugins/j2ee/geronimo-j2ee-build...
Date Tue, 13 Dec 2011 13:39:58 GMT
Author: xiaming
Date: Tue Dec 13 13:39:58 2011
New Revision: 1213689

URL: http://svn.apache.org/viewvc?rev=1213689&view=rev
Log:
GERONIMO-6230 Ensure the temp jar file exists before new NestedJarFile to avoid FileNotFoundException

Modified:
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java
    geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java?rev=1213689&r1=1213688&r2=1213689&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/util/JarUtils.java
Tue Dec 13 13:39:58 2011
@@ -55,6 +55,7 @@ public final class JarUtils {
     }
 
     public static final File DUMMY_JAR_FILE;
+    public static final String TEMP_FILE_NAME;
 
     private static final boolean jarUrlRewrite;
     static {
@@ -62,11 +63,20 @@ public final class JarUtils {
         jarUrlRewrite = Boolean.valueOf(System.getProperty("org.apache.geronimo.kernel.util.JarUtils.jarUrlRewrite",
"true"));
         try {
             DUMMY_JAR_FILE = FileUtils.createTempFile(false);
+            TEMP_FILE_NAME = DUMMY_JAR_FILE.getCanonicalPath();
             new JarOutputStream(new FileOutputStream(JarUtils.DUMMY_JAR_FILE), new Manifest()).close();
         } catch (IOException e) {
             throw new ExceptionInInitializerError(e);
         }
     }
+    
+    public static void assertTempFile() throws IOException {
+    	if(DUMMY_JAR_FILE.exists()) {
+    		return;
+    	} else {
+    		new JarOutputStream(new FileOutputStream(new File(JarUtils.TEMP_FILE_NAME)), new Manifest()).close();
+    	}
+    }
 
     public static File toTempFile(JarFile jarFile, String path) throws IOException {
         return toTempFile(createJarURL(jarFile, path));

Modified: geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?rev=1213689&r1=1213688&r2=1213689&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/client/geronimo-client-builder/src/main/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
Tue Dec 13 13:39:58 2011
@@ -438,6 +438,7 @@ public class AppClientModuleBuilder impl
             } else {
                 path = resource.getInternalRar();
                 try {
+                    JarUtils.assertTempFile();
                     connectorFile = new NestedJarFile(moduleFile, path);
                 } catch (IOException e) {
                     throw new DeploymentException("Could not locate connector inside ear",
e);
@@ -596,6 +597,7 @@ public class AppClientModuleBuilder impl
                 for (String libEntryPath : libClasspath) {
                     if (libEntryPath.endsWith(".jar")) {
                         try {
+                            JarUtils.assertTempFile();
                             NestedJarFile library = new NestedJarFile(earFile, libEntryPath);
                             appClientDeploymentContext.addIncludeAsPackedJar(URI.create(libEntryPath),
library);
                         } catch (IOException e) {
@@ -640,6 +642,7 @@ public class AppClientModuleBuilder impl
 
                     //Copy needed jar from ear to appclient configuration.
                     if (classpath.endsWith(".jar")) {
+                        JarUtils.assertTempFile();
                         NestedJarFile library = new NestedJarFile(earFile, classpath);
                         appClientDeploymentContext.addIncludeAsPackedJar(URI.create(classpath),
library);
                     }

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java?rev=1213689&r1=1213688&r2=1213689&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
Tue Dec 13 13:39:58 2011
@@ -624,6 +624,7 @@ public class EARConfigBuilder implements
                     String entryName = entry.getName();
                     //   EAR/lib/sub-dir/*.jar should not be added into lib classpath.
                     if (libDir != null && entry.getName().startsWith(libDir) &&
entry.getName().endsWith(".jar") && entry.getName().substring(libDir.length()+1).indexOf("/")
== -1) {
+                        JarUtils.assertTempFile();
                         NestedJarFile library = new NestedJarFile(earFile, entry.getName());
                         earContext.addIncludeAsPackedJar(URI.create(entry.getName()), library);
                         libClasspath.add(entry.getName());
@@ -921,6 +922,7 @@ public class EARConfigBuilder implements
 
                         NestedJarFile moduleFile;
                         try {
+                            JarUtils.assertTempFile();
                             moduleFile = new NestedJarFile(earFile, modulePath);
                         } catch (IOException e) {
                             throw new DeploymentException("Invalid moduleFile: " + modulePath,
e);
@@ -964,6 +966,7 @@ public class EARConfigBuilder implements
                             moduleTypeName = "a connector";
                         } else if (entry.getName().endsWith(".jar") && !isLibraryEntry(application,
entry)) {
                             try {
+                                JarUtils.assertTempFile();
                                 NestedJarFile moduleFile = new NestedJarFile(earFile, entry.getName());
                                 Manifest mf = moduleFile.getManifest();
 
@@ -1008,6 +1011,7 @@ public class EARConfigBuilder implements
 
                         NestedJarFile moduleFile;
                         try {
+                            JarUtils.assertTempFile();
                             moduleFile = new NestedJarFile(earFile, entry.getName());
                         } catch (IOException e) {
                             throw new DeploymentException("Invalid moduleFile: " + entry.getName(),
e);
@@ -1090,6 +1094,7 @@ public class EARConfigBuilder implements
                     String modulePath = gerExtModule.getInternalPath().trim();
                     applicationInfo.getModuleLocations().add(modulePath);
                     try {
+                        JarUtils.assertTempFile();
                         moduleFile = new NestedJarFile(earFile, modulePath);
                     } catch (IOException e) {
                         throw new DeploymentException("Invalid moduleFile: " + modulePath,
e);
@@ -1155,6 +1160,7 @@ public class EARConfigBuilder implements
             ZipEntry entry = entries.nextElement();
             if (entry.getName().endsWith(".jar") && isLibraryEntry(application, entry))
{
                 try {
+                    JarUtils.assertTempFile();
                     NestedJarFile moduleFile = new NestedJarFile(earFile, entry.getName());
 
                     if (moduleFile.getEntry("META-INF/beans.xml") == null) continue;



Mime
View raw message