Как настроить источник данных sqlite для JPA в Websphere Liberty? - PullRequest
0 голосов
/ 21 февраля 2019

Я пытаюсь использовать sqlite как постоянный слой в моем приложении и взаимодействовать с ним через JPA.Но всякий раз, когда я подключаюсь либо для чтения, либо для записи, я получаю исключение java.sql.SQLException.

Я использую Websphere Liberty webProfile8 19.0.0.1 с EclipseLink 2.6.8 в качестве поставщика JPA.

Существует скрипт загрузки, который помещает некоторые исходные данные в таблицу TEST_ENTITY, и он работает без проблем.Вероятно, способ, которым JPA управляет соединениями БД для сущностей, отличается.

Если я переключаюсь на источник данных Apache Derby, все работает просто отлично.

Кто-нибудь сталкивался с чем-то подобным?

server.xml:

<library id="sqlitelib">
    <fileset dir="${shared.resource.dir}/libs" id="sqlite-jdbc" includes="sqlite-jdbc-3.23.1.jar"/>
</library>

<dataSource id="annodb" 
   type="javax.sql.DataSource"
   isolationLevel="TRANSACTION_SERIALIZABLE"
   jndiName="jdbc/annodb">
    <jdbcDriver          
        javax.sql.ConnectionPoolDataSource="org.sqlite.javax.SQLiteConnectionPoolDataSource" 
        javax.sql.DataSource="org.sqlite.SQLiteDataSource" 
        libraryRef="sqlitelib"/>
    <properties URL="jdbc:sqlite:c:/__anno.db"/>
</dataSource>

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="annodb">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/annodb</jta-data-source>
        <!-- non-jta-data-source>jdbc/annodb</non-jta-data-source-->            
        <class>com.ibm.zurich.ainews.domain.anno.entities.TestEntity</class>
        <properties>
            <!--property name="eclipselink.ddl-generation.output-mode" value="both"/-->
            <property name="eclipselink.logging.level" value="ALL"/>
            <property name="eclipselink.logging.logger" value="ServerLogger"/>
            <property name="eclipselink.create-ddl-jdbc-file-name" value="createSchemaDDL.sql"/>
            <property name="eclipselink.drop-ddl-jdbc-file-name" value="dropSchemaDDL.sql"/>
            <property name="eclipselink.weaving" value="false"/>
            <property name="javax.persistence.schema-generation.scripts.create-target" value="create.ddl"/>
            <property name="javax.persistence.sql-load-script-source" value="load.sql"/>
            <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
            <property name="javax.persistence.schema-generation.scripts.action" value="drop-and-create"/>
            <property name="eclipselink.jdbc.native-sql" value="false"/>
            <property name="javax.persistence.schema-generation.scripts.drop-target" value="drop.ddl"/>
        </properties>
    </persistence-unit>
</persistence>

трассировка полного стека:

[2/21/19 23:33:32:462 CET] 000000e0 connection    3   client acquired: 642755657
[2/21/19 23:33:32:465 CET] 000000e0 transaction   3   TX binding to tx mgr, status=STATUS_ACTIVE
[2/21/19 23:33:32:465 CET] 000000e0 transaction   3   acquire unit of work: -1982630449
[2/21/19 23:33:32:465 CET] 000000e0 transaction   3   begin unit of work flush
[2/21/19 23:33:32:465 CET] 000000e0 transaction   3   end unit of work flush
[2/21/19 23:33:32:465 CET] 000000e0 query         3   Execute query ReadAllQuery(name="TestEntity.findAll" referenceClass=TestEntity sql="SELECT PKEY, FIELD FROM TEST_ENTITY")
[2/21/19 23:33:32:466 CET] 000000e0 connection    3   Connection acquired from connection pool [read].
[2/21/19 23:33:32:466 CET] 000000e0 connection    3   reconnecting to external connection pool
[2/21/19 23:33:32:467 CET] 000000e0 sql           3   SELECT PKEY, FIELD FROM TEST_ENTITY
[2/21/19 23:33:32:477 CET] 000000e0 connection    3   Connection released to connection pool [read].
[2/21/19 23:33:32:477 CET] 000000e0 eclipselink   W   CWWJP9991W: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.8.WAS-v20181218-0accd7f): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: statement is not executing
Error Code: 0
Query: ReadAllQuery(name="TestEntity.findAll" referenceClass=TestEntity sql="SELECT PKEY, FIELD FROM TEST_ENTITY")
[2/21/19 23:33:32:478 CET] 000000e0 BusinessExcep E   CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "testRead" on bean "BeanId(ear#war-0.0.1-SNAPSHOT.war#AnnoMgr, null)". Exception data: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.8.WAS-v20181218-0accd7f): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: statement is not executing
Error Code: 0
Query: ReadAllQuery(name="TestEntity.findAll" referenceClass=TestEntity sql="SELECT PKEY, FIELD FROM TEST_ENTITY")
    at org.eclipse.persistence.internal.jpa.QueryImpl.getDetailedException(QueryImpl.java:382)
    at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:260)
    at org.eclipse.persistence.internal.jpa.QueryImpl.getResultList(QueryImpl.java:473)
    at com.ibm.zurich.ainews.domain.anno.mgr.AnnoMgr.testRead(AnnoMgr.java:72)
    at sun.reflect.GeneratedMethodAccessor1196.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:4886)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:592)
    at com.ibm.ws.cdi.ejb.impl.InterceptorChain.proceed(InterceptorChain.java:119)
    at com.ibm.ws.cdi.ejb.impl.EJBCDIInterceptorWrapper.invokeInterceptors(EJBCDIInterceptorWrapper.java:131)
    at com.ibm.ws.cdi.ejb.impl.EJBCDIInterceptorWrapper.aroundInvoke(EJBCDIInterceptorWrapper.java:54)
    at sun.reflect.GeneratedMethodAccessor1195.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:189)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:577)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)
    at com.ibm.ws.cdi.ejb.interceptor.WeldSessionBeanInterceptorWrapper.aroundInvoke(WeldSessionBeanInterceptorWrapper.java:58)
    at sun.reflect.GeneratedMethodAccessor1194.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:189)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:577)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInterceptor(InvocationContextImpl.java:298)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:267)
    at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:4788)
    at com.ibm.zurich.ainews.domain.anno.mgr.EJSLocalNSLAnnoMgr_99272aa0.testRead(EJSLocalNSLAnnoMgr_99272aa0.java)
    at com.ibm.zurich.ainews.api.stories.svc.TestSvc.testAnnoDB(TestSvc.java:71)
    at sun.reflect.GeneratedMethodAccessor1184.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:4886)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:592)
    at com.ibm.ws.cdi.ejb.impl.InterceptorChain.proceed(InterceptorChain.java:119)
    at com.ibm.ws.cdi.ejb.impl.EJBCDIInterceptorWrapper.invokeInterceptors(EJBCDIInterceptorWrapper.java:131)
    at com.ibm.ws.cdi.ejb.impl.EJBCDIInterceptorWrapper.aroundInvoke(EJBCDIInterceptorWrapper.java:54)
    at sun.reflect.GeneratedMethodAccessor1195.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:189)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:577)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:64)
    at com.ibm.ws.cdi.ejb.interceptor.WeldSessionBeanInterceptorWrapper.aroundInvoke(WeldSessionBeanInterceptorWrapper.java:58)
    at sun.reflect.GeneratedMethodAccessor1194.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:189)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:577)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInterceptor(InvocationContextImpl.java:298)
    at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:267)
    at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:4788)
    at com.ibm.zurich.ainews.api.stories.svc.EJSLocalNSLTestSvc_32d4537b.testAnnoDB(EJSLocalNSLTestSvc_32d4537b.java)
    at sun.reflect.GeneratedMethodAccessor1184.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at com.ibm.ws.jaxrs20.ejb.JaxRsFactoryBeanEJBCustomizer.serviceInvoke(JaxRsFactoryBeanEJBCustomizer.java:333)
    at com.ibm.ws.jaxrs20.server.LibertyJaxRsServerFactoryBean.performInvocation(LibertyJaxRsServerFactoryBean.java:637)
    at com.ibm.ws.jaxrs20.server.LibertyJaxRsInvoker.performInvocation(LibertyJaxRsInvoker.java:160)
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
    at com.ibm.ws.jaxrs20.server.LibertyJaxRsInvoker.invoke(LibertyJaxRsInvoker.java:273)
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:191)
    at com.ibm.ws.jaxrs20.server.LibertyJaxRsInvoker.invoke(LibertyJaxRsInvoker.java:444)
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:101)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:61)
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:99)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:309)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:124)
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:271)
    at com.ibm.ws.jaxrs20.endpoint.AbstractJaxRsWebEndpoint.invoke(AbstractJaxRsWebEndpoint.java:134)
    at com.ibm.websphere.jaxrs.server.IBMRestServlet.handleRequest(IBMRestServlet.java:146)
    at com.ibm.websphere.jaxrs.server.IBMRestServlet.doGet(IBMRestServlet.java:112)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
    at com.ibm.websphere.jaxrs.server.IBMRestServlet.service(IBMRestServlet.java:96)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1255)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:743)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:440)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1221)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1005)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:75)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:923)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:279)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1047)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:417)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:376)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:532)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:466)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:331)
    at com.ibm.ws.http.channel.internal.inbound.HttpICLReadCallback.complete(HttpICLReadCallback.java:70)
    at com.ibm.ws.channel.ssl.internal.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1803)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:501)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:571)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:926)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1015)
    at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:239)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.lang.Thread.run(Thread.java:785)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.8.WAS-v20181218-0accd7f): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: statement is not executing
Error Code: 0
Query: ReadAllQuery(name="TestEntity.findAll" referenceClass=TestEntity sql="SELECT PKEY, FIELD FROM TEST_ENTITY")
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:331)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:713)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:560)
    at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:2061)
    at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:586)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:262)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:248)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:319)
    at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:715)
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2767)
    at org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2720)
    at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:559)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1175)
    at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:911)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1134)
    at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:460)
    at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1222)
    at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2899)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1863)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1845)
    at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1810)
    at org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery(QueryImpl.java:258)
    ... 89 more
Caused by: java.sql.SQLException: statement is not executing
    at org.sqlite.core.CoreStatement.checkOpen(CoreStatement.java:50)
    at org.sqlite.jdbc3.JDBC3PreparedStatement.clearParameters(JDBC3PreparedStatement.java:37)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.closeWrapper(WSJdbcPreparedStatement.java:316)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcObject.close(WSJdbcObject.java:152)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcObject.close(WSJdbcObject.java:110)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.closeStatement(DatabaseAccessor.java:410)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.releaseStatement(DatabaseAccessor.java:1674)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:705)
    ... 109 more
...