Moving from persistence-impl to persistence-dbunit with openejb-embedded-4


#1

Hi,
I’m trying to move my app from using persistence-impl@Alpha6 to persistence-dbunit@Alpha7 and I’m
unable to get the DBUnit actions executed.

I used this example to get my app running with impl:

So for dbunit I changed org.jboss.arquillian.persistence.core.container.RemotePersistenceExtension to
org.jboss.arquillian.persistence.dbunit.container.RemoteDBUnitExtension in the file
META-INF/services/org.jboss.arquillian.core.spi.LoadableExtension
but when I run the app my dbunit annotations are not executed.

Any suggestions?

Thanks

George



#2

Hi,

apologies for late response, somehow I cannot recall getting the notification about this thread.

Having more details now I will test against embedded containers (besides Glassfish which is already part of the test suite) and fix.

I am aiming for the release pretty soon (matter of days) so this improvement, if it will mean some code changes will land in.

Cheers,
Bartosz


#3

Any luck with openejb embedded?


#4

Didn’t have time yet to test it in details. Pretty busy with regular work :\

I’m off for holidays this week and will be back 23.05. I will take care of it immediately upon my arrival.


#5

OK.

Any pointers as to what I can try to figure it our?

Also, any thoughts on my third party jpa/Hibernate question?

Thanks


#6

Any progress?

Thanks
George


#7

I tried to figure out what changed between impl Alpha6 and dbunit Alpha7 and realized that I needed to add “org.jboss.arquillian.persistence.dbunit.container.RemoteDBUnitExtension” to the LoadableExtension file.
So that gets dbunit enabled but now I’m getting this Class Cast Exception:

java.lang.ClassCastException: org.jboss.arquillian.persistence.core.event.ApplyScriptsBeforeTest cannot be cast to org.jboss.arquillian.persistence.dbunit.event.CompareDBUnitData
at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.compare(DBUnitDataHandler.java:61)


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.core.impl.ManagerImpl.fire(ManagerImpl.java:145)
at org.jboss.arquillian.core.impl.ManagerImpl.fire(ManagerImpl.java:116)
at org.jboss.arquillian.core.impl.EventImpl.fire(EventImpl.java:67)
at org.jboss.arquillian.persistence.core.lifecycle.CustomScriptsExecutor.executeScriptsBeforeTest(CustomScriptsExecutor.java:66)
at org.jboss.arquillian.persistence.core.lifecycle.CustomScriptsExecutor.executeBeforeTest(CustomScriptsExecutor.java:53)

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:95)

at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:88)
at org.apache.openejb.arquillian.common.TestObserver.observes(TestObserver.java:61)

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:61)

George


#8

This is odd and shouldn’t be really the case. I will investigate and let you know by the end of this week,


#9

Have you found anything?


#10

If you could share your project demonstrating the issue through GitHub that would help me investigating the problem.

Having very limited time last few weeks I couldn’t reproduce it yet. Apologies.


#11

I think @lindholm is having issues with jdk version, had the same error some time ago when running arq extension int-tests:

java.lang.ClassCastException: org.jboss.arquillian.persistence.core.event.ApplyScriptsBeforeTest cannot be cast to org.jboss.arquillian.persistence.dbunit.event.CompareDBUnitData
at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.compare(DBUnitDataHandler.java:61)

In my case I’ve had to change to jdk 7. Its a bit weird issue because sometimes it works with jdk8, see details here: Help running arquillian persistence int-tests


#12

Hi guys,

quick follow-up from my side. It’s apparently changed behaviour of JDK and the way how methods are now handled. When we scan for observers we not only register actual methods, but also bridge methods. As we try to invoke them too, it leads to the nasty

java.lang.ClassCastException: org.jboss.arquillian.persistence.core.event.ApplyScriptsBeforeTest cannot be cast to org.jboss.arquillian.persistence.dbunit.event.CompareDBUnitData
at org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.compare(DBUnitDataHandler.java:61)

I’ve figured out this problem while debugging Arquillian Persistence Extension build with JDK7 but run on WildFly 9 (on JDK8).

Here’s how the DBUnitDataHandler observer is scanned:

clazz.getDeclaredMethods() = {Method[11]@11763} 
 0 = {Method@11801} "public void org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.executeScripts(org.jboss.arquillian.persistence.core.event.ExecuteScripts)"
 1 = {Method@11802} "private void org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.executeScript(java.lang.String)"
 2 = {Method@11803} "private void org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.seedDatabase() throws java.lang.Exception"
 3 = {Method@11804} "private org.dbunit.operation.DatabaseOperation org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.seedingStrategy()"
 4 = {Method@11805} "private void org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.cleanDatabase(org.jboss.arquillian.persistence.CleanupStrategy)"
 5 = {Method@11806} "public void org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.cleanupUsingScript(org.jboss.arquillian.persistence.core.event.CleanupDataUsingScript)"
 6 = {Method@11807} "public void org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.compare(org.jboss.arquillian.persistence.core.event.DataEvent)"
 7 = {Method@11808} "public void org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.compare(org.jboss.arquillian.persistence.dbunit.event.CompareDBUnitData)"
 8 = {Method@11809} "public void org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.prepare(org.jboss.arquillian.persistence.core.event.DataEvent)"
 9 = {Method@11810} "public void org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.prepare(org.jboss.arquillian.persistence.dbunit.event.PrepareDBUnitData)"
 10 = {Method@11811} "public void org.jboss.arquillian.persistence.dbunit.DBUnitDataHandler.cleanup(org.jboss.arquillian.persistence.core.event.CleanupData)"

Entry 6 and 8 are bridge methods which are inferred from the interface this observer is implementing. Then when the test is executed Arquillian tries to call each and every captured method resulting in aforementioned error.

Some more details:

I’m about to bring the fix to Arquillian Core and release new version of Arquillian Persistence Extension shortly after (with additional features).


#13

Good news and great work @bartoszmajsak!


#14

Fix has beed pushed upstream

https://issues.jboss.org/browse/ARQ-2042

APE seems to be working fine at least with WF9. About to test on the other ones.