GERONIMO-6364 jaxws-catalog-tests test failed for UnknownHostExceptiion
Since Geronimo installs the whole ear as one bundle now, there may be issues while reading wsdl and jax-ws-catalog.xml file. Now the solution is that,
for WAR in EAR, as the WAR will be extracted, we will add the module directory prefix for those files, so that bundle.getEntry could work.
for EJB in EAR, the url will be something like ejb.jar!/META-INF/a.wsdl, we will try to build a jar URL to get the resource, one thing that needs to improve is that, this kind of URL will cause a full copy of the target jar file, as JarURLHandler may not recognize the bundleentry protocol.

git-svn-id: https://svn.apache.org/repos/asf/geronimo/server/trunk@1349684 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java b/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
index 9c7bb43..54b1ac0 100644
--- a/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
+++ b/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceContainer.java
@@ -52,8 +52,9 @@
                                   Context context,
                                   Axis2ModuleRegistry axis2ModuleRegistry,
                                   BeanContext deploymnetInfo,
-                                  String ejbModuleName) {
-        super(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry, ejbModuleName);
+                                  String ejbModuleName,
+                                  String catalogName) {
+        super(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry, ejbModuleName, catalogName);
         this.deploymnetInfo = deploymnetInfo;
     }
 
@@ -98,7 +99,7 @@
     @Override
     protected AxisServiceGenerator createServiceGenerator() {
         AxisServiceGenerator serviceGenerator = super.createServiceGenerator();
-        serviceGenerator.setCatalogName(JAXWSUtils.DEFAULT_CATALOG_EJB);
+        serviceGenerator.setCatalogName(catalogName);
         EJBMessageReceiver messageReceiver =
             new EJBMessageReceiver(this, this.endpointClass, this.deploymnetInfo);
         serviceGenerator.setMessageReceiver(messageReceiver);
diff --git a/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java b/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java
index 83a7916..c5b8d7d 100644
--- a/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java
+++ b/plugins/axis2/geronimo-axis2-ejb/src/main/java/org/apache/geronimo/axis2/ejb/EJBWebServiceGBean.java
@@ -62,7 +62,8 @@
                               @ParamAttribute(name="realmName")String realmName,
                               @ParamAttribute(name="authMethod")String authMethod,
                               @ParamAttribute(name="virtualHosts")String[] virtualHosts,
-                              @ParamAttribute(name="properties")Properties properties) throws Exception {
+                              @ParamAttribute(name="properties")Properties properties,
+                              @ParamAttribute(name="catalogName")String catalogName) throws Exception {
 
         if (ejbDeploymentContext == null || webContainers == null || webContainers.isEmpty() || portInfo == null) {
             return;
@@ -78,7 +79,7 @@
         BeanContext deploymnetInfo = ejbDeploymentContext.getDeploymentInfo();
         Context context = deploymnetInfo.getJndiEnc();
 
-        this.container = new EJBWebServiceContainer(portInfo, beanClassName, bundle, context, axis2ModuleRegistry, deploymnetInfo, abName.getNameProperty(NameFactory.EJB_MODULE));
+        this.container = new EJBWebServiceContainer(portInfo, beanClassName, bundle, context, axis2ModuleRegistry, deploymnetInfo, abName.getNameProperty(NameFactory.EJB_MODULE), catalogName);
         this.container.init();
 
         soapHandler.addWebService(this.location,
diff --git a/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java b/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
index 95459c7..dedf13a 100644
--- a/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
+++ b/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
@@ -135,8 +135,10 @@
     protected Axis2ModuleRegistry axis2ModuleRegistry;
 
     protected String moduleName;
+    
+    protected String catalogName;
 
-    public Axis2WebServiceContainer(PortInfo portInfo, String endpointClassName, Bundle bundle, Context context, Axis2ModuleRegistry axis2ModuleRegistry, String moduleName) {
+    public Axis2WebServiceContainer(PortInfo portInfo, String endpointClassName, Bundle bundle, Context context, Axis2ModuleRegistry axis2ModuleRegistry, String moduleName, String catalogName) {
         this.endpointClassName = endpointClassName;
         this.portInfo = portInfo;
         this.bundle = bundle;
@@ -144,6 +146,7 @@
         this.jndiResolver = new ServerJNDIResolver(context);
         this.axis2ModuleRegistry = axis2ModuleRegistry;
         this.moduleName = moduleName;
+        this.catalogName = catalogName;
     }
 
     public void init() throws Exception {
@@ -395,7 +398,7 @@
             // wsdl or xsd request
 
             if (portInfo.getWsdlFile() != null && !portInfo.getWsdlFile().equals("")) {
-                URL wsdlURL = AxisServiceGenerator.getWsdlURL(portInfo.getWsdlFile(), bundle);
+                URL wsdlURL = JAXWSUtils.getWsdlURL(bundle, portInfo.getWsdlFile());
                 this.wsdlQueryHandler.writeResponse(request.getURI().toString(), wsdlURL.toString(), response.getOutputStream());
             } else {
                 throw new Exception("Service does not have WSDL");
diff --git a/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java b/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
index e11ea0a..2663531 100644
--- a/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
+++ b/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/AxisServiceGenerator.java
@@ -162,7 +162,7 @@
             //instance, we will call the parseCatalog(URL) to add the file
             //catalogManager.setCatalogFiles(catalogURL.toString());
         }
-        URL wsdlURL = getWsdlURL(wsdlFile, bundle);
+        URL wsdlURL = JAXWSUtils.getWsdlURL(bundle, wsdlFile);
         WSDL4JWrapper wsdlWrapper = new WSDL4JWrapper(wsdlURL, this.configurationContext, catalogManager);
         Definition wsdlDefinition = wsdlWrapper.getDefinition();
 
@@ -327,30 +327,7 @@
             composite.setWsdlDefinition(testMap);
             return composite;
         }
-    }
-
-    public static URL getWsdlURL(String wsdlFile, Bundle bundle) {
-        if (wsdlFile == null) {
-            return null;
-        }
-        URL wsdlURL;
-        try {
-            wsdlURL = BundleUtils.getEntry(bundle, wsdlFile);
-        } catch (MalformedURLException e) {
-            log.warn("MalformedURLException when getting entry:" + wsdlFile + " from bundle " + bundle.getSymbolicName(), e);
-            wsdlURL = null;
-        }
-        if (wsdlURL == null) {
-            wsdlURL = bundle.getResource(wsdlFile);
-            if (wsdlURL == null) {
-                try {
-                    wsdlURL = new URL(wsdlFile);
-                } catch (MalformedURLException e) {
-                }
-            }
-        }
-        return wsdlURL;
-    }
+    }    
 
     public static EndpointDescription getEndpointDescription(AxisService service) {
         Parameter param = service.getParameter(EndpointDescription.AXIS_SERVICE_PARAMETER);
diff --git a/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java b/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
index 5268c2f..0626149 100644
--- a/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
+++ b/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ServiceReference.java
@@ -17,6 +17,7 @@
 
 package org.apache.geronimo.axis2.client;
 
+import java.io.IOException;
 import java.net.URI;
 import java.net.URL;
 import java.util.Map;
@@ -37,6 +38,7 @@
 import org.apache.geronimo.jaxws.client.PortMethodInterceptor;
 import org.apache.geronimo.jaxws.handler.GeronimoHandlerResolver;
 import org.apache.geronimo.jaxws.info.HandlerChainsInfo;
+import org.apache.xml.resolver.Catalog;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -65,7 +67,14 @@
         if (catalogURL != null) {
             composite = new DescriptionBuilderComposite();
             OASISCatalogManager catalogManager = new OASISCatalogManager();
-            catalogManager.setCatalogFiles(catalogURL.toString());
+            Catalog catalog = catalogManager.getCatalog();
+            try {
+                catalog.parseCatalog(catalogURL);
+            } catch (IOException e) {
+                NamingException toThrow = new NamingException("Fail to parse catalog file " + catalogURL.toString());
+                toThrow.initCause(e);
+                throw toThrow;
+            }            
             composite.setCatalogManager(catalogManager);
         }
 
diff --git a/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java b/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
index 7b4e666..4fe67d9 100644
--- a/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
+++ b/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainer.java
@@ -64,8 +64,9 @@
                                    Axis2ModuleRegistry axis2ModuleRegistry,
                                    AnnotationHolder holder,
                                    String contextRoot,
-                                   String moduleName) {
-        super(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry, moduleName);
+                                   String moduleName,
+                                   String catalogName) {
+        super(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry, moduleName, catalogName);
         this.holder = holder;
         this.contextRoot = contextRoot;
     }
@@ -117,7 +118,7 @@
     @Override
     protected AxisServiceGenerator createServiceGenerator() {
         AxisServiceGenerator serviceGenerator = super.createServiceGenerator();
-        serviceGenerator.setCatalogName(JAXWSUtils.DEFAULT_CATALOG_WEB);
+        serviceGenerator.setCatalogName(catalogName);
         return serviceGenerator;
     }
 
diff --git a/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java b/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
index 1c2043d..e35d9d7 100644
--- a/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
+++ b/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
@@ -60,6 +60,7 @@
     private Bundle bundle;
     private Axis2ModuleRegistry axis2ModuleRegistry;
     private String webModuleName;
+    private String catalogName;
 
     public POJOWebServiceContainerFactoryGBean(
                         @ParamAttribute(name="portInfo") PortInfo portInfo,
@@ -68,6 +69,7 @@
                         @ParamReference(name="TransactionManager", namingType=NameFactory.JTA_RESOURCE) TransactionManager transactionManager,
                         @ParamAttribute(name="holder") AnnotationHolder holder,
                         @ParamAttribute(name="contextRoot") String contextRoot,
+                        @ParamAttribute(name="catalogName") String catalogName,
                         @ParamReference(name="Axis2ModuleRegistry") Axis2ModuleRegistry axis2ModuleRegistry,
                         @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
                         @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle,
@@ -94,10 +96,11 @@
         this.contextRoot = contextRoot;
         this.axis2ModuleRegistry = axis2ModuleRegistry;
         this.webModuleName = abName.getNameProperty(NameFactory.WEB_MODULE);
+        this.catalogName = catalogName;
     }
 
     public WebServiceContainer getWebServiceContainer() {
-        POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry, holder, contextRoot, webModuleName);
+        POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName, bundle, context, axis2ModuleRegistry, holder, contextRoot, webModuleName, catalogName);
         try {
             container.init();
         } catch (Exception e) {
diff --git a/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java b/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java
index 2415600..e925f32 100644
--- a/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java
+++ b/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2WebServiceContainerTest.java
@@ -28,6 +28,7 @@
 
 import org.apache.geronimo.axis2.osgi.Axis2ModuleRegistry;
 import org.apache.geronimo.axis2.pojo.POJOWebServiceContainer;
+import org.apache.geronimo.jaxws.JAXWSUtils;
 import org.apache.geronimo.jaxws.PortInfo;
 import org.apache.geronimo.jaxws.annotations.AnnotationHolder;
 import org.apache.geronimo.kernel.osgi.MockBundle;
@@ -77,7 +78,7 @@
 
         String endpointClassName = "org.apache.geronimo.axis2.testdata.simple.HelloWorld";
         Bundle mockBundle = new MockBundle(cl, null, 11L);
-        POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName, mockBundle, null, new Axis2ModuleRegistry(mockBundle.getBundleContext()), AnnotationHolder.EMPTY, "/axis2", "TestWebModuleName");
+        POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endpointClassName, mockBundle, null, new Axis2ModuleRegistry(mockBundle.getBundleContext()), AnnotationHolder.EMPTY, "/axis2", "TestWebModuleName", JAXWSUtils.DEFAULT_CATALOG_WEB);
         container.init();
         container.invoke(req, res);
         out.flush();
@@ -152,7 +153,7 @@
                 Axis2Response res = new Axis2Response("text/xml; charset=utf-8", "127.0.0.1", null, null, 8080, out);
                 Bundle mockBundle = new MockBundle(cl, null, 11L);
                 POJOWebServiceContainer container = new POJOWebServiceContainer(portInfo, endPointClassName, mockBundle, null, new Axis2ModuleRegistry(mockBundle.getBundleContext()),
-                        AnnotationHolder.EMPTY, "/axis2","TestWebModuleName");
+                        AnnotationHolder.EMPTY, "/axis2","TestWebModuleName", JAXWSUtils.DEFAULT_CATALOG_WEB);
                 container.init();
                 container.invoke(req, res);
                 System.out.println("Response "+out);
diff --git a/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSBuilderUtils.java b/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSBuilderUtils.java
index 1c25010..9d2475c 100644
--- a/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSBuilderUtils.java
+++ b/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSBuilderUtils.java
@@ -23,7 +23,8 @@
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 
-public class JAXWSBuilderUtils {    
+public class JAXWSBuilderUtils {
+
     private static boolean isURL(String name) {
         try {
             new URL(name);
@@ -37,22 +38,58 @@
         // is Absolute URL path
         if (isURL(wsdlLocation)) return wsdlLocation;
         
+        Module parentModule = module.getParentModule();
+
+        if(parentModule == null) {
+            return wsdlLocation;
+        }
+
         // EAR
         //   L WAR
-        if (module.getType().equals(ConfigurationModuleType.WAR) && module.getParentModule() != null && module.getParentModule().getType().equals(ConfigurationModuleType.EAR))
+        if (module.getType().equals(ConfigurationModuleType.WAR) && parentModule.getType().equals(ConfigurationModuleType.EAR))
             return module.getTargetPathURI().resolve(wsdlLocation).toString();
         
         // EAR 
         //   L WAR
         //       L EJB
-        if (module.getType().equals(ConfigurationModuleType.EJB) && module.getParentModule() != null && module.getParentModule().getType().equals(ConfigurationModuleType.WAR)
-                && module.getParentModule().getParentModule() != null && module.getParentModule().getParentModule().getType().equals(ConfigurationModuleType.EAR))
-            return module.getParentModule().getTargetPathURI().resolve(wsdlLocation).toString();
+        if (module.getType().equals(ConfigurationModuleType.EJB) && parentModule.getType().equals(ConfigurationModuleType.WAR)
+                && parentModule.getParentModule() != null && parentModule.getParentModule().getType().equals(ConfigurationModuleType.EAR))
+            return parentModule.getTargetPathURI().resolve(wsdlLocation).toString();
         
-            
+        // EAR
+        //   L EJB
+        if(module.getType().equals(ConfigurationModuleType.EJB) && parentModule.getType().equals(ConfigurationModuleType.EAR)) {
+            return module.getModuleURI().toString() + "!/" + wsdlLocation;
+        }
+
         return wsdlLocation;
     }
     
+    public static String normalizeCatalogPath(Module module, String catalogName) {
+        if(isURL(catalogName)) {
+            return catalogName;
+        }
+
+        Module parentModule = module.getParentModule();
+
+        if(parentModule == null) {
+            return catalogName;
+        }
+        // EAR
+        // L WAR
+        if(module.getType().equals(ConfigurationModuleType.WAR) && parentModule.getType().equals(ConfigurationModuleType.EAR)) {
+            return module.getTargetPathURI().resolve(catalogName).toString();
+        }
+        
+        // EAR
+        //   L EJB
+        if(module.getType().equals(ConfigurationModuleType.EJB) && parentModule.getType().equals(ConfigurationModuleType.EAR)) {
+            return module.getModuleURI().toString() + "!/" + catalogName;
+        }
+
+        return catalogName;
+    }
+    
     private static boolean isURL(URI name) {
         try {
             name.toURL();
diff --git a/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java b/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
index 45449e3..da16c84 100644
--- a/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
+++ b/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
@@ -17,6 +17,7 @@
 
 package org.apache.geronimo.jaxws.builder;
 
+import java.io.BufferedInputStream;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.HashMap;
@@ -93,7 +94,7 @@
         if (wsDDUrl != null) {
             InputStream in = null;
             try {
-                in = wsDDUrl.openStream();
+                in = new BufferedInputStream(wsDDUrl.openStream());
 
                 Webservices wst = (Webservices) JaxbJavaee.unmarshalJavaee(Webservices.class, in);
                 for (WebserviceDescription desc : wst.getWebserviceDescription()) {
@@ -303,6 +304,7 @@
         containerFactoryData.setAttribute("componentContext", componentContext);
         containerFactoryData.setAttribute("holder", serviceHolder);
         containerFactoryData.setAttribute("contextRoot", ((WebModule) module).getContextRoot());
+        containerFactoryData.setAttribute("catalogName", JAXWSBuilderUtils.normalizeCatalogPath(module, JAXWSUtils.DEFAULT_CATALOG_WEB));
         try {
             context.addGBean(containerFactoryData);
         } catch (GBeanAlreadyExistsException e) {
@@ -375,6 +377,8 @@
 
         targetGBean.setAttribute("portInfo", portInfo);
 
+        targetGBean.setAttribute("catalogName", JAXWSBuilderUtils.normalizeCatalogPath(module, JAXWSUtils.DEFAULT_CATALOG_EJB));
+
         initialize(targetGBean, beanClass, portInfo, module, bundle);
 
         return true;
diff --git a/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java b/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
index 7a4db739..4051a3c 100644
--- a/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
+++ b/plugins/jaxws/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/JAXWSUtils.java
@@ -19,6 +19,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
@@ -312,23 +313,82 @@
         if (catalogName == null) {
             return null;
         }
-        LOG.debug("Checking for {} catalog in classloader", catalogName);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Checking for {} catalog in classloader", catalogName);
+        }
         URL catalogURL = bundle.getResource(catalogName);
         if (catalogURL == null ) {
             try {
-                LOG.debug("Checking for {} catalog in module directory", catalogName);
-                URL tmpCatalogURL = BundleUtils.getEntry(bundle, catalogName);
-                if (tmpCatalogURL != null) {
-                    tmpCatalogURL.openStream().close();
-                    catalogURL = tmpCatalogURL;
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Checking for {} catalog in module directory", catalogName);
+                }
+                int jarSeparatorIndex = catalogName.indexOf("!/"); 
+                if (jarSeparatorIndex != -1 && jarSeparatorIndex < (catalogName.length() - 2)) {
+                    String jarFileName = catalogName.substring(0,jarSeparatorIndex);
+                    URL jarFileURL = bundle.getEntry(jarFileName);
+                    if(jarFileURL != null) {
+                        return new URL("jar:" + jarFileURL + "!/" + catalogName.substring(jarSeparatorIndex +2));
+                    }
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("Not found the entry {} in the bundle {}", jarFileName, bundle.getLocation());
+                    }
+                } else {
+                    URL tmpCatalogURL = BundleUtils.getEntry(bundle, catalogName);
+                    if (tmpCatalogURL != null) {
+                        tmpCatalogURL.openStream().close();
+                        catalogURL = tmpCatalogURL;
+                    }
                 }
             } catch (FileNotFoundException e) {
-                LOG.debug("Catalog {} is not present in the module", catalogName);
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Catalog {} is not present in the module", catalogName);
+                }
             } catch (IOException e) {
-                LOG.warn("Failed to open catalog file: " + catalogURL, e);
+                if (LOG.isDebugEnabled()) {
+                    LOG.warn("Failed to open catalog file: " + catalogURL, e);
+                }
             }
         }
         return catalogURL;
     }
 
+    public static URL getWsdlURL(Bundle bundle, String wsdlFile) {
+        if (wsdlFile == null) {
+            return null;
+        }
+        URL wsdlURL = null;
+        try {
+            /**
+             * Geronimo now installs the whole EAR as one bundle, and the nested WARs are extracted, while EJB are left as Jar files.
+             * If the WSDL file is included in the EJB, it is required to get the Jar file entry firstly, then use jar protocol to load the WSDL
+             * file.
+             */
+            int jarSeparatorIndex = wsdlFile.indexOf("!/");
+            if (jarSeparatorIndex != -1 && jarSeparatorIndex < (wsdlFile.length() - 2)) {
+                String jarFileName = wsdlFile.substring(0, jarSeparatorIndex);
+                URL jarFileURL = bundle.getEntry(jarFileName);
+                if (jarFileURL != null) {
+                    wsdlURL = new URL("jar:" + jarFileURL + "!/" + wsdlFile.substring(jarSeparatorIndex + 2));
+                }
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Not found the entry {} in the bundle {}", jarFileName, bundle.getLocation());
+                }
+            } else {
+                wsdlURL = BundleUtils.getEntry(bundle, wsdlFile);
+            }
+        } catch (MalformedURLException e) {
+            LOG.warn("MalformedURLException when getting entry:" + wsdlFile + " from bundle " + bundle.getSymbolicName(), e);
+            wsdlURL = null;
+        }
+        if (wsdlURL == null) {
+            wsdlURL = bundle.getResource(wsdlFile);
+            if (wsdlURL == null) {
+                try {
+                    wsdlURL = new URL(wsdlFile);
+                } catch (MalformedURLException e) {
+                }
+            }
+        }
+        return wsdlURL;
+    }
 }
diff --git a/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/GeronimoAnnotationDeployer.java b/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/GeronimoAnnotationDeployer.java
index 03ef784..6d66246 100644
--- a/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/GeronimoAnnotationDeployer.java
+++ b/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/GeronimoAnnotationDeployer.java
@@ -20,12 +20,7 @@
 
 package org.apache.geronimo.openejb.deployment;
 
-import org.apache.openejb.OpenEJBException;
 import org.apache.openejb.config.AnnotationDeployer;
-import org.apache.openejb.config.AppModule;
-import org.apache.openejb.config.EnvEntriesPropertiesDeployer;
-import org.apache.openejb.jee.JndiConsumer;
-import org.apache.xbean.finder.ClassFinder;
 
 /**
  * @version $Rev$ $Date$