Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Strange iBatis error... parsing XPath '/sqlMapConfig/sqlMap'

  1. #1
    Join Date
    Feb 2005
    Posts
    11

    Default 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. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    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.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Feb 2005
    Posts
    11

    Default

    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.

  4. #4
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    9

    Default 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

  5. #5
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,425

    Default

    What is the problem you are having? Can you post the stacktrace?

  6. #6
    Join Date
    May 2007
    Location
    Franklin, MA
    Posts
    12

    Default 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>

  7. #7
    Join Date
    Jul 2007
    Posts
    9

    Default 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

  8. #8
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default 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?
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  9. #9
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default 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...
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  10. #10

    Default 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.

Similar Threads

  1. ERROR: Context initialization failed
    By makhlo in forum Architecture
    Replies: 8
    Last Post: Jul 11th, 2008, 01:41 AM
  2. iBatis lazy load transaction issues.
    By efpiva in forum Data
    Replies: 3
    Last Post: Jun 22nd, 2005, 06:20 PM
  3. Utilize Spring's JDBC Framework or iBATIS
    By jaybytez in forum Data
    Replies: 2
    Last Post: Mar 11th, 2005, 06:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •