2 Replies Latest reply on Dec 16, 2008 9:26 AM by Giovanni Parnoffi

    Datasources, War and java.lang.StackOverflowError

    Giovanni Parnoffi Newbie

      Hi all,

      I've searched everywhere for errors similar to mine, but I didn't find anything. I think I can assume that I'm doing something completely wrong :-P

      I am trying to have a web application use a datasource.
      I'm using mySQL. I configured the datasource with this file mysql-ds.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <datasources>
       <local-tx-datasource>
       <jndi-name>springCsm</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/spring_csm</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>root</user-name>
       <password>root</password>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
       <metadata>
       <type-mapping>mySQL</type-mapping>
       </metadata>
       </local-tx-datasource>
      </datasources>


      Then I have the web.xml file:
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
       <display-name>SpringCSM-ws</display-name>
       <servlet>
       <servlet-name>TestWs</servlet-name>
       <servlet-class>com.osdp.csm.test.TestWs</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>TestWs</servlet-name>
       <url-pattern>/TestWs</url-pattern>
       </servlet-mapping>
       <session-config>
       <session-timeout>30</session-timeout>
       </session-config>
      
       <resource-ref>
       <description>DB Connection</description>
       <res-ref-name>springCsm</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
      
       <welcome-file-list>
       <welcome-file>index.html</welcome-file>
       <welcome-file>index.htm</welcome-file>
       <welcome-file>index.jsp</welcome-file>
       <welcome-file>default.html</welcome-file>
       <welcome-file>default.htm</welcome-file>
       <welcome-file>default.jsp</welcome-file>
       </welcome-file-list>
      </web-app>


      and the jboss-web.xml file:
      <jboss-web>
       <resource-ref>
       <res-ref-name>springCsm</res-ref-name>
       <jndi-name>java:comp/env/springCsm</jndi-name>
       </resource-ref>
      </jboss-web>


      In my client, I lookup the datasource with the following code:
      @WebMethod
       public String greet( @WebParam(name = "name")
       String name )
       {
       Context ctx;
       try {
       ctx = new InitialContext();
       Context envContext = (Context) ctx.lookup("java:comp/env");
       DataSource ds = (DataSource) envContext.lookup("springCsm");
       Connection conn = ds.getConnection();
      
       } catch (Throwable e) {
       throw new RuntimeException(e);
       }
       return "OK";
       }



      What I get is this nasty exception:
      11:39:09,843 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
      java.lang.RuntimeException: java.lang.StackOverflowError
       at com.osdp.csm.test.TestWs.greet(TestWs.java:45)
       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:585)
       at org.jboss.wsf.container.jboss42.InvocationHandlerJSE.invoke(InvocationHandlerJSE.java:102)
       at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:221)
       at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:466)
       at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:284)
       at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:201)
       at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:134)
       at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.StackOverflowError
       at java.security.AccessController.doPrivileged(Native Method)
       at com.sun.naming.internal.VersionHelper12.getContextClassLoader(VersionHelper12.java:158)
       at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:41)
       at javax.naming.spi.NamingManager.getObjectFactoryFromReference(NamingManager.java:129)
       at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:302)
       at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1273)
       at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1290)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:763)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
       at org.jboss.ejb3.naming.SimpleMultiplexer.createMultiplexer(SimpleMultiplexer.java:53)
       at org.jboss.ejb3.naming.SimpleMultiplexer.getObjectInstance(SimpleMultiplexer.java:88)
       at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
       at javax.naming.spi.NamingManager.getContext(NamingManager.java:422)
       at javax.naming.spi.ContinuationContext.getTargetContext(ContinuationContext.java:38)
       at javax.naming.spi.NamingManager.getContinuationContext(NamingManager.java:770)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:773)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1209)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:758)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:774)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1209)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:758)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:774)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
      


      The last five lines are repeating recursively many times.

      I have tried with many different little changes, but what I get is always this kind of error. Since I'm completely a newbie I think there're something importat I'm missing, but I don't know exactly what...any clue?

      Regards,
      GiP
      /One week Jboss newbie :-)