Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
asciz@starmail.com - 19 Feb 2007 10:56 GMT
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
Lew - 20 Feb 2007 01:59 GMT
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
[quoted text clipped - 11 lines]
> 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
asciz@starmail.com - 20 Feb 2007 09:43 GMT
> a...@starmail.com wrote:
> > <?xml version="1.0" encoding="ISO-8859-1"?>
[quoted text clipped - 21 lines]
>
> - 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
asciz@starmail.com - 20 Feb 2007 09:56 GMT
> > a...@starmail.com wrote:
> > > <?xml version="1.0" encoding="ISO-8859-1"?>
[quoted text clipped - 35 lines]
> 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)
...


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.