How to put downloaded spring-beans-2.0.dtd in springContext.xml

I downloaded dtd, and put it into classpath. In Ant's build.xml, I have:

<property name="main.dir" value="./src/main"/>
<property name="resources.dir" value="${main.dir}/resources"/>
<path id="compile.classpath">
    <pathelement location="${resources.dir}"/>
    ...
</path>

spring-beans-2.0.dtd is in resources directory:

src
   main
      resources
           spring-beans-2.0.dtd

In applicationContext.xml: I added following line:
   <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"  "classpath://spring-beans-2.0.dtd" >

But it gives following error:
java.net.MalformedURLException: unknown protocol: classpath

How to put downloaded dtd in applicationContext.xml?
JianJunShenAsked:
Who is Participating?
 
objectsCommented:
no that was just an example :)
point is just include the path to the dtd, and make it SYSTEM instead of PUBLIC
0
 
objectsCommented:
don't think u can use classpath, instead use file path

   <!DOCTYPE beans SYSTEM "-//SPRING//DTD BEAN 2.0//EN"  "/mydtds/spring-beans-2.0.dtd" >
0
 
JianJunShenAuthor Commented:
I have tried. All failed.

1) <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"  "spring-beans-2.0.dtd">
error message is no protocol found
2) <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"  "file://spring-beans-2.0.dtd">
error message , see detailed error message
3)file:///C:/eclipse33/eclipse/workspaceStruts2SpriHibJavaAcademyV2/AuctionStruts2AjaxSprHib/src/main/resourcesspring-beans-2.0.dtd
See detailed error message

===================================detailed error message==================
[auctionstruts2ajaxsprhib] WARN [2007/10/03 14:20:58] | Ignored XML validation warning
org.xml.sax.SAXParseException: URI was not reported to parser for entity [document]
      at gnu.xml.aelfred2.SAXDriver.warn(SAXDriver.java:934)
      at gnu.xml.aelfred2.SAXDriver.startExternalEntity(SAXDriver.java:631)
      at gnu.xml.aelfred2.XmlParser.pushURL(XmlParser.java:3358)
      at gnu.xml.aelfred2.XmlParser.doParse(XmlParser.java:159)
      at gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:320)
      at gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)
      at gnu.xml.dom.JAXPFactory$JAXPBuilder.parse(JAXPFactory.java:186)
      at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:351)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
      at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
      at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
      at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(StandardService.java:448)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
      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:597)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
[auctionstruts2ajaxsprhib] WARN [2007/10/03 14:20:58] | Ignored XML validation warning
org.xml.sax.SAXParseException: No base URI; hope URI is absolute: file:///C:/eclipse33/eclipse/workspaceStruts2SpriHibJavaAcademyV2/AuctionStruts2AjaxSprHib/src/main/resourcesspring-beans-2.0.dtd
      at gnu.xml.aelfred2.SAXDriver.warn(SAXDriver.java:934)
      at gnu.xml.aelfred2.XmlParser.readExternalIds(XmlParser.java:2399)
      at gnu.xml.aelfred2.XmlParser.parseDoctypedecl(XmlParser.java:804)
      at gnu.xml.aelfred2.XmlParser.parseProlog(XmlParser.java:522)
      at gnu.xml.aelfred2.XmlParser.parseDocument(XmlParser.java:414)
      at gnu.xml.aelfred2.XmlParser.doParse(XmlParser.java:167)
      at gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:320)
      at gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)
      at gnu.xml.dom.JAXPFactory$JAXPBuilder.parse(JAXPFactory.java:186)
      at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:351)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
      at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
      at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
      at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(StandardService.java:448)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
      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:597)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
[auctionstruts2ajaxsprhib] WARN [2007/10/03 14:20:58] | Ignored XML validation warning
org.xml.sax.SAXParseException: No base URI; hope this SYSTEM id is absolute: file:///C:/eclipse33/eclipse/workspaceStruts2SpriHibJavaAcademyV2/AuctionStruts2AjaxSprHib/src/main/resourcesspring-beans-2.0.dtd
      at gnu.xml.aelfred2.SAXDriver.warn(SAXDriver.java:934)
      at gnu.xml.aelfred2.SAXDriver.absolutize(SAXDriver.java:606)
      at gnu.xml.aelfred2.SAXDriver.resolveEntity(SAXDriver.java:585)
      at gnu.xml.aelfred2.XmlParser.pushURL(XmlParser.java:3336)
      at gnu.xml.aelfred2.XmlParser.parseDoctypedecl(XmlParser.java:845)
      at gnu.xml.aelfred2.XmlParser.parseProlog(XmlParser.java:522)
      at gnu.xml.aelfred2.XmlParser.parseDocument(XmlParser.java:414)
      at gnu.xml.aelfred2.XmlParser.doParse(XmlParser.java:167)
      at gnu.xml.aelfred2.SAXDriver.parse(SAXDriver.java:320)
      at gnu.xml.aelfred2.XmlReader.parse(XmlReader.java:294)
      at gnu.xml.dom.JAXPFactory$JAXPBuilder.parse(JAXPFactory.java:186)
      at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:351)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
      at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:280)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:131)
      at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:147)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
      at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92)
      at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:101)
      at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:389)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:324)
      at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
      at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
      at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
      at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
      at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
      at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
      at org.apache.catalina.core.StandardService.start(StandardService.java:448)
      at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
      at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
      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:597)
      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
objectsCommented:
why didn't u try what i suggested?
0
 
JianJunShenAuthor Commented:
Do I need to create mydtds directory?
0
 
JianJunShenAuthor Commented:
I put dtd as follows:
<!DOCTYPE beans SYSTEM "-//SPRING//DTD BEAN 2.0//EN" "spring-beans-2.0.dtd" >

Caused by:
org.xml.sax.SAXParseException: required character (found """) (expected ">")

And in Tomcat:
ApplicationContext and spring-beans-2.0.dtd are in same directory.
C:\apache-tomcat-5.5.25\webapps\auctionstruts2ajaxsprhib\WEB-INF\classes

After I replace PUBLIC with SYSTEM, myEclipse editor dialog says the document type declaration for root elemen type of "beans" must end with >. But If I do not replace PUBLIC with SYSTEM, there is no error sign in editor. But anyway, I tried both, it does not work. Application deployt failed.

0
 
objectsCommented:
sorry, my bad. should have been:

<!DOCTYPE beans SYSTEM "spring-beans-2.0.dtd" >
0
 
JianJunShenAuthor Commented:
I put followings line into applicationContext.xml:

<!DOCTYPE beans SYSTEM "spring-beans.dtd" >

And in deployed folder, I could see applicationContext and spring-beans.dtd are in same folder.

But now, it gives following error:

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [C:\apache-tomcat-5.5.25\webapps\auctionstruts2ajaxsprhib\WEB-INF\classes\applicationContext.xml]; nested exception is java.net.MalformedURLException: no protocol: spring-beans.dtd
Caused by:
java.net.MalformedURLException: no protocol: spring-beans.dtd


0
 
objectsCommented:
what parser are you using?
0
 
JianJunShenAuthor Commented:
Hi, Objects:

Thanks for your help!!! The final reason is that gnujaxp.jar. After I remove this zip in my lib directory, everything works. I am using parser in that package. But could you please tell me parser matters in this case?

With best regards,

Juhani
0
 
JianJunShenAuthor Commented:
I will create another thread to ask what kind of jars one need to include from jfreechart package if one is going to integrate JFreechart with struts 2.

0
 
objectsCommented:
WOuld appear the parser does make a diff. One would hope it wouldn't but its not a pefect world and we sometimes need to deal with different implementations.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.