Announcement Announcement Module
Collapse
No announcement yet.
Strange iBatis error... parsing XPath '/sqlMapConfig/sqlMap' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Strange iBatis error... parsing XPath '/sqlMapConfig/sqlMap'

    Hi,
    I have successfully used iBatis in the past but with a current project I am encountering a strange error. It seems that the parser dies on parsing the sql-map-config.xml file. I am using jdk 1.5, eclipse 3.1 and iBatis build 2.1.5. Here is my config file and a stack trace of the error. Any help would be greatly appreciated. Thanks.

    sql-map-config.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
        "http&#58;//www.ibatis.com/dtd/sql-map-config-2.dtd">
    
    <sqlMapConfig>
    	<sqlMap resource="com/tabarca/dao/ibatis/maps/User.xml"/>
    </sqlMapConfig>
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'sqlMapClient' defined in class path resource [com/tabarca/domain/ibatis/testApplicationContext.xml]: Initialization of bean failed; nested exception is com.ibatis.common.exception.NestedRuntimeException : Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException : Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: com.ibatis.common.exception.NestedRuntimeException : Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null".
    com.ibatis.common.exception.NestedRuntimeException : Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException : Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: com.ibatis.common.exception.NestedRuntimeException : Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException : Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: com.ibatis.common.exception.NestedRuntimeException : Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null". Caused by: org.xml.sax.SAXParseException: Document root element "sqlMap", must match DOCTYPE root "null".
    at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigP arser.parse(SqlMapConfigParser.java:81)
    at com.ibatis.sqlmap.client.SqlMapClientBuilder.build SqlMapClient(SqlMapClientBuilder.java:62)
    at org.springframework.orm.ibatis.SqlMapClientFactory Bean.afterPropertiesSet(SqlMapClientFactoryBean.ja va:258)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1058)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:363)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:269)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:318)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:81)
    at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>(ClassPathXmlApplicationCon text.java:66)
    at org.springframework.test.AbstractSpringContextTest s.loadContextLocations(AbstractSpringContextTests. java:121)
    at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.loadContextLocations(Abstract DependencyInjectionSpringContextTests.java:161)
    at org.springframework.test.AbstractSpringContextTest s.getContext(AbstractSpringContextTests.java:101)
    at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.setUp(AbstractDependencyInjec tionSpringContextTests.java:129)
    at junit.framework.TestCase.runBare(TestCase.java:125 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:478)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:344)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)

  • #2
    I haven't used iBatis that much but I think you have a problem with XML parsers probably related to classpaths. You can check and make sure you have the recommended XML parser.

    Comment


    • #3
      In case anyone is having the same problem add this to the top of file:

      Code:
      <!DOCTYPE sqlMap
      	PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
      	"http&#58;//ibatis.apache.org/dtd/sql-map-2.dtd">
      That did the trick.

      Comment


      • #4
        It is not working

        Dear Senior Member,
        I have same problem with my sql-map-config file but i tried u r given tip but it is not working.So it is not problem problem is in the xml parser But i still not find solution of the problem

        Comment


        • #5
          What is the problem you are having? Can you post the stacktrace?

          Comment


          • #6
            Addition to SQL Map

            I'm no means an Ibatis expert but my sqlmapconfig includes and additional line:
            <settings enhancementEnabled="true" useStatementNamespaces="true"/>

            as in:
            Code:
            <?xml version="1.0" encoding="UTF-8"?>
            
            <!DOCTYPE sqlMapConfig
               PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
               "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
            
            <sqlMapConfig>
            
              <!-- List the SQL Map XML files. They can be loaded from the 
                   classpath, as they are here (com.domain.data...) -->
             <settings enhancementEnabled="true" useStatementNamespaces="true"/>
              <sqlMap resource="/bus/LogRecord.xml"/>
              <sqlMap resource="/bus/SupportTicket.xml"/>
              <!-- List more here...
              
              <sqlMap resource="com/mydomain/data/Order.xml"/>
              <sqlMap resource="com/mydomain/data/Documents.xml"/>
              -->
            
            </sqlMapConfig>

            Comment


            • #7
              Ibexx is rt

              Hi,
              Ibexx is rt the header of the config file needs to be changed.

              I have a question: I am trying to use the LIKE clause in the query and I do not get any result. I tried the following ways but in vain.

              1)
              <select id="searchSelect" parameterClass="java.lang.String" resultClass="Test2.model.TEMP_EMP_DO" >
              select * from LC.TEMP_EMP WHERE NAME LIKE '%#NAME#%'
              </select>
              No results
              2)
              <select id="searchSelect" parameterClass="java.lang.String" resultClass="Test2.model.TEMP_EMP_DO" >
              select * from LC.TEMP_EMP WHERE NAME LIKE #NAME#
              </select>
              here i had set the value of NAME ='%Emp%' in the client.Still not results.

              3)
              <select id="searchSelect" parameterClass="java.util.HashMap" resultClass="Test2.model.TEMP_EMP_DO" >
              select * from LC.TEMP_EMP WHERE NAME LIKE
              <isNotNull property="name" open="'%" close="%'" >
              #NAME#
              </isNotNull>
              </select>
              I get the SQLSTATE=42601 for this one, even after escaping the single quotes, % sign and both.

              Please share your solutions or tghts.

              Thnx

              Comment


              • #8
                Anybody found a solution??

                I have the same error:
                Code:
                org.springframework.beans.factory.BeanCreationException: Error creating bean wit
                h name 'sqlMapClient' defined in class path resource [applicationContext.xml]: I
                nvocation of init method failed; nested exception is java.lang.RuntimeException:
                 Error occurred.  Cause: com.ibatis.common.xml.NodeletException: Error parsing X
                ML.  Cause: java.lang.RuntimeException: Error parsing XPath '/sqlMapConfig/sqlMa
                p'.  Cause: java.io.IOException: Could not find resource Donor.xml
                Caused by: java.lang.RuntimeException: Error occurred.  Cause: com.ibatis.common
                .xml.NodeletException: Error parsing XML.  Cause: java.lang.RuntimeException: Er
                ror parsing XPath '/sqlMapConfig/sqlMap'.  Cause: java.io.IOException: Could not
                 find resource Donor.xml
                        at com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapC
                onfigParser.java:109)
                        at com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMap
                ClientBuilder.java:90)
                        at org.springframework.orm.ibatis.SqlMapClientFactoryBean.buildSqlMapCli
                ent(SqlMapClientFactoryBean.java:326)
                        at org.springframework.orm.ibatis.SqlMapClientFactoryBean.afterPropertie
                sSet(SqlMapClientFactoryBean.java:280)
                        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
                Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1175)
                        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
                
                etc
                
                etc
                iBatis version 2.3.0.677

                Anybody?

                Comment


                • #9
                  Solved

                  I moved sqlMapConfig.xml from /WEB-INF to /WEB-INF/classes, and then it worked. Strange, I'va always thought thar WEB-INF has belonged to the classpath of a Java web app as well...

                  Comment


                  • #10
                    Re the Like problem

                    Prias144

                    Try this:

                    <select id="searchSelect" parameterClass="java.lang.String" resultClass="Test2.model.TEMP_EMP_DO" >
                    select * from LC.TEMP_EMP WHERE NAME LIKE '%$NAME$%'
                    </select>

                    You need the different operators to get a LIKE query to work.

                    Comment


                    • #11
                      Hi,
                      Thnx for the suggestion will give that a shot too. I tried the following

                      <select id="searchLike" parameterClass="java.lang.String" resultClass="Test.model.TEMP_EMP_DO" >
                      select * from LC.TEMP_EMP WHERE EMPID LIKE #EMPID#
                      </select>

                      where EMPID ='%Emp%' and this worked fine in WSAD.thnx once again and hope kantorn finds it handy.

                      Regards.

                      Comment


                      • #12
                        Error while loading &quot;sql-map-config.xml&quot; file.

                        Originally posted by Ibexx View Post
                        In case anyone is having the same problem add this to the top of file:

                        Code:
                        <!DOCTYPE sqlMap
                        	PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
                        	"http://ibatis.apache.org/dtd/sql-map-2.dtd">
                        That did the trick.
                        I am getting error while loading "sql-map-config.xml" file.
                        Please let me know if some one has a fix for this error. I have also tried changing sql-map-config.xml with

                        <!DOCTYPE sqlMap
                        PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
                        "http://ibatis.apache.org/dtd/sql-map-2.dtd"> it did not work.

                        Thanks for help.

                        sql-map-config.xml file is :

                        <?xml version="1.0" encoding="UTF-8" ?>

                        <!DOCTYPE sqlMapConfig
                        PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
                        "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">

                        <sqlMapConfig>
                        <transactionManager type="JDBC">
                        <dataSource type="SIMPLE">
                        <property name="JDBC.Driver" value="oracle.jdbc.driver.OracleDriver" />
                        <property name="JDBC.ConnectionURL" value="jdbc:oracle:thin:@(DESCRIPTION = (LOAD_BALANCE=on)(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dbs01.dev3.personal.sdi.net)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = dbs02.dev3.personal.sdi.net)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME=SDIDB)))" />
                        <property name="JDBC.Username" value="userid" />
                        <property name="JDBC.Password" value="password" />
                        </dataSource>
                        </transactionManager>

                        <sqlMap resource="com/sdi/us/sales/personal/internet/services/lookup/domain/PolicyLookupDomain.xml"/>
                        </sqlMapConfig>

                        Error message is:

                        com.ibatis.common.exception.NestedRuntimeException : Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.net.SocketException: Operation timed out: connect:could be due to invalid address
                        Caused by: java.net.SocketException: Operation timed out: connect:could be due to invalid address
                        Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: java.net.SocketException: Operation timed out: connect:could be due to invalid address
                        Caused by: java.net.SocketException: Operation timed out: connect:could be due to invalid address

                        Comment


                        • #13
                          Originally posted by Ibexx View Post
                          In case anyone is having the same problem add this to the top of file:

                          Code:
                          <!DOCTYPE sqlMap
                          	PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
                          	"http://ibatis.apache.org/dtd/sql-map-2.dtd">
                          That did the trick.
                          Right!
                          Add this to [com/tabarca/dao/ibatis/maps/User.xml]

                          Comment

                          Working...
                          X