[jboss-as7-dev] simple H2DS using web app

Scott Marlow smarlow at redhat.com
Sat Apr 30 09:23:14 EDT 2011


To workaround, in standalone.xml, use the following url:

<datasource jndi-name="java:/H2DS" pool-name="H2DS" enabled="true" 
use-java-context="true">
  <connection-url>
   jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
  </connection-url>

Scott




On 04/30/2011 08:58 AM, Ales Justin wrote:
> OK, got around the NPE issue (see below on how), and got as expected :-)
>
> 14:55:55,631 ERROR [org.hibernate.tool.hbm2ddl.SchemaExport] schema export unsuccessful: org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-144]
> 	at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
> 	at org.h2.message.DbException.get(DbException.java:167)
> 	at org.h2.message.DbException.get(DbException.java:144)
> 	at org.h2.message.DbException.get(DbException.java:133)
> 	at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1329)
> 	at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1304)
> 	at org.h2.jdbc.JdbcConnection.setAutoCommit(JdbcConnection.java:360)
> 	at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.checkTransaction(BaseWrapperManagedConnection.java:773)
> 	at org.jboss.jca.adapters.jdbc.WrappedConnection.checkTransaction(WrappedConnection.java:1559)
> 	at org.jboss.jca.adapters.jdbc.WrappedConnection.createStatement(WrappedConnection.java:287)
> 	at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:265)
> 	at org.hibernate.tool.hbm2ddl.SchemaExport.drop(SchemaExport.java:229)
> 	at org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:961)
> 	at org.hibernate.ejb.EntityManagerFactoryImpl.close(EntityManagerFactoryImpl.java:127)
> 	at org.jboss.as.jpa.service.PersistenceUnitService.stop(PersistenceUnitService.java:88)
> 	at org.jboss.msc.service.ServiceControllerImpl$StopTask.run(ServiceControllerImpl.java:1779)
>
>> The test/example app using H2DS with JPA is here:
>> * https://github.com/alesj/hib-in-war/tree/as7
>>
>> I'm getting this when deploying
>>
>> Caused by: java.lang.NullPointerException
>> 	at org.jboss.as.ejb3.deployment.processors.TransactionAttributeAnnotationProcessor.processClassAnnotations(TransactionAttributeAnnotationProcessor.java:85)
>>
>> Let me check what the problem might be ...
>
> Adding explicit value() helped:
>
> @TransactionAttribute(TransactionAttributeType.REQUIRED)
>
> NPE code --->             TransactionAttributeType transactionAttributeType = TransactionAttributeType.valueOf(annotationInstance.value().asEnum());
>
>> On Apr 29, 2011, at 8:04 PM, Scott Marlow wrote:
>>
>>> Also, I think changing the jdbc url to the following might disable their shutdownhook:
>>>
>>> connection-url>jdbc:h2:mem:test;DB_CLOSE_ON_EXIT=FALSE,DB_CLOSE_DELAY=-1</connection-url>
>>>
>>>
>>>
>>> On 04/29/2011 01:58 PM, Scott Marlow wrote:
>>>>  From what I can tell, using MySQL might help but some other ideas.
>>>>
>>>> I looked at http://www.h2database.com/html/features.html and it seems
>>>> that the jdbc url should be okay. We currently have:
>>>>
>>>> connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
>>>>
>>>> That should keep the H2 database open until its no longer needed. I
>>>> wonder if H2 has a "on shutdown hook" being invoked too early.
>>>>
>>>> I verified that we have proper dependencies (at least for my test app):
>>>> http://pastebin.com/DDFEks1u
>>>>
>>>>
>>>> On 04/29/2011 01:01 PM, Scott Marlow wrote:
>>>>> On 04/29/2011 12:21 PM, Scott Marlow wrote:
>>>>>> If you run a local database server, that might be a workaround.
>>>>>
>>>>> Or maybe not, if its the database pool that is getting closed, too
>>>>> early, it won't help to use an external server.
>>>>>
>>>>
>>>
>>
>



More information about the jboss-as7-dev mailing list