2

I have several @Stateful SessionBeans annotated like this:

@Stateful
@Remote(AdminFacade.class)
public class TAdminFacadeBean implements TgAdminFacade,Serializable
{
   ...
}

Now I want to test them with Arquillian (1.0.0.Alpha5), but get lot's of different errors, messages vary either if the annotations are @Stateful or @Stateless, if a @Named is added or if there is no @Remote (and implements Interface).

Steps to reproduce:

  • Create new maven project with archetype org.jboss.weld.archetypes:jboss-javaee6-webapp:1.0.1.CR2
  • You might need to set jboss.home (see readme.txt)
  • Modify pom.xml and set profiles.profile[id=default].build.plugins.plugin[artifactId=maven-surefire-plugin].configuration.skip to false
  • Start JBoss-6.0.0.Final
  • Execute test (should pass): mvn test -Parq-jbossas-remote

The bean tested here ist MemberRegistration:

@Model
public class MemberRegistration
{
   ...
}

If you now change @Model to @Stateful, JBoss loops with stacktraces, with @Named @Stateful this error:

java.lang.IllegalArgumentException: ArquillianServletRunner not found.
Could not determine ContextRoot from ProtocolMetadata, please contact
DeployableContainer developer.

@Named @Stateless:

javax.transaction.NotSupportedException: BaseTransaction.checkTransactionState
- ARJUNA-16051 thread is already associated with a transaction!

How can I test my @Stateful Beans with Arquillian?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Thor
  • 6,607
  • 13
  • 62
  • 96

1 Answers1

4

Over and over again working in this issue I figured out the solution. Even I hate answering my own question I hope this can help somebody in the future.

The annotation for the @Stateful session bean (at the top of the question) are correct and stay the same. In the Arquillian test case the bean was originally injected with

@Inject MemberRegistration memberRegistration;

This works with @Model beans but not with @Stateful session beans and a @Remote interface. It seems this kind of beans must be injected with

@EJB private AdminFacade adminBean;

See What is the difference between @Inject and @EJB

Community
  • 1
  • 1
Thor
  • 6,607
  • 13
  • 62
  • 96