users@glassfish.java.net

Re: Problem resolving DTD's

From: Sahoo <Sahoo_at_Sun.COM>
Date: Fri, 22 Jun 2007 21:10:33 +0530

Hi,

This behavior seems to be dictated by the JDOM wrapper. Take a look at
the implementation of SAXBuilder. The constructor SAXBuilder(URL url)
sets the url as the *systemId* in the InputSource, where as the
constructor SAXBuilder(InputStream is) does *not* set any systemId in
the InputSource. When the systemId is set in the InputSource, it is used
to resolve any relative URIs. The specification of Input allows this
behavior. When it is not set, the entity resolver is probably using
Thread.contextClassLoader to resolve the entities.

Thanks,
Sahoo

glassfish_at_javadesktop.org wrote:
> We are using JDom library as the wrapper for SAX.
> Here is our code:
>
> Document doc = new SAXBuilder().build(Thread.currentThread().getContextClassLoader().
> getResourceAsStream("specifications-config.xml"));
>
>
> Here is exception:
>
> [#|2007-06-22T16:07:50.043+0400|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8080-0;_RequestID=1320fcf3-2978-4a27-91a2-56eab15d2f88;|StandardWrapperValve[facesServlet]: PWC1406: Servlet.service() for servlet facesServlet threw exception
> java.io.FileNotFoundException: C:\Java\glassfish\domains\domain1\config\tables-config.dtd
> at java.io.FileInputStream.open(Native Method)
> at java.io.FileInputStream.<init>(FileInputStream.java:106)
> at java.io.FileInputStream.<init>(FileInputStream.java:66)
> at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)
> at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)
> at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:973)
> at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:905)
> at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:872)
> at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:282)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:1021)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
> at org.jdom.input.SAXBuilder.build(SAXBuilder.java:453)
> at org.jdom.input.SAXBuilder.build(SAXBuilder.java:770)
> at ru.amfitel.m3000.ui.selfcare.core.config.ConfigLoader.loadSpecifications(ConfigLoader.java:64)
> at ru.amfitel.m3000.ui.selfcare.core.config.ConfigLoader.<clinit>(ConfigLoader.java:32)
> at ru.amfitel.m3000.ui.selfcare.core.blogic.m2000Impl.M2000DataFacadeImpl.loadCustomer(M2000DataFacadeImpl.java:1174)
> at ru.amfitel.m3000.ui.selfcare.core.blogic.m2000Impl.M2000DataFacadeImpl.authenticate(M2000DataFacadeImpl.java:232)
> at ru.amfitel.m3000.ui.selfcare.core.mbean.AuthBean.authenticate(AuthBean.java:136)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at com.sun.el.parser.AstValue.invoke(AstValue.java:174)
> at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:286)
> at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
> at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
> at javax.faces.component.UICommand.broadcast(UICommand.java:383)
> at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:180)
> at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:158)
> at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:346)
> at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
> at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
> at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
> at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
> at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:398)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
> at ru.amfitel.common5.filters.ResourceUploadFilter.doFilter(ResourceUploadFilter.java:137)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:217)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
> at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
> at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:217)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:185)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
> at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:255)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:81)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:193)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:611)
> at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:564)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:558)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1067)
> at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:255)
> at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:618)
> at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:549)
> at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:790)
> at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:326)
> at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:248)
> at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:199)
> at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
> at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:93)
> |#]
>
> It is interesting, but if we change code to
>
> Document doc = new SAXBuilder().build(Thread.currentThread().getContextClassLoader().
> getResource("specifications-config.xml"));
>
> exception disappers.
> [Message sent by forum member 'hazurek' (hazurek)]
>
> http://forums.java.net/jive/thread.jspa?messageID=223529
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>