web.xml / XML schema issue, why do some XML schema attributes disappear

A

asciz

Hi

I'm trying to get my j2ee app to run on Jboss (version 3.2.3), but
Jboss complains there are some missing attributes in the web-app
element. The attributes are present in the XML file, but they seem to
be removed by the parser, also when I view the file in a web browser.

My XML below (I have cut out a lot of stuff for the purpose of this
post)

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Hello</display-name>
</web-app>

When I view it in a browser for example, the only two attributes shown
are "version" and "xsi:schemaLocation".

Can anyone explain why this happens and whether it is the correct
behaviour?

Many thanks
asciz
 
L

Lew

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Hello</display-name>
</web-app>

When I view it in a browser for example, the only two attributes shown
are "version" and "xsi:schemaLocation".

Can anyone explain why this happens and whether it is the correct
behaviour?

Namespace declarations are not attributes. "xmlns" and "xmlns:xsi" are
namespace declarations, not attributes. They allow the parser to recognize
elements and attributes. The first namespace is the default namespace, and it
allows the parser to recognize the "version" attribute, which does not have a
namespace prefix. The "xmlns:xsi" namespace declaration allows the parser to
recognize the "xsi:schemaLocation" attribute.

- Lew
 
A

asciz

Namespace declarations are not attributes. "xmlns" and "xmlns:xsi" are
namespace declarations, not attributes. They allow the parser to recognize
elements and attributes. The first namespace is the default namespace, and it
allows the parser to recognize the "version" attribute, which does not have a
namespace prefix. The "xmlns:xsi" namespace declaration allows the parser to
recognize the "xsi:schemaLocation" attribute.

- Lew

Lew, thanks for explaining the difference between namespace
declarations and attributes.

I still don't understand, however, why my JBoss (version 3.2.3) does
not appear to "see" these declarations. I've based my web.xml on
examples that are supposed to work. I have not had the same problem on
JBoss 4.x.

Does anyone recognize this issue? I've seen some posts on similar
problem, but no explanation.

Thanks in advance,
-asciz
 
A

asciz

Lew, thanks for explaining the difference between namespace
declarations and attributes.

I still don't understand, however, why my JBoss (version 3.2.3) does
not appear to "see" these declarations. I've based my web.xml on
examples that are supposed to work. I have not had the same problem on
JBoss 4.x.

Does anyone recognize this issue? I've seen some posts on similar
problem, but no explanation.

Thanks in advance,
-asciz

Perhaps some debug output would be appropriate. I wonder if the fact
that the parser refers to "xmlns" as an 'attribute' is a clue; maybe
the parser does not understand namespaces etc?
Greatful for any suggestions.
-asciz

09:48:04,000 INFO [EmbeddedTomcatService] deploy, ctxPath=/myapp,
warUrl=file:/C:/bin/jboss-3.2.3/server/all/tmp/deploy/
tmp51713MyApp.ear-contents/MyApp.war/
09:48:04,265 ERROR [Digester] Parse Error at line 7 column 219:
Attribute "xmlns" must be declared for element type "web-app".
org.xml.sax.SAXParseException: Attribute "xmlns" must be declared for
element type "web-app".
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:
232)
at
org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:
173)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
362)
at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
296)
at
org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(XMLDTDValidator.java:
2166)
at
org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(XMLDTDValidator.java:
2885)
at
org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:
792)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:
752)
at org.apache.xerces.impl.XMLDocumentScannerImpl
$ContentDispatcher.scanRootElementHook(XMLDocumentScannerImpl.java:
927)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl
$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:
1519)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:
333)
at
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:
529)
at
org.apache.xerces.parsers.StandardParserConfiguration.parse(StandardParserConfiguration.java:
585)
at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:
147)
at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:
1148)
at org.apache.commons.digester.Digester.parse(Digester.java:
1548)
at
org.jboss.web.tomcat.tc4.SingleSignOnContextConfig.applicationConfig(SingleSignOnContextConfig.java:
299)
at
org.jboss.web.tomcat.tc4.SingleSignOnContextConfig.start(SingleSignOnContextConfig.java:
741)
at
org.jboss.web.tomcat.tc4.SingleSignOnContextConfig.lifecycleEvent(SingleSignOnContextConfig.java:
255)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:
166)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:
3582)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:
821)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
807)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:595)
at
org.jboss.web.tomcat.tc4.EmbeddedTomcatService.createWebContext(EmbeddedTomcatService.java:
549)
at
org.jboss.web.tomcat.tc4.EmbeddedTomcatService.performDeploy(EmbeddedTomcatService.java:
309)
at
org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:
428)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:
832)
at org.jboss.deployment.MainDeployer.start(MainDeployer.java:
824)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:
642)
at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:
605)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown
Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:
284)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:
177)
at $Proxy6.deploy(Unknown Source)
at
org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:
302)
at
org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:
476)
at org.jboss.deployment.scanner.AbstractDeploymentScanner
$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
at org.jboss.deployment.scanner.AbstractDeploymentScanner
$ScannerThread.loop(AbstractDeploymentScanner.java:212)
at org.jboss.deployment.scanner.AbstractDeploymentScanner
$ScannerThread.run(AbstractDeploymentScanner.java:191)
09:48:04,343 ERROR [Digester] Parse Error at line 7 column 219:
Attribute "xmlns:xsi" must be declared for element type "web-app".
org.xml.sax.SAXParseException: Attribute "xmlns:xsi" must be declared
for element type "web-app".
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:
232)
at
org.apache.xerces.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:
173)
....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top