4 Replies Latest reply on May 23, 2013 4:13 AM by Tommy Tynjä

    Arquillian Persistence Extension: Value too long

    Tommy Tynjä Newbie

      I'm currently trying to reproduce a production bug in a legacy codebase with the use of Arquillian Persistence Exception (APE).

       

      I've created a dataset representing my database row as json, and specifiying that file in @UsingDataSet. My dataset contains an entity with data copied from our production environment. The entity contains a column named json which has a length which can be greater than 255, which it is for this particular entity. When seeding the database with APE, I get an exception with the message "Value too long for column "JSON VARCHAR(255)".

       

      The json column of the specified entity is marked with @Column without any length specified (which defaults to 255). In our database schema this column is declared as character varying with an unspecified length. In Postgres which we use in production, a character varying column with unspecified length will accept a string of any length. From the Postgres documentation: "If character varying is used without length specifier, the type accepts strings of any size. The latter is a PostgreSQL extension." ([http://www.postgresql.org/docs/9.1/static/datatype-character.html]). The mismatch between JPA mapping and database schema is unfortunate, but cannot be changed at this point.

       

      I would be able to reproduce this behavior with Arquillian. One workaround is to specify the length of the column in the @Column annotation, which makes me being able to run the test locally. I can however not change the length attribute of the column at this point as it might cascade into other problems in the current codebase. I would like to checkin a failing test case (failing on an assertion obviously) in our codebase so it can be run in Continuous Integration, without altering the length of the column in the JPA mapping that is.

       

      How can I solve this issue?

       

      Test case:

          @Test

          @UsingDataSet(testDataSet)

          public void shouldSeedDatabase() { // does nothing

          }

       

       

      org.jboss.arquillian.persistence.dbunit.exception.DBUnitDataSetHandlingException: Failed while seeding database.

          at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.prepare(DBUnitDataHandler.java:81)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

          at org.jboss.arquillian.persistence.dbunit.DBUnitDataStateLogger.aroundDataSeeding(DBUnitDataStateLogger.java:106)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

          at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

          at org.jboss.arquillian.persistence.core.lifecycle.DataSetHandler.prepareDatabase(DataSetHandler.java:62)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

          at org.jboss.arquillian.persistence.dbunit.DBUnitDataStateLogger.beforePersistenceTest(DBUnitDataStateLogger.java:98)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.persistence.core.lifecycle.SchemaCreationScriptsExecutor.createSchema(SchemaCreationScriptsExecutor.java:72)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.persistence.dbunit.DBUnitPersistenceTestLifecycleHandler.createDatasets(DBUnitPersistenceTestLifecycleHandler.java:106)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.persistence.dbunit.DBUnitPersistenceTestLifecycleHandler.createDatabaseConnection(DBUnitPersistenceTestLifecycleHandler.java:87)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.persistence.core.lifecycle.ErrorCollectorHandler.createErrorCollector(ErrorCollectorHandler.java:38)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

          at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)

          at org.jboss.arquillian.persistence.core.lifecycle.PersistenceTestTrigger.beforeTest(PersistenceTestTrigger.java:104)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)

          at org.jboss.arquillian.test.impl.TestContextHandler.createTestContext(TestContextHandler.java:89)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.test.impl.TestContextHandler.createClassContext(TestContextHandler.java:75)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.test.impl.TestContextHandler.createSuiteContext(TestContextHandler.java:60)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)

          at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:135)

          at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:115)

          at org.jboss.arquillian.test.impl.EventTestRunnerAdaptor.before(EventTestRunnerAdaptor.java:95)

          at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:222)

          at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

          at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

          at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:240)

          at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

          at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

          at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

          at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

          at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

          at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

          at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

          at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:185)

          at org.jboss.arquillian.junit.Arquillian.multiExecute(Arquillian.java:314)

          at org.jboss.arquillian.junit.Arquillian.access$100(Arquillian.java:46)

          at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:199)

          at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

          at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:147)

          at org.junit.runner.JUnitCore.run(JUnitCore.java:157)

          at org.junit.runner.JUnitCore.run(JUnitCore.java:136)

          at org.jboss.arquillian.junit.container.JUnitTestRunner.execute(JUnitTestRunner.java:65)

          at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.executeTest(ServletTestRunner.java:160)

          at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.execute(ServletTestRunner.java:126)

          at org.jboss.arquillian.protocol.servlet.runner.ServletTestRunner.doGet(ServletTestRunner.java:90)

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

          at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

          at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)

          at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)

          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

          at java.lang.Thread.run(Thread.java:722)

      Caused by: org.jboss.arquillian.test.spi.ArquillianProxyException: org.h2.jdbc.JdbcSQLException : Value too long for column "JSON VARCHAR(255)": "... (1412)"; SQL statement:

      insert into MY_TABLE (ID, A, B, C, JSON, TIMESTAMP, X, Y, Z) values (?, ?, ?, ?, ?, ?, ?, ?, ?) [22001-161] [Proxied because : Original exception not deserilizable, ClassNotFoundException]

          at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)

          at org.h2.message.DbException.get(DbException.java:169)

          at org.h2.table.Column.validateConvertUpdateSequence(Column.java:320)

          at org.h2.table.Table.validateConvertUpdateSequence(Table.java:679)

          at org.h2.command.dml.Insert.insertRows(Insert.java:120)

          at org.h2.command.dml.Insert.update(Insert.java:84)

          at org.h2.command.CommandContainer.update(CommandContainer.java:73)

          at org.h2.command.Command.executeUpdate(Command.java:219)

          at org.h2.jdbc.JdbcPreparedStatement.execute(JdbcPreparedStatement.java:181)

          at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.execute(WrappedPreparedStatement.java:404)

          at org.dbunit.database.statement.SimplePreparedStatement.addBatch(SimplePreparedStatement.java:80)

          at org.dbunit.database.statement.AutomaticPreparedBatchStatement.addBatch(AutomaticPreparedBatchStatement.java:70)

          at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:195)

          at org.dbunit.operation.TransactionOperation.execute(TransactionOperation.java:78)

          at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.fillDatabase(DBUnitDataHandler.java:144)

          at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.prepare(DBUnitDataHandler.java:77)

          ... 156 more

       

       

      Please note that I've masked the actual column value and the insert sql statement in the stacktrace above.