Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ejb3unit interceptors  RSS feed

 
Brian Merker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using ejb3unit to test a session bean. This beans method has an @interceptor attribute.
When I execute the test from ejb3unit the interceptors invokeInteceptor method is not executed.
Does anyone know if ejb3unit supports interceptors?
Thanks
 
Thomas Fra
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying the same thing with the 2.0.0-SNAPSHOT version of ejb3unit and I have the following error :
java.lang.ClassCastException: org.ejb3unit.asm.jar.Type
at com.bm.ejb3metadata.annotations.analyzer.JavaxInterceptorInterceptorsVisitor.visitEnd(JavaxInterceptorInterceptorsVisitor.java:37)
at org.ejb3unit.asm.jar.ClassReader.a(Unknown Source)
at org.ejb3unit.asm.jar.ClassReader.a(Unknown Source)
at org.ejb3unit.asm.jar.ClassReader.a(Unknown Source)
at org.ejb3unit.asm.jar.ClassReader.accept(Unknown Source)
at org.ejb3unit.asm.jar.ClassReader.accept(Unknown Source)
at com.bm.ejb3metadata.MetadataAnalyzer.read(MetadataAnalyzer.java:113)
at com.bm.ejb3metadata.MetadataAnalyzer.analyze(MetadataAnalyzer.java:79)
at com.bm.ejb3metadata.MetadataAnalyzer.analyzeClasses(MetadataAnalyzer.java:49)
at com.bm.ejb3metadata.MetadataAnalyzer.initialize(MetadataAnalyzer.java:36)
at com.bm.ejb3metadata.annotations.metadata.MetaDataCache.getMetaData(MetaDataCache.java:128)
at com.bm.ejb3metadata.annotations.metadata.MetaDataCache.getMockModuleCreator(MetaDataCache.java:152)
at com.bm.testsuite.mocked.MockedSessionBeanFixture.setUp(MockedSessionBeanFixture.java:89)
at com.bm.testsuite.junit4.MockedSessionBeanJUnit4Fixture.setUp(MockedSessionBeanJUnit4Fixture.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:122)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:86)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:165)
at org.apache.maven.surefire.Surefire.run(Surefire.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:289)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:993)
 
Brian Merker
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran into this issue as well. I had to replace this import: import org.objectweb.asm.Type;
with this one: import org.ejb3unit.asm.jar.Type;
In the following classes

com/bm/ejb3metadata/annotations/analyzer/JavaxEjbEJBVisitor.java
com/bm/ejb3metadata/annotations/analyzer/classes/JavaxEjbLocalVisitor.java
com/bm/ejb3metadata/annotations/analyzer/JavaxInterceptorInterceptorsVisitor.java

 
Thomas Fra
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is quite complicated to rebuild all the project. if you have already done it, can you post the modified classes ?
Many thanks

Thomas
 
Jc Plessis
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
this post is quite old but that's the one I fell upon when I saw this problem...

So I did what was explained and it worked quite well... To avoid having to do it again and again I posted the jar at the followinf URL : http://jplessis.free.fr/upload/
RC2 corrects this problem while RC3 also corrects another problem with Cobertura...

Have fun,
JC
 
Christian Peacock
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi JC,

I downloaded RC3 to try and fix a problem I have with running entity bean tests using EJBUnit 1.2, but I get this problem:

junit.framework.AssertionFailedError: Exception in constructor: testWrite (java.lang.NoClassDefFoundError: Could not initialize class com.bm.utils.injectinternal.InternalInjector

...And in the output from Maven (prior to the start of the tests) I get this:

ERROR EntityManagerProvider:51 - java.io.FileNotFoundException: Unable to find any persistence.xml file on the classpath!!!

I do have a persistence.xml file in my test/resources directory which looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="ASBHostRequestingPersistenceUnit">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>

<class>uk.bl.bspa.asp.requesting.data.Request</class>
<class>uk.bl.bspa.asp.requesting.data.RequestingUser</class>

</persistence-unit>
</persistence>

Please can you help?

Many thanks,
Chris.

Jc Plessis wrote:
...
RC2 corrects this problem while RC3 also corrects another problem with Cobertura...
...
 
Christian Peacock
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've solved the problem - I needed to have the persistence.xml file in test/resources/META-INF. It was as simple as that!

(I still have a problem with dates though - I've posted here.)

I don't normally resort to asking for help without trying absolutely everything, but I'm getting short of time with my project and desperate to get things working.

Cheers,
Chris.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!