The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

mangelo (25) [Avatar] Offline
#1
Here is a snapshot of my console when trying to run the test from chapter 4. I have removed some of the lines for brevity.

WARNING: 
Local Exception Stack: 
Exception [EclipseLink-4011] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Error preallocating sequence numbers.  The sequence table information is not complete.
	at org.eclipse.persistence.exceptions.DatabaseException.errorPreallocatingSequenceNumbers(DatabaseException.java:150)
	at org.eclipse.persistence.sequencing.StandardSequence.getGeneratedVector(StandardSequence.java:73)
	at org.eclipse.persistence.sequencing.DefaultSequence.getGeneratedVector(DefaultSequence.java:163)
	at org.eclipse.persistence.sequencing.Sequence.getGeneratedVector(Sequence.java:257)
	at org.eclipse.persistence.internal.sequencing.SequencingManager$Preallocation_Transaction_NoAccessor_State.getNextValue(SequencingManager.java:468)
	at org.eclipse.persistence.internal.sequencing.SequencingManager.getNextValue(SequencingManager.java:1067)
	at org.eclipse.persistence.internal.sequencing.ClientSessionSequencing.getNextValue(ClientSessionSequencing.java:70)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:361)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:320)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.assignSequenceNumber(UnitOfWorkImpl.java:486)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist(UnitOfWorkImpl.java:4290)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist(RepeatableWriteUnitOfWork.java:518)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4235)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:496)
	at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:287)
	at org.imdb.MoviesService.createMovie(MoviesService.java:17)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)

	(many more lines here)

Mar 04, 2016 2:51:15 PM com.sun.ejb.containers.BaseContainer postInvoke
WARNING: A system exception occurred during an invocation on EJB MoviesService, method: public void org.imdb.MoviesService.createMovie(org.imdb.Movie)
Mar 04, 2016 2:51:15 PM com.sun.ejb.containers.BaseContainer postInvoke
WARNING: 
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean
	at com.sun.ejb.containers.EJBContainerTransactionManager.checkExceptionClientTx(EJBContainerTransactionManager.java:662)
	at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:507)
	at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4566)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2074)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2044)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
	at com.sun.proxy.$Proxy187.createMovie(Unknown Source)
	at org.imdb.__EJB31_Generated__MoviesService__Intf____Bean__.createMovie(Unknown Source)
	at org.imdb.MoviesServiceTest.shouldCreateMovies(MoviesServiceTest.java:61)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.jboss.arquillian.junit.Arquillian$8$1.invoke(Arquillian.java:370)
	at org.jboss.arquillian.container.test.impl.execution.LocalTestExecuter.execute(LocalTestExecuter.java:60)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

	(many more lines here)

Caused by: Exception [EclipseLink-4011] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Error preallocating sequence numbers.  The sequence table information is not complete.
	at org.eclipse.persistence.exceptions.DatabaseException.errorPreallocatingSequenceNumbers(DatabaseException.java:150)
	at org.eclipse.persistence.sequencing.StandardSequence.getGeneratedVector(StandardSequence.java:73)
	at org.eclipse.persistence.sequencing.DefaultSequence.getGeneratedVector(DefaultSequence.java:163)
	at org.eclipse.persistence.sequencing.Sequence.getGeneratedVector(Sequence.java:257)
	at org.eclipse.persistence.internal.sequencing.SequencingManager$Preallocation_Transaction_NoAccessor_State.getNextValue(SequencingManager.java:468)
	at org.eclipse.persistence.internal.sequencing.SequencingManager.getNextValue(SequencingManager.java:1067)
	at org.eclipse.persistence.internal.sequencing.ClientSessionSequencing.getNextValue(ClientSessionSequencing.java:70)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:361)
	at org.eclipse.persistence.internal.descriptors.ObjectBuilder.assignSequenceNumber(ObjectBuilder.java:320)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.assignSequenceNumber(UnitOfWorkImpl.java:486)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist(UnitOfWorkImpl.java:4290)
	at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist(RepeatableWriteUnitOfWork.java:518)
	at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:4235)
	at org.eclipse.persistence.internal.jpa.EntityManagerImpl.persist(EntityManagerImpl.java:496)

[http-listener(3)] WARN org.dbunit.dataset.AbstractTableMetaData - Potential problem found: The configured data type factory 'class org.dbunit.dataset.datatype.DefaultDataTypeFactory' might cause problems with the current database 'HSQL Database Engine' (e.g. some datatypes may not be supported properly). In rare cases you might see this message because the list of supported database products is incomplete (list=[derby]). If so please request a java-class update via the forums.If you are using your own IDataTypeFactory extending DefaultDataTypeFactory, ensure that you override getValidDbProducts() to specify the supported database products.
[http-listener(3)] ERROR org.dbunit.assertion.DbUnitAssert - org.dbunit.assertion.DbComparisonFailure[row count (table=MOVIE)expected:<2>but was:<0>]
Mar 04, 2016 2:51:15 PM org.eclipse.persistence.session.file:/var/folders/bv/tbvj2m_j24lczg38q0rd62sr0000gn/T/gfembed2585069121891231399tmp/applications/986d0650-fa98-4487-b791-a293a3abb09a/WEB-INF/classes/_arquillian-hsql.connection
INFO: file:/var/folders/bv/tbvj2m_j24lczg38q0rd62sr0000gn/T/gfembed2585069121891231399tmp/applications/986d0650-fa98-4487-b791-a293a3abb09a/WEB-INF/classes/_arquillian-hsql logout successful
Mar 04, 2016 2:51:15 PM org.glassfish.persistence.common.Java2DBProcessorHelper logI18NWarnMessage
WARNING: Cannot drop tables for application 986d0650-fa98-4487-b791-a293a3abb09a. The expected DDL file 986d0650-fa98-4487-b791-a293a3abb09a_arquillian-hsql_dropDDL.jdbc is not available.
PlainTextActionReporterSUCCESS
Cannot drop tables for application 986d0650-fa98-4487-b791-a293a3abb09a. The expected DDL file 986d0650-fa98-4487-b791-a293a3abb09a_arquillian-hsql_dropDDL.jdbc is not available.Mar 04, 2016 2:51:15 PM org.glassfish.admin.mbeanserver.JMXStartupService shutdown
INFO: JMXStartupService and JMXConnectors have been shut down.
JdbcRuntimeExtension,  getAllSystemRAResourcesAndPools = [GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcConnectionPool, GlassFishConfigBean.org.glassfish.jdbc.config.JdbcResource]
Mar 04, 2016 2:51:15 PM com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl sendStopToResourceAdapter
INFO: RAR7094: __dm_jdbc_ra shutdown successful.
Mar 04, 2016 2:51:15 PM com.sun.enterprise.v3.server.AppServerStartup stop
INFO: Shutdown procedure finished

mangelo (25) [Avatar] Offline
#2
I found the simple fix. Just add the strategy to the GeneratedValue annotation.

public class Movie {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private long id;

...

Andy Gumbrecht (9) [Avatar] Offline
#3
Hi Mangelo,

I hope this got fixed before we went to print. The default is GenerationType.AUTO, which should work with most JPA providers out of the box (and is often IDENTITY). So maybe it was just a impl version causing the issue.

Thanks for the feedback,

Andy.