geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r514188 - in /geronimo/server/trunk/modules/geronimo-tomcat6-builder/src: main/java/org/apache/geronimo/tomcat/deployment/ test/java/org/apache/geronimo/tomcat/deployment/ test/resources/deployables/war-no-dd/ test/resources/deployables/war...
Date Sat, 03 Mar 2007 16:47:35 GMT
Author: jgenender
Date: Sat Mar  3 08:47:34 2007
New Revision: 514188

URL: http://svn.apache.org/viewvc?view=rev&rev=514188
Log:
GERONIMO-2921 - Force the Tomcat builder to create a default web.xml if one does not already
exist

Added:
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceContainer.java
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war-no-dd/
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war-no-dd/WEB-INF/
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war-no-dd/WEB-INF/mywsdl.wsdl
Modified:
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceBuilder.java
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?view=diff&rev=514188&r1=514187&r2=514188
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Sat Mar  3 08:47:34 2007
@@ -20,7 +20,9 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.FileWriter;
 import java.net.URL;
+import java.net.MalformedURLException;
 import java.security.Permission;
 import java.security.PermissionCollection;
 import java.security.Permissions;
@@ -81,8 +83,12 @@
 import org.apache.geronimo.xbeans.javaee.ServletType;
 import org.apache.geronimo.xbeans.javaee.WebAppDocument;
 import org.apache.geronimo.xbeans.javaee.WebAppType;
+import org.apache.geronimo.xbeans.javaee.ServletMappingType;
+import org.apache.geronimo.xbeans.javaee.impl.WebAppDocumentImpl;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+import org.apache.xmlbeans.XmlCursor;
 
 /**
  * @version $Rev:385659 $ $Date$
@@ -97,13 +103,13 @@
     private static final String TOMCAT_NAMESPACE = TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI();
 
     public TomcatModuleBuilder(Environment defaultEnvironment,
-            AbstractNameQuery tomcatContainerName,
-            Collection webServiceBuilder,
-            Collection securityBuilders,
-            Collection serviceBuilders,
-            NamingBuilder namingBuilders,
-            ResourceEnvironmentSetter resourceEnvironmentSetter,
-            Kernel kernel) {
+                               AbstractNameQuery tomcatContainerName,
+                               Collection webServiceBuilder,
+                               Collection securityBuilders,
+                               Collection serviceBuilders,
+                               NamingBuilder namingBuilders,
+                               ResourceEnvironmentSetter resourceEnvironmentSetter,
+                               Kernel kernel) {
         super(kernel, securityBuilders, serviceBuilders, namingBuilders, resourceEnvironmentSetter,
webServiceBuilder);
         this.defaultEnvironment = defaultEnvironment;
 
@@ -125,13 +131,17 @@
 
             // read in the entire specDD as a string, we need this for getDeploymentDescriptor
             // on the J2ee management object
-            specDD = DeploymentUtil.readAll(specDDUrl);
+            try {
+                specDD = DeploymentUtil.readAll(specDDUrl);
 
-            // we found web.xml, if it won't parse that's an error.
-            XmlObject parsed = XmlBeansUtil.parse(specDD);
-            WebAppDocument webAppDoc = convertToServletSchema(parsed);
-            webApp = webAppDoc.getWebApp();
-            check(webApp);
+                // we found web.xml, if it won't parse that's an error.
+                XmlObject parsed = XmlBeansUtil.parse(specDD);
+                WebAppDocument webAppDoc = convertToServletSchema(parsed);
+                webApp = webAppDoc.getWebApp();
+                check(webApp);
+            } catch (FileNotFoundException fnfe) {
+                webApp = WebAppType.Factory.newInstance();
+            }
         } catch (XmlException e) {
             // Output the target path in the error to make it clearer to the user which webapp
             // has the problem.  The targetPath is used, as moduleFile may have an unhelpful
@@ -144,10 +154,6 @@
             }
             //else ignore as jee5 allows optional spec dd for .war's
         }
-        
-        if (webApp == null) {
-            webApp = WebAppType.Factory.newInstance();
-        }
 
         // parse vendor dd
         TomcatWebAppType tomcatWebApp = getTomcatWebApp(plan, moduleFile, standAlone, targetPath,
webApp);
@@ -268,6 +274,37 @@
         WebModule webModule = (WebModule) module;
 
         WebAppType webApp = (WebAppType) webModule.getSpecDD();
+
+        /**
+         * This next bit of code is kind of a kludge to get Tomcat to get a default
+         * web.xml if one does not exist.  This is primarily for jaxws.  This code is
+         * necessary because Tomcat either has a bug or there is a problem dynamically
+         * adding a wrapper to an already running context.  Although the wrapper
+         * can be added, the url mappings do not get picked up at the proper level
+         * and therefore Tomcat cannot dispatch the request.  Hence, creating and
+         * writing out a web.xml to the deployed location is the only way around this
+         * until Tomcat fixes that bug.
+         */
+        File webXml = new File(moduleContext.getBaseDir(), "/WEB-INF/web.xml");
+        if (!webXml.exists()) {
+            try {
+                FileWriter outFile = new FileWriter(webXml);
+
+                XmlOptions opts = new XmlOptions();
+                opts.setUseDefaultNamespace();
+                opts.setSavePrettyPrint();
+
+                WebAppDocument doc = WebAppDocument.Factory.newInstance();
+                doc.setWebApp(webApp);
+                
+                outFile.write(doc.xmlText(opts));
+                outFile.flush();
+                outFile.close();
+            } catch (Exception e) {
+                throw new DeploymentException(e);
+            }
+        }
+        
         TomcatWebAppType tomcatWebApp = (TomcatWebAppType) webModule.getVendorDD();
 
         GBeanData webModuleData = new GBeanData(moduleName, TomcatWebAppContext.GBEAN_INFO);
@@ -395,6 +432,7 @@
                         //force all the factories to start before the web app that needs
them.
                         webModuleData.addDependency(wsContainerFactoryName);
                     }
+
                 }
             }
 

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceBuilder.java?view=diff&rev=514188&r1=514187&r2=514188
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceBuilder.java
Sat Mar  3 08:47:34 2007
@@ -40,6 +40,7 @@
     public boolean configurePOJO(GBeanData targetGBean, String servletName, Module module,
String seiClassName, DeploymentContext context) throws DeploymentException {
         AbstractName webServiceContainerFactoryName = context.getNaming().createChildName(targetGBean.getAbstractName(),
"webServiceContainer", NameFactory.GERONIMO_SERVICE);
         GBeanData webServiceContainerFactoryGBean = new GBeanData(webServiceContainerFactoryName,
SerializableWebServiceContainerFactoryGBean.GBEAN_INFO);
+        webServiceContainerFactoryGBean.setAttribute("webServiceContainer", new MockWebServiceContainer());
         try {
             context.addGBean(webServiceContainerFactoryGBean);
         } catch (GBeanAlreadyExistsException e) {

Added: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceContainer.java?view=auto&rev=514188
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceContainer.java
(added)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceContainer.java
Sat Mar  3 08:47:34 2007
@@ -0,0 +1,30 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.tomcat.deployment;
+
+import org.apache.geronimo.webservices.WebServiceContainer;
+
+public class MockWebServiceContainer implements WebServiceContainer {
+    public void invoke(Request request, Response response) throws Exception {
+    }
+
+    public void getWsdl(Request req, Response res) throws Exception {
+    }
+
+    public void destroy() {
+    }
+}

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?view=diff&rev=514188&r1=514187&r2=514188
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
Sat Mar  3 08:47:34 2007
@@ -22,12 +22,7 @@
 import java.net.URL;
 import java.security.PermissionCollection;
 import java.security.Permissions;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 import org.apache.geronimo.testsupport.TestSupport;
 
@@ -113,7 +108,10 @@
     public void testDeployWar6() throws Exception {
         verifyStartable("war6-jee5");
     }
-    
+
+    public void testDeployWarNoDD() throws Exception {
+        verifyStartable("war-no-dd");
+    }
     public void testContextRootWithSpaces() throws Exception {
         WebModuleInfo info = deployWar("war-spaces-in-context");
         String contextRoot = (String) kernel.getAttribute(info.moduleName, "contextPath");
@@ -139,7 +137,8 @@
         recursiveDelete(outputPath);
         outputPath.mkdirs();
         File path = new File(BASEDIR, "src/test/resources/deployables/" + warName);
-        File dest = new File(BASEDIR, "target/test-resources/deployables/" + warName + "/war");
+        //File dest = new File(BASEDIR, "target/test-resources/deployables/" + warName +
"/war");
+        File dest = new File(BASEDIR, "target/test-resources/deployables/" + warName );
         recursiveCopy(path, dest);
         UnpackedJarFile jarFile = new UnpackedJarFile(path);
         Module module = builder.createModule(null, jarFile, kernel.getNaming(), new ModuleIDBuilder());
@@ -320,6 +319,7 @@
 
         defaultEnvironment.addDependency(baseId, ImportType.ALL);
         defaultEnvironment.setConfigId(webModuleArtifact);
+        ArrayList naming = new ArrayList();
         builder = new TomcatModuleBuilder(defaultEnvironment, new AbstractNameQuery(containerName),
Collections.singleton(webServiceBuilder), Collections.singleton(new GeronimoSecurityBuilderImpl()),
Collections.singleton(new GBeanBuilder(null, null)), new NamingBuilderCollection(null, null),
new MockResourceEnvironmentSetter(), null);
     }
 

Added: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war-no-dd/WEB-INF/mywsdl.wsdl
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war-no-dd/WEB-INF/mywsdl.wsdl?view=auto&rev=514188
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war-no-dd/WEB-INF/mywsdl.wsdl
(added)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war-no-dd/WEB-INF/mywsdl.wsdl
Sat Mar  3 08:47:34 2007
@@ -0,0 +1,124 @@
+?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<wsdl:definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:tns="http://apache.org/greeter_control"
+    xmlns:x1="http://apache.org/greeter_control/types"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    targetNamespace="http://apache.org/greeter_control" name="HelloWorld">
+    <wsdl:types>
+        <schema targetNamespace="http://apache.org/greeter_control/types"
+            xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
+            <element name="sayHi">
+                <complexType/>
+            </element>
+            <element name="sayHiResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMe">
+                <complexType>
+                    <sequence>
+                        <element name="requestType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMeResponse">
+                <complexType>
+                    <sequence>
+                        <element name="responseType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="greetMeOneWay">
+                <complexType>
+                    <sequence>
+                        <element name="requestType" type="xsd:string"/>
+                    </sequence>
+                </complexType>
+            </element>
+            <element name="pingMe">
+                <complexType/>
+            </element>
+            <element name="pingMeResponse">
+                <complexType/>
+            </element>
+            <element name="faultDetail">
+                <complexType>
+                    <sequence>
+                        <element name="minor" type="xsd:short"/>
+                        <element name="major" type="xsd:short"/>
+                    </sequence>
+                </complexType>
+            </element>
+
+        </schema>
+    </wsdl:types>
+
+
+    <wsdl:message name="greetMeRequest">
+        <wsdl:part element="x1:greetMe" name="in"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeResponse">
+        <wsdl:part element="x1:greetMeResponse" name="out"/>
+    </wsdl:message>
+
+
+    <wsdl:portType name="Greeter">
+
+        <wsdl:operation name="greetMe">
+            <wsdl:input message="tns:greetMeRequest" name="greetMeRequest"/>
+            <wsdl:output message="tns:greetMeResponse" name="greetMeResponse"/>
+        </wsdl:operation>
+
+
+    </wsdl:portType>
+
+
+    <wsdl:binding name="GreeterSOAPBinding" type="tns:Greeter">
+        <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+
+
+        <wsdl:operation name="greetMe">
+            <soap:operation soapAction="" style="document"/>
+            <wsdl:input name="greetMeRequest">
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output name="greetMeResponse">
+                <soap:body use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+
+
+    </wsdl:binding>
+
+    <wsdl:service name="GreeterService">
+        <wsdl:port binding="tns:GreeterSOAPBinding" name="GreeterPort">
+            <soap:address location="http://localhost:8080/SoapContext/GreeterPorttttttttttttttttt"/>
+            <wswa:UsingAddressing xmlns:wswa="http://www.w3.org/2005/08/addressing/wsdl"/>
+        </wsdl:port>
+    </wsdl:service>
+
+
+</wsdl:definitions>



Mime
View raw message