Announcement Announcement Module
Collapse
No announcement yet.
How to use the system id in the xml definition file? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use the system id in the xml definition file?

    Hello,

    i have the problem that the spring-beans.dtd cannot be resolved.
    I read the threads:

    http://forum.springframework.org/showthread.php?t=11395

    And I added XercesImpl.jar to my classpath and I still could not locate the dtd.

    The Exception is:
    org.xml.sax.SAXParseException: Relative URI "spring-beans.dtd"could not be located without a Base-URI

    my xml looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans SYSTEM "spring-beans.dtd" >

    The dtd is located in the same dir as the xml-file.

    The folders look like this:

    bin <- start.bat and the jar for my code (also dtd included)
    lib <- spring jars
    config <- xml and dtd

    If I use the Public declaration, the system will try to get the dtd by http :-(

    Any Ideas? Rgds,

    Andreas

    :using Spring 1.1.3:
    Last edited by robyn; May 19th, 2006, 05:55 AM.

  • #2
    Re: How to use the system id in the xml definition file?

    Originally posted by Andreas Schuth
    And I added XercesImpl.jar to my classpath and I still could not locate the dtd.
    Did you also provide the VM parameter -Djavax.xml.parsers.DocumentBuilderFactory=org.apac he.xerces.jaxp.DocumentBuilderFactoryImpl?

    Comment


    • #3
      Andreas,

      thanks for your answer (again :-))

      Yes, I did not specify the systemproperty :-(
      But now I still cannot run my application:

      Exception:
      Exception in thread "main" java.util.MissingResourceException: Can't find bundle for base name org.apache.xerces.impl.msg.XMLMessages, locale de_DE
      at java.util.ResourceBundle.throwMissingResourceExcep tion(ResourceBundle.java:804)
      at java.util.ResourceBundle.getBundleImpl(ResourceBun dle.java:773)
      at java.util.ResourceBundle.getBundle(ResourceBundle. java:538)
      at org.apache.xerces.impl.msg.XMLMessageFormatter.for matMessage(XMLMessageFormatter.java:110)
      at org.apache.xerces.impl.XMLErrorReporter.reportErro r(XMLErrorReporter.java:333)
      at org.apache.xerces.impl.XMLErrorReporter.reportErro r(XMLErrorReporter.java:305)
      at org.apache.xerces.impl.XMLScanner.reportFatalError (XMLScanner.java:1269)
      at org.apache.xerces.impl.XMLDTDScannerImpl.scanDecls (XMLDTDScannerImpl.java:1855)
      at org.apache.xerces.impl.XMLDTDScannerImpl.scanDTDEx ternalSubset(XMLDTDScannerImpl.java:312)
      at org.apache.xerces.impl.XMLDocumentScannerImpl$DTDD ispatcher.dispatch(XMLDocumentScannerImpl.java:850 )
      at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanDocument(XMLDocumentFragmentScannerImpl.ja va:329)
      at org.apache.xerces.parsers.DTDConfiguration.parse(D TDConfiguration.java:525)
      at org.apache.xerces.parsers.DTDConfiguration.parse(D TDConfiguration.java:581)
      at org.apache.xerces.parsers.XMLParser.parse(XMLParse r.java:152)
      at org.apache.xerces.parsers.DOMParser.parse(DOMParse r.java:253)
      at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(D ocumentBuilderImpl.java:201)
      at javax.xml.parsers.DocumentBuilder.parse(DocumentBu ilder.java:76)

      I guess xerces cannot fint the resource bundle, but it is in the classpath.
      I added:

      ../lib/xerces/xercesImpl.jar;
      ../lib/xerces/xml-apis.jar

      to the classpath.

      There may be a problem with the classloader ?
      I am using the FileSystemXmlApplicationContext to load the XML file.

      Any ideas, best rgds,

      Andreas

      :using Xerces 2.6.2:

      Comment


      • #4
        As I saw, the objected resource org.apache.xerces.impl.msg.XMLMessages resides inside the xercesImpl.jar (at least in version 2.5.0).
        So if the xerces classes cannot find it, it would indeed be an indication of a classloader issue. Maybe you have multiple xerces jars in your classpath?

        Regards,
        Andreas

        P.S.: Still using Spring 1.1.1, but I do not believe that this might be a reason (many others would have encountered this issue also, I believe)

        Comment


        • #5
          Andreas,

          thx for reply.
          I fixed the classloader issue.
          I separated the jars from my lib dir wich is loaded by another classloader.

          But still I have an Exception:
          INFO: Found entity [spring-beans.dtd] as application context resource [spring-beans.dtd]
          Exception in thread "main" org.springframework.beans.factory.BeanDefinitionSt oreException: Line 2 in XML document from file [C:\server.xml] is invalid;
          nested exception is org.xml.sax.SAXParseException: The markup declarati
          ons contained or pointed to by the document type declaration must be well-formed.
          org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed.
          at org.apache.xerces.framework.XMLParser.reportError( XMLParser.java:969)
          at org.apache.xerces.framework.XMLDTDScanner.reportFa talXMLError(XMLDTDScanner.java:645)
          at org.apache.xerces.framework.XMLDTDScanner.abortMar kup(XMLDTDScanner.java:699)
          at org.apache.xerces.framework.XMLDTDScanner.scanDecl s(XMLDTDScanner.java:1439)
          at org.apache.xerces.framework.XMLDocumentScanner.sca nDoctypeDecl(XMLDocumentScanner.java:2179)
          at org.apache.xerces.framework.XMLDocumentScanner.acc ess$0(XMLDocumentScanner.java:2133)
          at org.apache.xerces.framework.XMLDocumentScanner$Pro logDispatcher.dispatch(XMLDocumentScanner.java:882 )
          at org.apache.xerces.framework.XMLDocumentScanner.par seSome(XMLDocumentScanner.java:380)
          at org.apache.xerces.framework.XMLParser.parse(XMLPar ser.java:861)
          at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(D ocumentBuilderImpl.java:123)
          at javax.xml.parsers.DocumentBuilder.parse(DocumentBu ilder.java:76)
          at org.springframework.beans.factory.xml.XmlBeanDefin itionReader.loadBeanDefinitions(XmlBeanDefinitionR eader.java:130)
          at org.springframework.beans.factory.support.Abstract BeanDefinitionReader.loadBeanDefinitions(AbstractB eanDefinitionReader.java:83)
          at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:101)
          at org.springframework.context.support.AbstractXmlApp licationContext.loadBeanDefinitions(AbstractXmlApp licationContext.java:69)
          at org.springframework.context.support.AbstractRefres hableApplicationContext.refreshBeanFactory(Abstrac tRefreshableApplicationContext.java:87)
          at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:262)
          at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:82)


          The dtd is valid and is the one shipped witch spring!
          This is really annoying :-(

          Comment


          • #6
            Re: How to use the system id in the xml definition file?

            Originally posted by Andreas Schuth
            Hello,

            i have the problem that the spring-beans.dtd cannot be resolved.
            I read the threads:

            http://forum.springframework.org/sho...ght=system+dtd

            And I added XercesImpl.jar to my classpath and I still could not locate the dtd.

            The Exception is:
            org.xml.sax.SAXParseException: Relative URI "spring-beans.dtd"could not be located without a Base-URI

            my xml looks like this:

            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE beans SYSTEM "spring-beans.dtd" >

            The dtd is located in the same dir as the xml-file.

            The folders look like this:

            bin <- start.bat and the jar for my code (also dtd included)
            lib <- spring jars
            config <- xml and dtd

            If I use the Public declaration, the system will try to get the dtd by http :-(

            Any Ideas? Rgds,

            Andreas

            :using Spring 1.1.3:
            You should be able to use the PUBLIC definition. If the Spring libraries are on the classpath, then the dtd entity resolver that spring registers should also be able to find the DTD file that is also on that same classpth (as part of the spring libs).

            You can't really use SYSTEM wiithout giving the XML parser information about a base directiory, but you should never have to use SYSTEM. If it is actually going out to get the DTD by http when you use public, then there is something seriously wrong in your setup (i.e. spring-beans.dtd has been stripped from the spring jars, or spring was not able to register its entity resolver, etc.).
            Last edited by robyn; May 19th, 2006, 05:59 AM.

            Comment


            • #7
              Found it

              Dear guyz,

              i found the problem in my application.
              Now please do not lough (as I would not know - you can).

              1) Xerces is not neccessary, as crimson works fine
              2) So you dont need the java properties to be set
              3) The PUBLIC-declaration is correct

              My mistake was:
              I have a user called --> "jones!" <--
              And I tested on my desktop which has the path
              c:\......\Jones!\Desktop

              In Eclipse everthing works fine .. path to Eclipse is D:\Eclipse 3.0.1\......

              So the problem was in the user name which endet witch a exclamation mark.

              I run it on d:\temp with no problem.

              Thank you for your help and pls do not lough :-)))

              Best regards,


              Andreas

              s: have a wonderful Christmas and enjoy the last days of the year.
              Greetings from the lake of constance / germany.

              Comment

              Working...
              X