13 Replies Latest reply on Nov 6, 2006 10:00 AM by weston.price

    JBoss MS SQL Server DataSource Exception

    danielkalcevich

      I have tried posting a question similar to this one in a different thread, but got no response, so I thought I would try explaining it a different way. I am attempting to declare a DataSource in JBoss for MS SQL Server DB to the "/mdc" namespace in the JNDI. I am receiving an exception (shown below) when I try to access that DataSource through an app deployed in the Tomcat Service (in JBoss).

      My question is what does this exception mean and what can I do to fix it? For more context, my web app is running Spring with Ibatis 2.2.0. Thanks.

      Daniel

      --------
      Data Source:

      <local-tx-datasource>
      <jndi-name>mdc</jndi-name>
      <connection-url>jdbc:inetdae7:server:1433?database=MDC</connection-url>
      <driver-class>com.inet.tds.TdsDriver</driver-class>
      <user-name>xxxx</user-name>
      xxx

      <type-mapping>MS SQLSERVER2000</type-mapping>

      </local-tx-datasource>

      -----
      JBoss Web Resource Ref:

      <resource-ref>
      <res-ref-name>mdc</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <jndi-name>java:/mdc</jndi-name>
      </resource-ref>

      -----------
      Exception:

      Caused by: java.lang.IllegalAccessException: Method=public abstract java.sql.Connection java.sql.Statement.getConnection() throws java.sql.SQLException does not return Serializable
      at org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService.doStatementMethod(WrapperDataSourceService.java:411)
      at org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService.invoke(WrapperDataSourceService.java:223)
      at sun.reflect.GeneratedMethodAccessor127.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:819)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:420)
      at sun.reflect.GeneratedMethodAccessor126.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
      at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
      at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:133)
      at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197)
      at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)
      at org.jboss.resource.adapter.jdbc.remote.StatementInterceptor.invoke(StatementInterceptor.java:58)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
      ... 119 more

        • 1. Re: JBoss MS SQL Server DataSource Exception
          weston.price

          For some reason, you *-ds.xml file is being deployed as a remotely accessible DataSource, is this your intent?. Could you please post the *-ds.xml file in it's entirety.

          • 2. Re: JBoss MS SQL Server DataSource Exception
            danielkalcevich

            My -ds.xml is as follows:

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



            <local-tx-datasource>
            <jndi-name>mdcJMS</jndi-name>
            <connection-url>jdbc:inetdae7:server:1433?database=MDC_JMS</connection-url>
            <driver-class>com.inet.tds.TdsDriver</driver-class>
            <user-name>user</user-name>
            pass

            <type-mapping>MS SQLSERVER2000</type-mapping>

            </local-tx-datasource>

            <local-tx-datasource>
            <jndi-name>mdc</jndi-name>
            <connection-url>jdbc:inetdae7:server:1433?database=MDC_INT</connection-url>
            <driver-class>com.inet.tds.TdsDriver</driver-class>
            <user-name>user</user-name>
            pass

            <type-mapping>MS SQLSERVER2000</type-mapping>

            </local-tx-datasource>

            • 3. Re: JBoss MS SQL Server DataSource Exception
              weston.price

              Can you please post the code you use to look up the DataSource in your client? Something is not right. For some reason this is being treated as a remote call.

              Just to clarify, your webapp is deployed in the same VM as your DataSource correct?

              Also, what version of JBoss?

              • 4. Re: JBoss MS SQL Server DataSource Exception
                danielkalcevich

                I am using JBoss 4.0.5.GA. The setup is that I have a server configuration which uses the Tomcat Service bundled with JBoss, and that my app is deployed within that Tomcat Service.

                The code that actually calls the JNDI Lookup is code located within the Spring Framework; more specifically the "JndiObjectFactoryBean". I think the problem lie might there, but what would cause the lookup of a remote connection? Are there any indicators or anything I could check?

                • 5. Re: JBoss MS SQL Server DataSource Exception
                  weston.price

                  In your application-context.xml file, how are you referencing the DataSource? Something is causing the DataSource to be treated a remotely enabled DataSource which is typically only possible by setting the <use-java-context> element in your *-ds.xml file to false. I am assuming that you have not modified the JBoss/Tomcat configuration and you are simply deploying your application as a normal J2EE web application (WAR file).

                  • 6. Re: JBoss MS SQL Server DataSource Exception
                    danielkalcevich

                    My application-context.xml defines the following:





                    I have no resource-ref in either my web.xml or my jboss-web.xml.

                    To answer your question I am just deploying my application as a .WAR file into the deploy directory of my server config.

                    Another thing to note is that I switched over to debug mode and get the following in the log.

                    -----
                    Log:

                    13:38:43,813 DEBUG TransactionSynchronizationManager:84 - Initializing transaction synchronization
                    13:38:43,813 DEBUG TransactionInterceptor:84 - Getting transaction for com.firstam.mlsdatachecker.jdbc.manager.IConfigDataManager.getAllTimeZones
                    13:38:43,813 DEBUG SqlMapClientTemplate:84 - Opened SqlMapSession [com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl@1d22104] for iBATIS operation
                    13:38:43,844 DEBUG TransactionSynchronizationManager:84 - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@29d50d] for key [org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy@8f2588] to thread [main]
                    13:38:43,844 DEBUG TransactionSynchronizationManager:84 - Bound value [org.springframework.jdbc.datasource.ConnectionHolder@8523a0] for key [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy@9fa2fb] to thread [main]
                    13:38:43,860 DEBUG SqlMapClientTemplate:84 - Obtained JDBC Connection [2807456] for iBATIS operation
                    13:38:43,891 DEBUG TransactionSynchronizationManager:84 - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@29d50d] for key [org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy@8f2588] bound to thread [main]
                    13:38:44,188 INFO XmlBeanDefinitionReader:94 - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
                    13:38:44,219 INFO SQLErrorCodesFactory:94 - SQLErrorCodes loaded: [DB2, Derby, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
                    13:38:44,563 DEBUG TransactionSynchronizationManager:84 - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@8523a0] for key [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy@9fa2fb] bound to thread [main]
                    13:38:44,641 DEBUG TransactionSynchronizationManager:84 - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@8523a0] for key [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy@9fa2fb] bound to thread [main]
                    13:38:44,641 DEBUG TransactionSynchronizationManager:84 - Retrieved value [org.springframework.jdbc.datasource.ConnectionHolder@8523a0] for key [org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy@9fa2fb] bound to thread [main]

                    • 7. Re: JBoss MS SQL Server DataSource Exception
                      weston.price

                      You application-context.xml entry did not come through. You can bracket it with:

                      
                      


                      Try again.

                      • 8. Re: JBoss MS SQL Server DataSource Exception
                        danielkalcevich

                         

                        <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
                         <property name="jndiName" value="java:/mdc"/>
                        </bean>


                        • 9. Re: JBoss MS SQL Server DataSource Exception
                          danielkalcevich

                          The server.log reports that Spring appears to find the object in the JNDI tree, and that it accesses it from the JNDI as a Remote DataSource. I have some code that is called on application startup in a Servlet just to try and see what the DataSource looks like. The code is:

                          System.out.println( "Data Source: " + ctx.getBean( "dataSource" ) );
                          DataSource ds = null;
                          Connection c = null;
                          try {
                           ds = (DataSource)ctx.getBean( "dataSource" );
                           System.out.println( "DataSource: " + ds );
                           c = ds.getConnection();
                           System.out.println( "Connection: " + c );
                          } catch (SQLException e) {
                           e.printStackTrace();
                          } finally {
                           if( c != null ) {
                           try {
                           c.close();
                           } catch (SQLException e) {}
                           }
                          }
                          



                          -----
                          log:

                          2006-11-03 14:00:22,939 DEBUG [org.springframework.jndi.JndiTemplate] Looking up JNDI object with name [java:/mdc]
                          2006-11-03 14:00:23,064 DEBUG [org.springframework.jndi.JndiObjectFactoryBean] Located object with JNDI name [java:/mdc]
                          ....
                          2006-11-03 14:00:31,892 INFO [STDOUT] Data Source: org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy@7ae165
                          2006-11-03 14:00:31,892 INFO [STDOUT] DataSource: org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy@7ae165
                          2006-11-03 14:00:31,955 DEBUG [org.jboss.resource.connectionmanager.IdleRemover] internalRegisterPool: registering pool with interval 900000 old interval: 450000
                          2006-11-03 14:00:31,955 DEBUG [org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService] Created Connection proxy for invoker=jboss:service=invoker,type=jrmp, targetName=jboss.jca:service=DataSourceBinding,name=mdc, cacheID=14322087
                          2006-11-03 14:00:31,970 INFO [STDOUT] Connection: 14322087
                          2006-11-03 14:00:32,033 DEBUG [org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService] Created Connection proxy for invoker=jboss:service=invoker,type=jrmp, targetName=jboss.jca:service=DataSourceBinding,name=mdc, cacheID=21168790
                          2006-11-03 14:00:32,095 DEBUG [org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService] Created Statement proxy for invoker=jboss:service=invoker,type=jrmp, targetName=jboss.jca:service=DataSourceBinding,name=mdc, cacheID=13208327
                          2006-11-03 14:00:32,158 DEBUG [org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService] Created ResultSet proxy for invoker=jboss:service=invoker,type=jrmp, targetName=jboss.jca:service=DataSourceBinding,name=mdc, cacheID=22616909
                          2006-11-03 14:00:32,361 DEBUG [org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService] Closed Statement=13208327
                          2006-11-03 14:00:33,252 DEBUG [org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService] Created DatabaseMetadata proxy for invoker=jboss:service=invoker,type=jrmp, targetName=jboss.jca:service=DataSourceBinding,name=mdc, cacheID=18894914
                          2006-11-03 14:00:33,377 DEBUG [org.jboss.web.tomcat.tc5.TomcatDeployer] Initialized: {WebApplication: /C:/opt/jboss-4.0.5.GA/server/mdc/tmp/deploy/tmp21642MLSDataChecker-exp.war/, URL: file:/C:/opt/jboss-4.0.5.GA/server/mdc/tmp/deploy/tmp21642MLSDataChecker-exp.war/, classLoader: java.net.FactoryURLClassLoader@1e3bfb6:31702966} jboss.web:j2eeType=WebModule,name=//localhost/MLSDataChecker,J2EEApplication=none,J2EEServer=none
                          2006-11-03 14:00:33,377 DEBUG [org.jboss.web.WebModule] Started jboss.web.deployment:war=MLSDataChecker.war,id=1278716270
                          2006-11-03 14:00:33,377 DEBUG [org.jboss.system.ServiceController] Starting dependent components for: jboss.web.deployment:war=MLSDataChecker.war,id=1278716270 dependent components: []
                          2006-11-03 14:00:33,392 DEBUG [org.jboss.deployment.MainDeployer] End deployment start on package: MLSDataChecker.war

                          • 10. Re: JBoss MS SQL Server DataSource Exception
                            weston.price

                            Extremely weird. Check the JMX console for your datasource. Look for the DataSourceBinding for your datasource. It will be under

                            jboss.jca:name=JndiName,service=DataSourceBinding

                            You should see the use java context property. Check that. It's the only thing I can think of that explains this. Those objects do not get bound into JNDI in any other way unless that property is set.

                            • 11. Re: JBoss MS SQL Server DataSource Exception
                              danielkalcevich

                              The value for the "name=mdc,service=DataSourceBinding" mbean property "UseJavaContext" is True.

                              • 12. Re: JBoss MS SQL Server DataSource Exception (Solved)
                                danielkalcevich

                                The problem appeared to be classpath related. The jar files jbossall-client.jar and jnp-client.jar were the culprit. I was able to remove those from the classpath and now it shows the DataSources as being local.

                                06:43:11,714 INFO [STDOUT] Data Source: org.jboss.resource.adapter.jdbc.WrapperDataSource@8e753c
                                06:43:11,730 INFO [STDOUT] DataSource: org.jboss.resource.adapter.jdbc.WrapperDataSource@8e753c
                                06:43:11,823 INFO [STDOUT] Connection: org.jboss.resource.adapter.jdbc.WrappedConnection@1385846

                                • 13. Re: JBoss MS SQL Server DataSource Exception
                                  weston.price

                                  Strangest one I have heard of in awhile...glad it' working