Simon JDBC Driver on GlassFish

665 views
Skip to first unread message

Timothy Sparg

unread,
Mar 28, 2013, 11:05:01 AM3/28/13
to java...@googlegroups.com
Hi guys

Is it possible to use the Simon JDBC driver when using GlassFish Connection Pools?

My URL looks like jdbc:simon:sqlserver://myDBServer:1433;databaseName=myDatabase;

I'm getting the following error in the glassfish logs:
Have I just configured something incorrectly?

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: The connection string contains a badly formed name or value.
Error Code: 0
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:309)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:135)
    at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
    at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:472)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:290)
    at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:275)
    at com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:208)
    at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createNativeQuery(EntityManagerWrapper.java:630)
    at com.corefreight.backend.coreversioning.service.AppVersionFacadeREST.findLatest(AppVersionFacadeREST.java:43)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5366)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5338)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5326)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
    at $Proxy123.findLatest(Unknown Source)
    at com.corefreight.backend.coreversioning.service.__EJB31_Generated__AppVersionFacadeREST__Intf____Bean__.findLatest(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:722)
Caused by: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: The connection string contains a badly formed name or value.
    at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:120)
    at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:123)
    ... 80 more

Richard Richter

unread,
Mar 28, 2013, 12:05:46 PM3/28/13
to java...@googlegroups.com
Hi Timothy

Welcome to our little community. :-)

It's hard to say from this information, but it should work... however
it is not always as easy as putting :simon: into the JDBC URL. How is
your connection pool configured? Does it use particular class of
connection pool? I can show example from Jetty JNDI where we use Simon
around Oracle:

<New id="NonPublicCRUZDataSource" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>NonPublicCRUZDataSource</Arg>
<Arg>
<New class="org.javasimon.jdbcx4.SimonDataSource">
<Set name="RealDataSourceClassName">oracle.jdbc.pool.OracleDataSource</Set>
<Set name="Url">jdbc:oracle:thin:@172.16.13.36:1521:SAM</Set>
<Set name="User">whatever</Set>
<Set name="Password">something</Set>
</New>
</Arg>
</New>

As you can see, I used SimonDataSource and told him what the real
class is. JDBC URL is original.

Different example is from Spring configuration where we have access to
test DB (H2 in this case):

<bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl"
value="jdbc:simon:h2:~/h2-data/ris/cruzDB/cruz;AUTO_SERVER=TRUE"/>
<property name="user" value="sa"/>
<property name="password" value=""/>
...
</bean>

Here you can see that URL is changed and there is no DB specific
driver or other class specified. C3P0 will find Simon and Simon will
find H2 under cover.

Hope these examples can help you resolve your problems.

Virgo
> --
> You received this message because you are subscribed to the Google Groups
> "javasimon" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to javasimon+...@googlegroups.com.
> To post to this group, send email to java...@googlegroups.com.
> Visit this group at http://groups.google.com/group/javasimon?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Gérald

unread,
Mar 31, 2013, 3:26:45 PM3/31/13
to java...@googlegroups.com
Hi Timothy,

Back from Devoxx Fr, I did some testing of Simon's JDBC driver in GlassFish:

  • You can create a non XA connection pool using the Driver provider
    • Copy javasimon-core and javasimon-jdbc jars in glassfish/lib along with your SQL server drivers
    • Configure the connection pool, I have in my domail.xml:
    •     <jdbc-connection-pool driver-classname="org.javasimon.jdbc4.Driver" res-type="java.sql.Driver" name="jdbc/simonNonXAPool">
            <property name="Prefix" value="org.javasimon.jdbc4"></property>
            <property name="LoginTimeout" value="0"></property>
            <property name="Password" value="simon"></property>
            <property name="User" value="simon"></property>
            <property name="URL" value="jdbc:simon:mysql://localhost:3306/simon"></property>
          </jdbc-connection-pool>
  • But you can not create an XA connection pool because a NPE is raised as soon as an SimonDataSource or a SimonXADataSource is used (at least with MySQL, I do not have SQL Server set up):
    • The config in domain.xml should be
    •     <jdbc-connection-pool datasource-classname="org.javasimon.jdbcx4.SimonXADataSource" wrap-jdbc-objects="true" res-type="javax.sql.XADataSource" name="jdbc/simonXAPool">
            <property name="URL" value="jdbc:simon:mysql://localhost:3306/tyrematch"></property>
            <property name="Password" value="simon"></property>
            <property name="User" value="simon"></property>
            <property name="CachePreparedStatements" value="true"></property>
            <property name="RealDataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"></property>
          </jdbc-connection-pool>

    • I get this error
    • Caused by: java.lang.NullPointerException
          at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:428)
          at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:138)
          at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:108)
          at com.mysql.jdbc.jdbc2.optional.MysqlXADataSource.getXAConnection(MysqlXADataSource.java:48)
          at org.javasimon.jdbcx4.SimonXADataSource.getXAConnection(SimonXADataSource.java:61)
          at com.sun.gjc.spi.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:113)
          at com.sun.enterprise.resource.allocator.ConnectorAllocator.createResource(ConnectorAllocator.java:160)
          at com.sun.enterprise.resource.pool.ConnectionPool.createSingleResource(ConnectionPool.java:907)
          ... 149 more
    • Obviously the wrapper DataSource doesn't get URL/user/password from SimonDataSource, I'll check that

Gérald

Gérald

unread,
Mar 31, 2013, 4:20:35 PM3/31/13
to java...@googlegroups.com
After some more testing, you can use the SimonDataSource and SimonXADataSource, they work properly, but you must remove the "simon:" from the JDBC URL. So the config which works is:
    <jdbc-connection-pool datasource-classname="org.javasimon.jdbcx4.SimonXADataSource"
          wrap-jdbc-objects="false" res-type="javax.sql.XADataSource" name="jdbc/simonXAPool">
      <property name="URL" value="jdbc:mysql://localhost:3306/simon"></property>

      <property name="Password" value="simon"></property>
      <property name="User" value="simon"></property>
      <property name="RealDataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource"></property>
    </jdbc-connection-pool>

To conclude: The NPE was not a bug in Simon (MySQL raises this exception because it doesn't understand the java:simon:mysql URL format) and the configuration between Simon Driver et Simon DataSource are not homogeneous.

Gérald

Gérald

unread,
Apr 2, 2013, 4:50:46 AM4/2/13
to java...@googlegroups.com
Yet another thing related to SQL Server,

If you're using the Simon JDBC driver, it doesn't recognize automatically SQL Server and set the appropriate driver. So you'll have to set it manually adding and add an extra option to the URL:
jdbc:simon:sqlserver://myDBServer:1433;databaseName=myDatabase;simon_real_drv=com.microsoft.sqlserver.jdbc.SQLServerDriver
I'll fix it so as SQL Server is on par with Oracle, MySQL, Postgres, H2... and the Microsoft's driver is set automatically.

If you're using a Simon JDBC DataSource (XA or not), there is no problem since you have to set the RealDataSourceClassName property to com.microsoft.sqlserver.jdbc.SQLServerDataSource or com.microsoft.sqlserver.jdbc.SQLServerXADataSource.

Gérald

Timothy Sparg

unread,
Apr 2, 2013, 6:34:53 AM4/2/13
to java...@googlegroups.com
Hi guys 

Thanks for all the responses, it's much appreciated!

My Glassfish resources file looks as follows:

<resources>
    <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="true" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.javasimon.jdbcx4.SimonXADataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="connectionPoolFreight" non-transactional-connections="false" ping="false" pool-resize-quantity="2" pooling="true" res-type="javax.sql.XADataSource" statement-cache-size="0" statement-leak-reclaim="false" statement-leak-timeout-in-seconds="0" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
        <property name="URL" value="jdbc:sqlserver://dbServer:1433;databaseName=db1;sendStringParametersAsUnicode=false"/>
        <property name="User" value="dbUsername"/>
        <property name="Password" value="dbPassword"/>
        <property name="RealDataSourceClassName" value="com.microsoft.sqlserver.jdbc.SQLServerXADataSource"/>
    </jdbc-connection-pool>
    <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="true" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.javasimon.jdbcx4.SimonXADataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="connectionPoolCoreExchange" non-transactional-connections="false" ping="false" pool-resize-quantity="2" pooling="true" res-type="javax.sql.XADataSource" statement-cache-size="0" statement-leak-reclaim="false" statement-leak-timeout-in-seconds="0" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
        <property name="URL" value="jdbc:sqlserver://dbServer:1433;databaseName=db1;sendStringParametersAsUnicode=false"/>
        <property name="User" value="dbUsername"/>
        <property name="Password" value="dbPassword"/>
        <property name="RealDataSourceClassName" value="com.microsoft.sqlserver.jdbc.SQLServerXADataSource"/>
    </jdbc-connection-pool>
    <jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="true" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.javasimon.jdbcx4.SimonXADataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="connectionPoolCoreDocs" non-transactional-connections="false" ping="false" pool-resize-quantity="2" pooling="true" res-type="javax.sql.XADataSource" statement-cache-size="0" statement-leak-reclaim="false" statement-leak-timeout-in-seconds="0" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
        <property name="URL" value="jdbc:sqlserver://dbServer:1433;databaseName=db1;sendStringParametersAsUnicode=false"/>
        <property name="User" value="dbUsername"/>
        <property name="Password" value="dbPassword"/>
        <property name="RealDataSourceClassName" value="com.microsoft.sqlserver.jdbc.SQLServerXADataSource"/>
    </jdbc-connection-pool>
  
  
    <jdbc-resource jndi-name="jdbc/db1" enabled="true" pool-name="connectionPoolFreight"/>
    <jdbc-resource jndi-name="jdbc/db2" enabled="true" pool-name="connectionPoolCoreExchange"/>
    <jdbc-resource jndi-name="jdbc/db3" enabled="true" pool-name="connectionPoolCoreDocs"/>
</resources>


This configuration works for the most part, except that I keep on getting database connection closed exceptions.
See stacktrace:

WARNING: Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
Error Code: 0
Call: SELECT TOP 1 * FROM AppVersion WHERE IsEnabled = 1 ORDER BY AppRelDate DESC, AppVerNo DESC
Query: ReadAllQuery(referenceClass=AppVersion sql="SELECT TOP 1 * FROM AppVersion WHERE IsEnabled = 1 ORDER BY AppRelDate DESC, AppVerNo DESC")
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1494)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:636)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535)
at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1702)
at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:253)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:264)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:646)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:418)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1097)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:829)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1056)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:390)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1144)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1501)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1483)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1457)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:485)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:773)
at com.corefreight.backend.coreversioning.service.AppVersionFacadeREST.findLatest(AppVersionFacadeREST.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5366)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5338)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5326)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at $Proxy388.findLatest(Unknown Source)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolProxy.checkClosed(SQLServerConnectionPoolProxy.java:55)
at com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolProxy.prepareStatement(SQLServerConnectionPoolProxy.java:66)
at org.javasimon.jdbc4.SimonConnection.prepareStatement(SimonConnection.java:157)
at com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java:502)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1474)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1423)
at org.eclipse.persistence.internal.databaseaccess.DatabaseCall.prepareStatement(DatabaseCall.java:697)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:585)
... 89 more

WARNING: java.lang.NullPointerException
at com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolProxy.setClientInfo(SQLServerConnectionPoolProxy.java:375)
at org.javasimon.jdbc4.SimonConnection.setClientInfo(SimonConnection.java:486)
at com.sun.gjc.spi.jdbc40.ConnectionHolder40.setClientInfo(ConnectionHolder40.java:322)
at com.sun.gjc.spi.jdbc40.ConnectionHolder40.close(ConnectionHolder40.java:530)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.closeDatasourceConnection(DatabaseAccessor.java:473)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.closeConnection(DatasourceAccessor.java:504)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.closeConnection(DatabaseAccessor.java:496)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.closeJTSConnection(DatasourceAccessor.java:179)
at org.eclipse.persistence.sessions.server.ClientSession.releaseJTSConnection(ClientSession.java:117)
at org.eclipse.persistence.transaction.AbstractSynchronizationListener.afterCompletion(AbstractSynchronizationListener.java:218)
at org.eclipse.persistence.transaction.JTASynchronizationListener.afterCompletion(JTASynchronizationListener.java:79)
at com.sun.jts.jta.SynchronizationImpl.after_completion(SynchronizationImpl.java:156)
at com.sun.jts.CosTransactions.RegisteredSyncs.distributeAfter(RegisteredSyncs.java:213)
at com.sun.jts.CosTransactions.TopCoordinator.afterCompletion(TopCoordinator.java:2588)
at com.sun.jts.CosTransactions.CoordinatorTerm.rollback(CoordinatorTerm.java:569)
at com.sun.jts.CosTransactions.TerminatorImpl.rollback(TerminatorImpl.java:305)
at com.sun.jts.CosTransactions.CurrentImpl.rollback(CurrentImpl.java:766)
at com.sun.jts.jta.TransactionManagerImpl.rollback(TransactionManagerImpl.java:359)
at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.rollbackDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:223)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.rollback(JavaEETransactionManagerSimplified.java:896)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5089)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4879)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at $Proxy388.findLatest(Unknown Source)



When I enable Connection Validation, all my queries execute, however in the log files I see this:



INFO: RAR5074 : Table based validation detected invalid connection. Querying the table dbo.logLevels failed. Set resource-adapter log-level to FINE for exception stack trace. 
FINE: SELECT TOP 1 * FROM AppVersion WHERE IsEnabled = 1 ORDER BY AppRelDate DESC, AppVerNo DESC
INFO: RAR5074 : Table based validation detected invalid connection. Querying the table dbo.logLevels failed. Set resource-adapter log-level to FINE for exception stack trace. 
FINE: SELECT TOP 1 * FROM AppVersion WHERE IsEnabled = 1 ORDER BY AppRelDate DESC, AppVerNo DESC
FINE: SELECT TOP 1 * FROM AppVersion WHERE IsEnabled = 1 ORDER BY AppRelDate DESC, AppVerNo DESC
INFO: RAR5074 : Table based validation detected invalid connection. Querying the table dbo.logLevels failed. Set resource-adapter log-level to FINE for exception stack trace. 
FINE: SELECT TOP 1 * FROM AppVersion WHERE IsEnabled = 1 ORDER BY AppRelDate DESC, AppVerNo DESC
INFO: RAR5074 : Table based validation detected invalid connection. Querying the table dbo.logLevels failed. Set resource-adapter log-level to FINE for exception stack trace. 
FINE: SELECT TOP 1 * FROM AppVersion WHERE IsEnabled = 1 ORDER BY AppRelDate DESC, AppVerNo DESC
INFO: RAR5074 : Table based validation detected invalid connection. Querying the table dbo.logLevels failed. Set resource-adapter log-level to FINE for exception stack trace. 
FINE: SELECT TOP 1 * FROM AppVersion WHERE IsEnabled = 1 ORDER BY AppRelDate DESC, AppVerNo DESC
INFO: RAR5074 : Table based validation detected invalid connection. Querying the table dbo.logLevels failed. Set resource-adapter log-level to FINE for exception stack trace. 
FINE: SELECT TOP 1 * FROM AppVersion WHERE IsEnabled = 1 ORDER BY AppRelDate DESC, AppVerNo DESC


I'm trying to work out how to enable the resource-adapter log-levels that they are talking about

Tim

Richard Richter

unread,
Apr 2, 2013, 7:07:44 AM4/2/13
to java...@googlegroups.com
I can't offer any solution, however... is there any chance to get closer to that NullPointerException? Why is it there?

WARNING: java.lang.NullPointerException
at com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolProxy.setClientInfo(SQLServerConnectionPoolProxy.java:375)
at org.javasimon.jdbc4.SimonConnection.setClientInfo(SimonConnection.java:486)

Is there anything Simon could have done better? I admit, that we (authors) are not JDBC experts - we merely rely the calls to whatever is under. Is it possible to find out what input caused that NPE?

Or is that NPE irrelevant? I hope not. ;-)

V.


--

Gérald

unread,
Apr 2, 2013, 11:12:03 AM4/2/13
to java...@googlegroups.com
I think the NPE is just a consequence of the first failure, and is executed during the resulting transaction rollback.

Can you enable the appropriate log level as proposed by?

INFO: RAR5074 : Table based validation detected invalid connection. Querying the table dbo.logLevels failed. Set resource-adapter log-level to FINE for exception stack trace.
From GlassFish doc, about error RAR5074:
  • Causes:
    • The Connection object is now invalid due to database restart
    • The connection object is now invalid since the database is not up and running
    • The JDBC driver cannot execute the statement due to internal error
  • Solutions:
    • Switch on the connection validation property of the connection pool and try again
    • If the database has restarted, restart the application server as well or set the connection validation property in the pool to avoid this in the future. If the database server is not up, please bring it up
I wonder why GlassFish provides a closed connection even if Connection Validation is disabled and why the Simon connection wrapper would change something.

Gérald

Timothy Sparg

unread,
Apr 3, 2013, 6:51:25 AM4/3/13
to java...@googlegroups.com
I think you're right about the NPE.


From stepping through the code I see that the GlassFish Transaction Manager calls commit on the transaction which in turn calls close on the SimonConnection.

see Call Stack:

org.javasimon.jdbc4.SimonConnection.close(SimonConnection.java:68)
com.sun.gjc.spi.ManagedConnection.transactionCompleted(ManagedConnection.java:622)
com.sun.gjc.spi.XAResourceImpl.commit(XAResourceImpl.java:90)
com.sun.enterprise.resource.XAResourceWrapper.commit(XAResourceWrapper.java:74)
com.sun.jts.jtsxa.OTSResourceImpl.commit_one_phase(OTSResourceImpl.java:174)
com.sun.jts.CosTransactions.RegisteredResources.commitOnePhase(RegisteredResources.java:1565)
com.sun.jts.CosTransactions.TopCoordinator.commitOnePhase(TopCoordinator.java:2955)
com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:321)
com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:250)
com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:623)
com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:323)
com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.commitDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:186)
com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:858)
com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5114)


The SimonConnection close method is as follows:


    public void close() throws SQLException {
        conn.close();

        life.stop();
    }

conn is the real database connection which is then closed.

The next call of getClientInfo() causes an exception, as you can't call this method on a closed connection.

Without fully understanding everything that's going on here, shouldn't SimonPooledConnection be the class that the transaction manager is working with, and not SimonConnection?

Tim

Gérald Quintana

unread,
Apr 3, 2013, 9:35:44 AM4/3/13
to java...@googlegroups.com
Hi Tim,

Your app gets a GlassFish connection, which wraps, Simon connection, which wraps a SQL Server connection. When your app closes the GlassFish connection, the real (SQL Server one) connection is not closed and returns to the pool. When GF want to free some connection, it closes the Simon connection which in turn closes the SQL Server one (this the code your pointing).

The problem described your first stacktrace is that the SQL Server connection is closed but GlassFish is not aware of that and tries to use it (prepare a statement).
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
at com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolProxy.checkClosed(SQLServerConnectionPoolProxy.java:55)
at com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolProxy.prepareStatement(SQLServerConnectionPoolProxy.java:66)
at org.javasimon.jdbc4.SimonConnection.prepareStatement(SimonConnection.java:157)
at com.sun.gjc.spi.base.ConnectionHolder.prepareStatement(ConnectionHolder.java:502)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.prepareStatement(DatabaseAccessor.java:1474)

WARNING: java.lang.NullPointerException
at com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolProxy.setClientInfo(SQLServerConnectionPoolProxy.java:375)
at org.javasimon.jdbc4.SimonConnection.setClientInfo(SimonConnection.java:486)
at com.sun.gjc.spi.jdbc40.ConnectionHolder40.setClientInfo(ConnectionHolder40.java:322)

Your second stacktrace is weird, why does GF closes the real connection when transaction is completed?

org.javasimon.jdbc4.SimonConnection.close(SimonConnection.java:68)
com.sun.gjc.spi.ManagedConnection.transactionCompleted(ManagedConnection.java:622)
com.sun.gjc.spi.XAResourceImpl.commit(XAResourceImpl.java:90)

Don't you have the same problems without Simon ? If you remove Simon, I guess it will be a SQL Server instead, and it will be closed as well.
Why are you database connection closed? Is database server stopped or something like this?

IMHO Simon as nothing to do with connection pooling, it's just wrapper to intercept SQL queries. I tested the combo GlassFish+Simon+MySQL+Real app (XA connection pool) and have no problem. Maybe you should try to enable wrap-jdbc-objects?

Gérald



2013/4/3 Timothy Sparg <timoth...@gmail.com>

Timothy Sparg

unread,
Apr 4, 2013, 4:14:03 AM4/4/13
to java...@googlegroups.com
Hi Gérald

This problem does not exist when I use the MSSQL JDBC Driver, the moment I introduce the the Simon JDBC Driver the problem occurs.

I've tried wrap-jdbc-objects=true and wrap-jdbc-objects=false   both configuration options give the same error.

I'm going to use Simon without the JDBC logging for now, I'll revisit it in the future and see if I can understand why the problem occurs.


Tim

Richard Richter

unread,
Apr 4, 2013, 4:31:54 AM4/4/13
to java...@googlegroups.com
Just wild guess - is it possible that Simon is working with unwrapped connection, while without Simon you normally close the wrappped one? What if appserver asks for connection, Simon gives it to AS, AS then wraps it, but Simon close still closes the underlying connection for real?

I can't experiment with this too much as I don't have any setup like this up and running.

Gérald Quintana

unread,
Apr 4, 2013, 4:45:38 AM4/4/13
to java...@googlegroups.com
Long time ago, I had a problem with GlassFish, this is why I introduced the WrapperSupport class. It may still be buggy. I don't get why Simon would decide to close the SQL Server connection by itself.
You could try to add a log in SimonConnection.close and dump the stacktrace.
I might try to set up a SQL Server for testing, but my last attempt was a nightmare.

Gérald




2013/4/4 Richard Richter <vir...@gmail.com>

Gérald

unread,
Apr 7, 2013, 9:26:25 AM4/7/13
to java...@googlegroups.com
Hi Tim,

I set up a local SQL Server 2012 Express database, configured a GlassFish 3.1 datasource (SQL Server XA DataSource wrapped in Simon XA DataSource), deployed a stupid application using embedded JPA implementation to generate JDBC requests, but I can not reproduce your problem.I am using:
  • Windows 7
  • JDK 6 (implementing JDBC 4.0)
  • GlassFish 3.1.1
  • Microsoft SQL Server 2012 Express (known as 11.00.3128)
  • Microsoft JDBC Driver 4.0 for SQL Server 4.0.2206.100 implementing JDBC 4.0
  • Simon 3.1 from SVN (implementing JDBC 4.0)
Can you isolate the problem in a sample application with a trivial database schema?

Gérald
Reply all
Reply to author
Forward
0 new messages