FAQ
Hi,

I have a project with EJB3 Seam components. I write unit tests that will run
on OpenEJB, but I encounter a problem I can't find it is a Seam or OpenEJB
one.

I wrote a Seam component with CONVERSATION scope, i.e. a stateful session
bean. I wrote the following unit test for this component :

public void testSaveAndDeleteOrganizationType() throws
java.lang.Exception
{
new ComponentTest() {
public void testComponents() throws java.lang.Exception {

OrganizationInternalServiceLocal service =
(OrganizationInternalServiceLocal)
getInstance("organizationInternalService");

// Create a new organization type

OrganizationType newOrganizationType = new
OrganizationType();
newOrganizationType.setCode("ORG_TYPE_TEST");
newOrganizationType.setName("Test organization type");
newOrganizationType =
service.saveOrganizationType(newOrganizationType);
assert newOrganizationType.getId() != null;

// Create a duplicated organization type

try {
OrganizationType duplicatedOrganizationType = new
OrganizationType();
duplicatedOrganizationType.setCode("ORG_TYPE_TEST");
duplicatedOrganizationType.setName("Test organization
type");
duplicatedOrganizationType =
service.saveOrganizationType(duplicatedOrganizationType);
assert false;
}
catch (Exception exception){
assert true;
}

// Delete an organization type

service.deleteOrganizationType(newOrganizationType);
assert service.loadOrganizationType("ORG_TYPE_TEST") ==
null;

}
}.run();
}

I have a unique constraint on code property of organization type. So when I
try to save an organization type with a code that is already in database,
the saveOrganizationType is expected to throw an exception. Actually it
does, no problem about that. But further calls to the component, for example
deleteOrganizationType method, fail with the following stack trace :

testSaveAndDeleteOrganizationType(t4.core.commons.organization.internal.test.OrganizationInternalServiceTest)
Time elapsed: 0.156 sec <<< FAILURE!
javax.ejb.NoSuchEJBException: reference is invalid
at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.isValidReference(BaseEjbProxyHandler.java:319)
at
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:232)
at $Proxy135.deleteOrganizationType(Unknown Source)
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.jboss.seam.util.Reflections.invoke(Reflections.java:22)
at
org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at
org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at
org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:43)
at
org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at
org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
at
org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
at
org.javassist.tmp.java.lang.Object_$$_javassist_27.deleteOrganizationType(Object_$$_javassist_27.java)
at
t4.core.commons.organization.internal.test.OrganizationInternalServiceTest$26.testComponents(OrganizationInternalServiceTest.java:1276)
at
org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:163)
at
t4.core.commons.organization.internal.test.OrganizationInternalServiceTest.testSaveAndDeleteOrganizationType(OrganizationInternalServiceTest.java:1246)

If I set the component to STATELESS scope, i.e. staless session bean, my
unit test works OK ! So what I note is that throwing an exception from a
stateful session bean turns it to invalid. Do you think this is a problem
with OpenEJB or with Seam ?

Thanks in advance,

Olivier

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 4 | next ›
Discussion Overview
groupusers @
categoriesopenejb
postedNov 19, '08 at 3:09p
activeNov 24, '08 at 4:23p
posts4
users3
websiteopenejb.apache.org
irc#openejb

People

Translate

site design / logo © 2021 Grokbase