You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Gary Griffin <ga...@h-lounge.com> on 2006/11/17 20:24:13 UTC

StackOverflowError on SqlMapClientBuilder.buildSqlMapClient

Hi!

I'm new to iBatis and am trying to implement it in some of my code that's running in a J2EE enivronment on JBoss. Using the following code, I get a StackOverflowError:

        try {
        // neither my SqlMapConfig file nor the example one delivered with iBatis seems to work:
         String resource = "WEB-INF/SqlMapConfig.xml";
        // the following line works:
         Reader configReader = Resources.getResourceAsReader(resource);
/*
 * I used this code to make sure the reading of the XML was working:
          StringBuffer sb = new StringBuffer();
         BufferedReader br = new BufferedReader(configReader); 

         char[] cbuf = new char[65536];

         int read_this_time = 0;
        read_this_time = br.read(cbuf,0,65536);
        sb.append(cbuf,0,read_this_time);
         System.out.println(sb.toString());
*/
        //...but this line fails: 
         SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(configReader);

         List rowList = sqlMap.queryForList("getRowList", listParams);
         data.getRequest().setAttribute("rowlist", rowList);
     } catch (IOException io) {
         throw new RuntimeException("Error: " + io, io);
     } catch (SQLException se) {
      throw new RuntimeException("Error: " + se, se);
     } catch (Exception e) {
      throw new RuntimeException("Error: " + e, e);
     }

The stack trace:

javax.servlet.ServletException: Servlet execution threw an exception
 org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)

root cause

java.lang.StackOverflowError
 java.lang.Object.hashCode(Native Method)
 java.util.Hashtable.get(Hashtable.java:336)
 gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1570)
 gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1591)
 gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1591)
 gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1591)
 gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1591)
...

Here's the config file that came with the iBatis I have.
(Build Date: 2006/08/16 19:50 Build Number: 638):

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

  <!-- Configure a built-in transaction manager.  If you're using an 
       app server, you probably want to use its transaction manager 
       and a managed datasource -->
  <transactionManager type="JDBC" commitRequired="false">
    <dataSource type="SIMPLE">
      <property name="JDBC.Driver" value="org.hsqldb.jdbcDriver"/>
      <property name="JDBC.ConnectionURL" value="jdbc:hsqldb:."/>
      <property name="JDBC.Username" value="sa"/>
      <property name="JDBC.Password" value="sa"/>
    </dataSource>
  </transactionManager>

  <!-- List the SQL Map XML files. They can be loaded from the 
       classpath, as they are here (com.domain.data...) -->
  <sqlMap resource="com/mydomain/data/Account.xml"/>
  <!-- List more here...
  <sqlMap resource="com/mydomain/data/Order.xml"/>
  <sqlMap resource="com/mydomain/data/Documents.xml"/>
  -->

</sqlMapConfig>

If you have any idea what I might be doing wrong, please let me know. It's as if the XML is causing a never ending loop for some reason. I validated my XML against the DTD and it looked okay. Here's my XML. I tried with and without lazy loading enabled:

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

<!--  <settings useStatementNamespaces="false" /> -->
 <settings lazyLoadingEnabled="false" />
    <transactionManager type="JDBC" >
        <dataSource type="JNDI">
            <property name="DataSource" value="java:comp/env/jdbc/qcsql"/>
        </dataSource>
    </transactionManager>

    <sqlMap resource="RowList.xml"/>
</sqlMapConfig>

THANKS!
Gary

Re: StackOverflowError on SqlMapClientBuilder.buildSqlMapClient

Posted by Gary Griffin <ga...@h-lounge.com>.
Thanks for kicking me in the right direction. I did get by this 
issue, which was apparently unrelated to iBATIS. I found this 
link helpful:

http://forum.java.sun.com/thread.jspa?threadID=609651&messageID=3341149

I removed gnujaxp.jar from my JBoss server's lib directory since 
we weren't using it anymore and the problem went away. Not sure 
what I would have done if we were using it. The jar has some 
javax.xml, org.w3c, and org.xml classes in it. Perhaps this was 
causing a conflict with some of the other jars we have on the 
classpath. I'll have to work on my classloader and JAR knowledge 
to understand this one I think. Perhaps it's common for some 
company's and orgs to package other stuff into their jar files 
rather than let the developer find the dependencies?

To troubleshoot this I also created a small java app outside of 
the web server and things worked as expected.

Thanks,
Gary 


Re: StackOverflowError on SqlMapClientBuilder.buildSqlMapClient

Posted by Larry Meadors <lm...@apache.org>.
I do not see anything in that stack trace that leads me to believe
iBATIS is involved in any way.

I'd take a closer look at the
gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer stuff, wherever
that is coming from.

Larry


On 11/17/06, Gary Griffin <ga...@h-lounge.com> wrote:
>
>
> Hi!
>
> I'm new to iBatis and am trying to implement it in some of my code that's
> running in a J2EE enivronment on JBoss. Using the following code, I get a
> StackOverflowError:
>
>         try {
>         // neither my SqlMapConfig file nor the example one delivered with
> iBatis seems to work:
>          String resource = "WEB-INF/SqlMapConfig.xml";
>         // the following line works:
>          Reader configReader = Resources.getResourceAsReader(resource);
> /*
>  * I used this code to make sure the reading of the XML was working:
>           StringBuffer sb = new StringBuffer();
>          BufferedReader br = new BufferedReader(configReader);
>
>          char[] cbuf = new char[65536];
>
>          int read_this_time = 0;
>         read_this_time = br.read(cbuf,0,65536);
>         sb.append(cbuf,0,read_this_time);
>          System.out.println(sb.toString());
> */
>         //...but this line fails:
>          SqlMapClient sqlMap =
> SqlMapClientBuilder.buildSqlMapClient(configReader);
>
>          List rowList = sqlMap.queryForList("getRowList", listParams);
>          data.getRequest().setAttribute("rowlist", rowList);
>      } catch (IOException io) {
>          throw new RuntimeException("Error: " + io, io);
>      } catch (SQLException se) {
>       throw new RuntimeException("Error: " + se, se);
>      } catch (Exception e) {
>       throw new RuntimeException("Error: " + e, e);
>      }
>
> The stack trace:
>
> javax.servlet.ServletException: Servlet execution threw an exception
> org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
>
> root cause
>
> java.lang.StackOverflowError
>  java.lang.Object.hashCode(Native Method)
>  java.util.Hashtable.get(Hashtable.java:336)
> gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1570)
> gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1591)
> gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1591)
> gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1591)
> gnu.xml.pipeline.ValidationConsumer$ChildrenRecognizer.patchNext(ValidationConsumer.java:1591)
> ...
>
> Here's the config file that came with the iBatis I have.
> (Build Date: 2006/08/16 19:50 Build Number: 638):
>
> <?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>
>
>   <!-- Configure a built-in transaction manager.  If you're using an
>        app server, you probably want to use its transaction manager
>        and a managed datasource -->
>   <transactionManager type="JDBC" commitRequired="false">
>     <dataSource type="SIMPLE">
>       <property name="JDBC.Driver" value="org.hsqldb.jdbcDriver"/>
>       <property name="JDBC.ConnectionURL" value="jdbc:hsqldb:."/>
>       <property name="JDBC.Username" value="sa"/>
>       <property name="JDBC.Password" value="sa"/>
>     </dataSource>
>   </transactionManager>
>
>   <!-- List the SQL Map XML files. They can be loaded from the
>        classpath, as they are here (com.domain.data...) -->
>   <sqlMap resource="com/mydomain/data/Account.xml"/>
>   <!-- List more here...
>   <sqlMap resource="com/mydomain/data/Order.xml"/>
>   <sqlMap resource="com/mydomain/data/Documents.xml"/>
>   -->
>
> </sqlMapConfig>
>
> If you have any idea what I might be doing wrong, please let me know. It's
> as if the XML is causing a never ending loop for some reason. I validated my
> XML against the DTD and it looked okay. Here's my XML. I tried with and
> without lazy loading enabled:
>
> <?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>
>
> <!--  <settings useStatementNamespaces="false" /> -->
>  <settings lazyLoadingEnabled="false" />
>     <transactionManager type="JDBC" >
>         <dataSource type="JNDI">
>             <property name="DataSource"
> value="java:comp/env/jdbc/qcsql"/>
>         </dataSource>
>     </transactionManager>
>
>     <sqlMap resource="RowList.xml"/>
> </sqlMapConfig>
>
> THANKS!
> Gary