Author: djencks Date: Thu Apr 7 07:58:22 2005 New Revision: 160407 URL: http://svn.apache.org/viewcvs?view=rev&rev=160407 Log: JettyClassloader now makes contents of war available as resources. Use classloader to find wsdl in ws.
Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/PortInfo.java geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/WSDescriptorParser.java geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/AxisWebServiceContainer.java geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyClassLoader.java geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/ClassLoaderTest.java geronimo/trunk/modules/webservices/src/java/org/apache/geronimo/webservices/POJOWebServiceServlet.java Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java (original) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java Thu Apr 7 07:58:22 2005 @@ -128,14 +128,6 @@ HandlerInfoChainFactory handlerInfoChainFactory = new HandlerInfoChainFactory(serviceInfo.getHanlderInfos()); service.setOption(org.apache.axis.Constants.ATTR_HANDLERINFOCHAIN, handlerInfoChainFactory); - URL wsdlURL = null; - try { - wsdlURL = new URL(serviceDesc.getWSDLFile()); - } catch (MalformedURLException e) { - throw new DeploymentException("Invalid URL to the webservice's WSDL file", e); - } - - URI location = null; try { location = new URI(serviceDesc.getEndpointURL()); @@ -144,7 +136,7 @@ } classLoader = new ClassLoaderReference(classLoader); - AxisWebServiceContainer axisWebServiceContainer = new AxisWebServiceContainer(location, wsdlURL, service, classLoader); + AxisWebServiceContainer axisWebServiceContainer = new AxisWebServiceContainer(location, serviceDesc.getWSDLFile(), service, classLoader); //targetGBean.setAttribute("webServiceContainer", axisWebServiceContainer); try { targetGBean.setAttribute("webServiceContainer", new StoredObject(axisWebServiceContainer)); // Hack! Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java (original) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java Thu Apr 7 07:58:22 2005 @@ -157,7 +157,7 @@ URL location = getAddressLocation(port); serviceDesc.setEndpointURL(location.toExternalForm()); - serviceDesc.setWSDLFile(portInfo.getWsdlURL().toExternalForm()); + serviceDesc.setWSDLFile(portInfo.getWsdlLocation()); Binding binding = port.getBinding(); serviceDesc.setStyle(getStyle(binding)); Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java (original) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/HeavyweightOperationDescBuilder.java Thu Apr 7 07:58:22 2005 @@ -150,7 +150,7 @@ built = true; operationDesc.setName(operationName); - + // Set to 'document', 'rpc' or 'wrapped' if (wrappedStype) { operationDesc.setStyle(Style.WRAPPED); @@ -368,10 +368,11 @@ if (complexTypeMap.containsKey(elementType)) { String javaClassName = (String) publicTypes.get(elementTypeQName); javaElementType = getJavaClass(javaClassName); - } else if (qnameToClassMap.containsKey(elementType)) { - javaElementType = (Class) qnameToClassMap.get(elementType); } else { - throw new DeploymentException("Unknown type: " + elementType + " of name: " + elementName); + javaElementType = (Class) qnameToClassMap.get(elementTypeQName); + if (javaElementType == null) { + throw new DeploymentException("Unknown type: " + elementType + " of name: " + elementName + " and QName: " + elementTypeQName); + } } } else { //anonymous type @@ -588,7 +589,7 @@ if (null == operationType) { throw new DeploymentException("No global element named " + name + " for operation " + operationName); } - + // schemaType should be complex using xsd:sequence compositor SchemaParticle parametersType = operationType.getContentModel(); if (SchemaParticle.ELEMENT == parametersType.getParticleType()) { @@ -615,12 +616,12 @@ " is not a sequence for operation " + operationName); } } - + /** * Supporting the Document/Literal Wrapped pattern * * See http://www-106.ibm.com/developerworks/webservices/library/ws-whichwsdl/ for a nice explanation and example - * + * * wrapped-element tag is used * WSDL message with a single part * part uses the 'element' attribute to point to an elemement in the types section Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/PortInfo.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/PortInfo.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/PortInfo.java (original) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/PortInfo.java Thu Apr 7 07:58:22 2005 @@ -16,10 +16,9 @@ */ package org.apache.geronimo.axis.builder; -import java.net.URL; -import javax.xml.namespace.QName; import javax.wsdl.Definition; import javax.wsdl.Port; +import javax.xml.namespace.QName; import org.apache.geronimo.xbeans.j2ee.JavaWsdlMappingType; import org.apache.geronimo.xbeans.j2ee.PortComponentHandlerType; @@ -38,9 +37,9 @@ private final PortComponentHandlerType[] handlers; private final Port port; - private final URL wsdlURL; + private final String wsdlLocation; - public PortInfo(String portName, QName portQName, Definition definition, JavaWsdlMappingType javaWsdlMapping, String seiInterfaceName, PortComponentHandlerType[] handlers, Port port, ServiceEndpointInterfaceMappingType seiMapping, URL wsdlURL) { + public PortInfo(String portName, QName portQName, Definition definition, JavaWsdlMappingType javaWsdlMapping, String seiInterfaceName, PortComponentHandlerType[] handlers, Port port, ServiceEndpointInterfaceMappingType seiMapping, String wsdlLocation) { this.portName = portName; this.portQName = portQName; this.definition = definition; @@ -49,11 +48,11 @@ this.handlers = handlers; this.port = port; this.seiMapping = seiMapping; - this.wsdlURL = wsdlURL; + this.wsdlLocation = wsdlLocation; } - public URL getWsdlURL() { - return wsdlURL; + public String getWsdlLocation() { + return wsdlLocation; } public String getPortName() { Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/WSDescriptorParser.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/WSDescriptorParser.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/WSDescriptorParser.java (original) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/WSDescriptorParser.java Thu Apr 7 07:58:22 2005 @@ -21,7 +21,6 @@ import java.lang.reflect.Method; import java.math.BigDecimal; import java.math.BigInteger; -import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -66,7 +65,6 @@ import javax.xml.rpc.holders.StringHolder; import org.apache.geronimo.common.DeploymentException; -import org.apache.geronimo.deployment.util.DeploymentUtil; import org.apache.geronimo.kernel.ClassLoading; import org.apache.geronimo.schema.SchemaConversionUtils; import org.apache.geronimo.xbeans.j2ee.ExceptionMappingType; @@ -167,14 +165,9 @@ ServiceEndpointInterfaceMappingType seiMapping = (ServiceEndpointInterfaceMappingType) seiMappings.get(seiInterfaceName); - URL wsdlURL = null; - try { - wsdlURL = DeploymentUtil.createJarURL(moduleFile, webserviceDescription.getWsdlFile().getStringValue().trim()); - } catch (MalformedURLException e) { - throw new DeploymentException("Invalid WSDL URL: " + webserviceDescription.getWsdlFile().getStringValue().trim(), e); - } + String wsdlLocation = webserviceDescription.getWsdlFile().getStringValue().trim(); - PortInfo portInfo = new PortInfo(portComponentName, portQName, definition, javaWsdlMapping, seiInterfaceName, handlers, port, seiMapping, wsdlURL); + PortInfo portInfo = new PortInfo(portComponentName, portQName, definition, javaWsdlMapping, seiInterfaceName, handlers, port, seiMapping, wsdlLocation); if (portMap.put(linkName, portInfo) != null) { throw new DeploymentException("Ambiguous description of port associated with j2ee component " + linkName); Modified: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/AxisWebServiceContainer.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/AxisWebServiceContainer.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/AxisWebServiceContainer.java (original) +++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/AxisWebServiceContainer.java Thu Apr 7 07:58:22 2005 @@ -19,10 +19,8 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URI; -import java.net.URL; import java.util.Iterator; import java.util.Map; - import javax.servlet.http.HttpServletResponse; import javax.wsdl.Definition; import javax.wsdl.Port; @@ -30,6 +28,7 @@ import javax.wsdl.extensions.ExtensibilityElement; import javax.wsdl.extensions.soap.SOAPAddress; import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLLocator; import javax.wsdl.xml.WSDLReader; import javax.wsdl.xml.WSDLWriter; import javax.xml.soap.SOAPException; @@ -49,30 +48,31 @@ import org.apache.commons.logging.LogFactory; import org.apache.geronimo.webservices.WebServiceContainer; import org.w3c.dom.Element; +import org.xml.sax.InputSource; /** * @version $Rev$ $Date$ */ public class AxisWebServiceContainer implements WebServiceContainer { - public static final String REQUEST = AxisWebServiceContainer.class.getName()+"@Request"; - public static final String RESPONSE = AxisWebServiceContainer.class.getName()+"@Response"; + public static final String REQUEST = AxisWebServiceContainer.class.getName() + "@Request"; + public static final String RESPONSE = AxisWebServiceContainer.class.getName() + "@Response"; private static Log log = LogFactory.getLog(AxisWebServiceContainer.class); public static final String XSD_NS = "http://www.w3.org/2001/XMLSchema"; private final URI location; - private final URL wsdlURL; + private final String wsdlLocation; private final SOAPService service; - + private final ClassLoader classLoader; - private final Byte wsdlMutext = new Byte((byte)0); + private final Byte wsdlMutext = new Byte((byte) 0); private transient Definition definition; private transient WSDLWriter wsdlWriter; - public AxisWebServiceContainer(URI location, URL wsdlURL, SOAPService service, ClassLoader classLoader) { + public AxisWebServiceContainer(URI location, String wsdlURL, SOAPService service, ClassLoader classLoader) { this.location = location; - this.wsdlURL = wsdlURL; + this.wsdlLocation = wsdlURL; this.service = service; this.classLoader = classLoader; } @@ -82,7 +82,7 @@ req.setAttribute(MESSAGE_CONTEXT, context); context.setClassLoader(classLoader); - + Message responseMessage = null; String contentType = req.getHeader(HTTPConstants.HEADER_CONTENT_TYPE); @@ -120,7 +120,7 @@ Thread.currentThread().setContextClassLoader(classLoader); service.invoke(context); - + responseMessage = context.getResponseMessage(); } catch (AxisFault fault) { responseMessage = handleFault(fault, res, context); @@ -196,17 +196,17 @@ } return responseMessage; } - + public void getWsdl(Request request, Response response) throws Exception { - + // Avoid concurrent modification of the WSDL dom. - synchronized(wsdlMutext) { - - // Read in the the WSDL in once. - if( definition == null ) { + synchronized (wsdlMutext) { + + // Read in the the WSDL in once. + if (definition == null) { initWSDLDom(); } - + // Update all the service port soap address elements. Map services = definition.getServices(); for (Iterator iter1 = services.values().iterator(); iter1.hasNext();) { @@ -216,14 +216,13 @@ Port port = (Port) iter2.next(); for (Iterator iter3 = port.getExtensibilityElements().iterator(); iter3.hasNext();) { ExtensibilityElement element = (ExtensibilityElement) iter3.next(); - if (element instanceof SOAPAddress ) { - SOAPAddress soapAddress = (SOAPAddress)element; - URI realLocation = request.getURI(); + if (element instanceof SOAPAddress) { + SOAPAddress soapAddress = (SOAPAddress) element; + URI realLocation = request.getURI(); // We replace the host and port here. - URI updated = new URI( - realLocation.getScheme(), - realLocation.getUserInfo(), - realLocation.getHost(), + URI updated = new URI(realLocation.getScheme(), + realLocation.getUserInfo(), + realLocation.getHost(), realLocation.getPort(), realLocation.getPath(), // Humm is this right? null, @@ -233,11 +232,11 @@ } } } - + // Dump the WSDL dom to the output stream OutputStream out = response.getOutputStream(); wsdlWriter.writeWSDL(definition, out); - out.close(); +// out.close(); } } @@ -248,14 +247,59 @@ WSDLFactory wsdlFactory = WSDLFactory.newInstance(); wsdlWriter = wsdlFactory.newWSDLWriter(); WSDLReader wsdlReader = wsdlFactory.newWSDLReader(); - definition = wsdlReader.readWSDL(wsdlURL.toExternalForm()); + ResourceWSDLLocator wsdlLocator = new ResourceWSDLLocator(wsdlLocation, Thread.currentThread().getContextClassLoader(), classLoader); + definition = wsdlReader.readWSDL(wsdlLocator); } public URI getLocation() { return location; } - public URL getWsdlURL() { - return wsdlURL; + private static class ResourceWSDLLocator implements WSDLLocator { + + private final String wsdlLocation; + private final ClassLoader classLoader; + private final ClassLoader classLoader2; + + private String latestImportURI; + + public ResourceWSDLLocator(String wsdlLocation, ClassLoader classLoader, ClassLoader classLoader2) { + this.wsdlLocation = wsdlLocation; + this.classLoader = classLoader; + this.classLoader2 = classLoader2; + } + + public InputSource getBaseInputSource() { + InputStream wsdlInputStream = classLoader.getResourceAsStream(wsdlLocation); + if (wsdlInputStream == null) { + wsdlInputStream = classLoader2.getResourceAsStream(wsdlLocation); + if (wsdlInputStream == null) { + throw new IllegalStateException("wsdl not found in classloader at " + wsdlLocation); + } + } + return new InputSource(wsdlInputStream); + } + + public String getBaseURI() { + return wsdlLocation; + } + + public InputSource getImportInputSource(String parentLocation, String relativeLocation) { + URI parentURI = URI.create(parentLocation); + latestImportURI = parentURI.resolve(relativeLocation).toString(); + InputStream importInputStream = classLoader.getResourceAsStream(latestImportURI); + if (importInputStream == null) { + throw new IllegalStateException("wsdl not found in classloader at " + latestImportURI); + } + InputSource inputSource = new InputSource(importInputStream); + inputSource.setSystemId(getLatestImportURI()); + return inputSource; + } + + public String getLatestImportURI() { + return latestImportURI; + } } + + } Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java (original) +++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/AxisWebServiceContainerTest.java Thu Apr 7 07:58:22 2005 @@ -1,12 +1,12 @@ /* * Copyright 2001-2004 The Apache Software Foundation. - * + * * Licensed 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. @@ -15,13 +15,9 @@ */ package org.apache.geronimo.axis; -import java.io.ByteArrayOutputStream; import java.io.InputStream; -import java.io.OutputStream; import java.net.URI; -import java.net.URL; import java.util.HashMap; - import javax.xml.namespace.QName; import org.apache.axis.constants.Style; @@ -34,15 +30,15 @@ import org.apache.axis.handlers.soap.SOAPService; import org.apache.axis.providers.java.RPCProvider; import org.apache.geronimo.axis.server.AxisWebServiceContainer; -import org.apache.geronimo.axis.server.ReadOnlyServiceDesc; import org.apache.geronimo.axis.server.POJOProvider; +import org.apache.geronimo.axis.server.ReadOnlyServiceDesc; import org.apache.geronimo.axis.testData.echosample.EchoBean; import org.apache.geronimo.webservices.WebServiceContainer; //import org.openejb.deployment.OpenEJBModuleBuilder; /** - * + * * @version $Rev: $ $Date: $ */ public class AxisWebServiceContainerTest extends AbstractTestCase { @@ -90,23 +86,15 @@ RPCProvider provider = new POJOProvider(); SOAPService service = new SOAPService(null, provider, null); - service.setServiceDescription(serviceDesc); + service.setServiceDescription(sd); service.setOption("className","org.apache.geronimo.axis.testData.echosample.EchoBean"); - URL wsdlURL = cl.getResource("echo.wsdl"); + String wsdlURL = "echo.wsdl"; URI location = new URI(serviceDesc.getEndpointURL()); - AxisWebServiceContainer axisWebServiceContainer = + AxisWebServiceContainer continaer = new AxisWebServiceContainer(location, wsdlURL, service, cl); - AxisWebServiceContainer continaer = - new AxisWebServiceContainer( - null, - null, - service, - Thread.currentThread().getContextClassLoader()); InputStream in = cl.getResourceAsStream("echoString-req.txt"); - - OutputStream outputStream = new ByteArrayOutputStream(); AxisRequest req = new AxisRequest( Modified: geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java (original) +++ geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java Thu Apr 7 07:58:22 2005 @@ -720,6 +720,12 @@ getWebClassPath(earContext, webModule); URI[] webClassPath = webModule.getWebClasspath(); URI baseUri = earContext.getBaseDir().toURI(); + URL baseUrl = null; + try { + baseUrl = baseUri.resolve(webModule.getTargetPathURI()).toURL(); + } catch (MalformedURLException e) { + throw new DeploymentException("Invalid module location: " + webModule.getTargetPathURI() + ", baseUri: " + baseUri); + } URL[] webClassPathURLs = new URL[webClassPath.length]; for (int i = 0; i < webClassPath.length; i++) { URI path = baseUri.resolve(webClassPath[i]); @@ -730,7 +736,7 @@ } } - ClassLoader webClassLoader = new JettyClassLoader(webClassPathURLs, cl, contextPriorityClassLoader); + ClassLoader webClassLoader = new JettyClassLoader(webClassPathURLs, baseUrl, cl, contextPriorityClassLoader); return webClassLoader; } Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyClassLoader.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyClassLoader.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyClassLoader.java (original) +++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyClassLoader.java Thu Apr 7 07:58:22 2005 @@ -25,13 +25,23 @@ public class JettyClassLoader extends URLClassLoader { private final boolean contextPriorityClassLoader; private final ClassLoader parent; + private final ClassLoader resourceClassLoader; - public JettyClassLoader(URL[] urls, ClassLoader parent, boolean contextPriorityClassLoader) { + public JettyClassLoader(URL[] urls, URL resourceURL, ClassLoader parent, boolean contextPriorityClassLoader) { super(urls, parent); if (parent == null) { throw new IllegalArgumentException("Parent class loader is null"); } + URL[] resourceURLS; + if (resourceURL != null) { + resourceURLS = new URL[urls.length + 1]; + System.arraycopy(urls, 0, resourceURLS, 0, urls.length); + resourceURLS[resourceURLS.length - 1] = resourceURL; + } else { + resourceURLS = urls; + } + resourceClassLoader = new ResourceClassLoader(resourceURLS, parent); // hold on to the parent so we don't have to go throught the security check each time this.parent = parent; @@ -69,23 +79,34 @@ } public URL getResource(String name) { - if (!contextPriorityClassLoader || - name.startsWith("java/") || - name.startsWith("javax/") || - name.startsWith("org/apache/geronimo/") || - name.startsWith("org/mortbay/") || - name.startsWith("org/xml/") || - name.startsWith("org/w3c/")) { - return super.getResource(name); - } + return resourceClassLoader.getResource(name); + } - // try to load the resource from this class loader - URL url = findResource(name); - if (url != null) { - return url; + private class ResourceClassLoader extends URLClassLoader { + + public ResourceClassLoader(URL[] urls, ClassLoader classLoader) { + super(urls, classLoader); } - // that didn't work... try the parent - return parent.getResource(name); + public URL getResource(String name) { + if (!contextPriorityClassLoader || + name.startsWith("java/") || + name.startsWith("javax/") || + name.startsWith("org/apache/geronimo/") || + name.startsWith("org/mortbay/") || + name.startsWith("org/xml/") || + name.startsWith("org/w3c/")) { + return super.getResource(name); + } + + // try to load the resource from this class loader + URL url = findResource(name); + if (url != null) { + return url; + } + + // that didn't work... try the parent + return parent.getResource(name); + } } } Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java (original) +++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java Thu Apr 7 07:58:22 2005 @@ -188,6 +188,7 @@ URI root = URI.create(configurationBaseUrl.toString()); webAppRoot = root.resolve(uri); + URL webAppRootURL = webAppRoot.toURL(); URL[] urls = new URL[webClassPath.length]; for (int i = 0; i < webClassPath.length; i++) { @@ -195,7 +196,7 @@ classPathEntry = root.resolve(classPathEntry); urls[i] = classPathEntry.toURL(); } - this.webClassLoader = new JettyClassLoader(urls, classLoader, contextPriorityClassLoader); + this.webClassLoader = new JettyClassLoader(urls, webAppRootURL, classLoader, contextPriorityClassLoader); setClassLoader(this.webClassLoader); handler = new WebApplicationHandler(); @@ -479,7 +480,7 @@ public static final GBeanInfo GBEAN_INFO; - + static { GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder("Jetty WebApplication Context", JettyWebAppContext.class, NameFactory.WEB_MODULE); infoBuilder.addAttribute("deploymentDescriptor", String.class, true); Modified: geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/ClassLoaderTest.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/ClassLoaderTest.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/ClassLoaderTest.java (original) +++ geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/ClassLoaderTest.java Thu Apr 7 07:58:22 2005 @@ -48,7 +48,7 @@ * parent ClassLoader. This should work. */ public void testFalseNonexistantJavaxClass() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), false); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), false); try { cl.loadClass("javax.foo.Foo"); } catch(ClassNotFoundException e) { @@ -61,7 +61,7 @@ * parent ClassLoader. This should work. */ public void testTrueNonexistantJavaxClass() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), true); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), true); try { cl.loadClass("javax.foo.Foo"); } catch(ClassNotFoundException e) { @@ -75,7 +75,7 @@ * This should always load the parent's copy. */ public void testFalseExistantJavaxClass() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), false); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), false); try { Class cls = cl.loadClass("javax.servlet.Servlet"); assertTrue("Loaded wrong class first; expected to find parent CL's copy of javax.servlet.Servlet",cls.getDeclaredMethods().length > 0); @@ -90,7 +90,7 @@ * This should always load the parent's copy. */ public void testTrueExistantJavaxClass() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), true); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), true); try { Class cls = cl.loadClass("javax.servlet.Servlet"); assertTrue("Loaded wrong class first; expected to find parent CL's copy of javax.servlet.Servlet",cls.getDeclaredMethods().length > 0); @@ -107,7 +107,7 @@ * copy when the contextPriorityClassLoader is set to true. */ public void testFalseExistantNonJavaxClass() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), false); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), false); try { Class cls = cl.loadClass("mx4j.MBeanDescription"); assertTrue("Should not have overriden parent CL definition of class mx4j.MBeanDescription", cls.getDeclaredMethods().length > 0); @@ -124,7 +124,7 @@ * the contextPriorityClassLoader is set to true (as here). */ public void testTrueExistantNonJavaxClass() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), true); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), true); try { Class cls = cl.loadClass("mx4j.MBeanDescription"); assertTrue("Should be able to override a class that is not in java.*, javax.*, etc.", cls.getDeclaredMethods().length == 0); @@ -138,7 +138,7 @@ * parent ClassLoader. This should work. */ public void testFalseNonexistantJavaxResource() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), false); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), false); URL url = cl.getResource("javax/foo/Foo.class"); if(url == null) { fail("Should be able to load a javax.* class that is not defined by my parent CL"); @@ -151,7 +151,7 @@ * parent ClassLoader. This should work. */ public void testTrueNonexistantJavaxResource() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), true); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), true); URL url = cl.getResource("javax/foo/Foo.class"); if(url == null) { fail("Should be able to load a javax.* class that is not defined by my parent CL"); @@ -165,7 +165,7 @@ * This should always load the parent's copy. */ public void testFalseExistantJavaxResource() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), false); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), false); URL url = cl.getResource("javax/servlet/Servlet.class"); if(url == null) { fail("Problem with test; expecting to have javax.servlet.* on the ClassPath"); @@ -179,7 +179,7 @@ * This should always load the parent's copy. */ public void testTrueExistantJavaxResource() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), true); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), true); URL url = cl.getResource("javax/servlet/Servlet.class"); if(url == null) { fail("Problem with test; expecting to have javax.servlet.* on the ClassPath"); @@ -195,7 +195,7 @@ * copy when the contextPriorityClassLoader is set to true. */ public void testFalseExistantNonJavaxResource() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), false); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), false); URL url = cl.getResource("mx4j/MBeanDescription.class"); if(url == null) { fail("Problem with test; expecting to have mx4j.* on the ClassPath"); @@ -211,7 +211,7 @@ * the contextPriorityClassLoader is set to true (as here). */ public void testTrueExistantNonJavaxResource() { - cl = new JettyClassLoader(urls, getClass().getClassLoader(), true); + cl = new JettyClassLoader(urls, null, getClass().getClassLoader(), true); URL url = cl.getResource("mx4j/MBeanDescription.class"); if(url == null) { fail("Problem with test; expecting to have mx4j.* on the ClassPath"); Modified: geronimo/trunk/modules/webservices/src/java/org/apache/geronimo/webservices/POJOWebServiceServlet.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/webservices/src/java/org/apache/geronimo/webservices/POJOWebServiceServlet.java?view=diff&r1=160406&r2=160407 ============================================================================== --- geronimo/trunk/modules/webservices/src/java/org/apache/geronimo/webservices/POJOWebServiceServlet.java (original) +++ geronimo/trunk/modules/webservices/src/java/org/apache/geronimo/webservices/POJOWebServiceServlet.java Thu Apr 7 07:58:22 2005 @@ -17,19 +17,13 @@ package org.apache.geronimo.webservices; import java.io.IOException; -import java.security.Principal; import javax.servlet.Servlet; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.xml.rpc.ServiceException; -import javax.xml.rpc.handler.MessageContext; import javax.xml.rpc.server.ServiceLifecycle; -import javax.xml.rpc.server.ServletEndpointContext; /** * Delegates requests to a WebServiceContainer which is presumably for a POJO WebService