Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2007-10-03
12
Medium Priority
?
3,117 Views
Last Modified: 2013-11-24
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?
0
Comment
Question by:JianJunShen
  • 6
  • 6
12 Comments
 
LVL 92

Expert Comment

by:objects
ID: 20004905
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
 

Author Comment

by:JianJunShen
ID: 20005407
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
 
LVL 92

Expert Comment

by:objects
ID: 20005422
why didn't u try what i suggested?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:JianJunShen
ID: 20005556
Do I need to create mydtds directory?
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 20005593
no that was just an example :)
point is just include the path to the dtd, and make it SYSTEM instead of PUBLIC
0
 

Author Comment

by:JianJunShen
ID: 20006111
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
 
LVL 92

Assisted Solution

by:objects
objects earned 2000 total points
ID: 20006188
sorry, my bad. should have been:

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

Author Comment

by:JianJunShen
ID: 20012006
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
 
LVL 92

Assisted Solution

by:objects
objects earned 2000 total points
ID: 20012020
what parser are you using?
0
 

Author Comment

by:JianJunShen
ID: 20012083
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
 

Author Comment

by:JianJunShen
ID: 20012092
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
 
LVL 92

Assisted Solution

by:objects
objects earned 2000 total points
ID: 20012136
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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question