Well I solved the problem and for the benefit of anyone looking though the email archive the solution is:
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
If the namespace isn't set to true, than the element contains no namespace hence causing a failure.
By default in 1.4.1 the DocumentBuilderFactory is set to ignore the namespace. I did not realize this but am know happy to know it.
Ryan Cuprak
[EMAIL PROTECTED]
Office: (203)-786-5682
Cell: (203)-376-8789
Ryan D. Cuprak/507107/EKC@Kodak
02/20/2003 10:31 AM
|
To: [EMAIL PROTECTED] cc: Subject: (more info) Re: WSSDDocument Constructor problems (deploying via a servlet) |
Okay, I pinned down the code in WSSDElement which is throwing the exception. I checked and both Namespace and Localname are null, hence the exception being thrown. However, I don't understand how to correct this - is there some different between using the admin tool and WSSDDocument and deployment in terms of expectations? Basically I cut and pasted this from the examples.
/**
* Make sure everything looks kosher with the element name.
*/
private void validateCandidateElement(Element e)
throws WSDDException
{
QName name = getElementName();
if ((null == e) || (null == e.getNamespaceURI())
|| (null == e.getLocalName())
||!e.getNamespaceURI().equals(name.getNamespaceURI())
||!e.getLocalName().equals(name.getLocalPart())) {
throw new WSDDException(Messages.getMessage("invalidWSDD00",
e.getLocalName(),
name.getLocalPart()));
}
}
Deployment file contents:
<deployment name="HelloWorld" xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance">
<service name="MyHelloWorld" provider="java:RPC" >
<namespace>http://kodak.com/sis/</namespace>
<parameter name="className" value="com.kodak.sis.gmp.webapp.services.MyHelloWorld" />
<parameter name="allowedMethods" value="*"/>
</service>
</deployment>
Ryan Cuprak
[EMAIL PROTECTED]
Office: (203)-786-5682
Cell: (203)-376-8789
Ryan D. Cuprak/507107/EKC@Kodak
02/20/2003 10:09 AM | To: [EMAIL PROTECTED] cc: Subject: WSSDDocument Constructor problems (deploying via a servlet) |
Since I can't automatically deploy using server-config I decided to try doing it in code. After hunting through the list archives I found a snippet (posted by Peter Kock 2/6/03). Below is the code snippet (fully implemented). I read in the deployment file, desploy.wsdd which works when using the admin tool and pass an element which name is 'deployment' to the constructor of WSDDDocument. However WSDDocument throws the exception "Invalid WSDD element 'null'. I then tried passing in the Document but recieved the same exact error message. Am I missing the boat here on something (using the release candidate)?
public class SystemStartup extends HttpServlet {
public void init () {
AxisServlet axisServlet = new AxisServlet();
ServletConfig sC = getServletConfig();
try {
axisServlet.init(sC);
} catch (ServletException e) {
e.printStackTrace();
}
try {
AxisEngine engine = axisServlet.getEngine();
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
Document doc = null;
File fl = new File ("../webapps/GMPServer/WEB-INF/deploy.wsdd");
DocumentBuilder builder = fact.newDocumentBuilder();
doc = builder.parse(fl);
Element element = doc.getDocumentElement();
System.out.println ( "Element: " + element.getNodeName() ); //-- prints out 'deployment'
WSDDDocument wsddDoc = new WSDDDocument(element); //-- EXCEPTION BEING THROWN HERE
EngineConfiguration config = engine.getConfig();
if ( config instanceof WSDDEngineConfiguration) {
WSDDDeployment deployment = ((WSDDEngineConfiguration) config).getDeployment();
wsddDoc.deploy(deployment);
}
engine.refreshGlobalOptions();
engine.saveConfiguration();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
}
public void doGet(HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException {
}
public void doPost(HttpServletRequest request, HttpServletResponse response ) throws ServletException , IOException {
}
}
Exception:
org.apache.axis.deployment.wsdd.WSDDException: Invalid WSDD element 'null' (want
ed 'deployment')
org.apache.axis.deployment.wsdd.WSDDException: Invalid WSDD element 'null' (want
ed 'deployment')
at org.apache.axis.deployment.wsdd.WSDDElement.validateCandidateElement(
WSDDElement.java:116)
at org.apache.axis.deployment.wsdd.WSDDElement.<init>(WSDDElement.java:9
6)
at org.apache.axis.deployment.wsdd.WSDDDeployment.<init>(WSDDDeployment.
java:218)
at org.apache.axis.deployment.wsdd.WSDDDocument.<init>(WSDDDocument.java
:118)
at com.kodak.sis.gmp.webapp.servlets.SystemStartup.init(Unknown Source)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:934)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:82
1)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:3420)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
608)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:821)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:80
7)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDep
loyer.java:257)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:772)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:502
)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:410
)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:879)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:368)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:166)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1196)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347
)
at org.apache.catalina.core.StandardService.start(StandardService.java:4
97)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:218
9)
at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
at org.apache.axis.deployment.wsdd.WSDDElement.validateCandidateElement(
WSDDElement.java:116)
at org.apache.axis.deployment.wsdd.WSDDElement.<init>(WSDDElement.java:9
6)
at org.apache.axis.deployment.wsdd.WSDDDeployment.<init>(WSDDDeployment.
java:218)
at org.apache.axis.deployment.wsdd.WSDDDocument.<init>(WSDDDocument.java
:118)
at com.kodak.sis.gmp.webapp.servlets.SystemStartup.init(Unknown Source)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:934)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:82
1)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:3420)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3
608)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:821)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:80
7)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:579)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDep
loyer.java:257)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:772)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:502
)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:410
)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:879)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java
:368)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl
eSupport.java:166)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1196)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:738)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1188)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:347
)
at org.apache.catalina.core.StandardService.start(StandardService.java:4
97)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:218
9)
at org.apache.catalina.startup.Catalina.start(Catalina.java:512)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
Feb 20, 2003 9:48:53 AM org.apache.coyote.http11.Http11Protocol start
Ryan Cuprak
[EMAIL PROTECTED]
Office: (203)-786-5682
Cell: (203)-376-8789