Adding a @Stateless @WebService to my .ear breaks Weld on JBoss 6.1.0?
ultrapod Apr 18, 2012 5:22 PMApologies in advance if this is the wrong forum to post this. I'm posting this here because the error I'm getting seems to be originating from Weld, so this seemed like the most logical place to start.
I have an .ear in a fairly standard configuration that contains a web app in a .war and a library that contains EJB's in a .jar. I am basically trying to add a @Stateless @WebService to an existing .ear, and I'm getting an error that seems to me to indicate that Weld doesn't like the @WebService annotation. Here is the complete layout of the .ear I'm using; in trying to troubleshoot this I have obviously removed alot of the essential components of a useful web application, but I still get the same error no matter what since the error happens on deployment.
enterprise.ear/ |-> META-INF/ |-> application.xml |-> MANIFEST.MF |-> ejb.jar/ |-> ../session/TestStatelessSessionBean.class |-> ../session/interfaces/TestStatelessSession.class |-> ../webservice/TestWebService.class |-> META-INF/ |-> beans.xml |-> MANIFEST.MF |-> application.war/ |-> WEB-INF/ |-> beans.xml |-> classes/ |-> ../TestManagedBean.class
Both the .war and the ejb .jar are using CDI, and as such each have an empty beans.xml file in their respective WEB-INF and META_INF subdirectories. The EJB jar contains a two stateless EJBs, one of which is also a web service. The application contains a single @Named managed bean.
TestManagedBean.java
@Named("TestManagedBean") @SessionScoped public class TestManagedBean implements Serializable { private static final long serialVersionUID = 7580115849971190388L; private final Logger logger = Logger.getLogger(this.getClass().getName()); @Inject private TestStatelessSessionBean testSession; @PostConstruct public void defaultPostConstruct() { logger.info(this.getClass().getCanonicalName() + " constructed"); } @PreDestroy public void defaultPreDestroy() { logger.info("destroying " + this.getClass().getCanonicalName()); } public void testInjection() { logger.info("testInjection"); logger.info(testSession.testMethod("test")); } }
TestStatelessSessionBean.java
@Stateless public class TestStatelessSessionBean implements TestStatelessSession { private final Logger logger = Logger.getLogger(this.getClass().getName()); @PostConstruct public void defaultPostConstruct() { logger.info(this.getClass().getCanonicalName() + " constructed"); } @PreDestroy public void defaultPreDestroy() { logger.info("destroying " + this.getClass().getCanonicalName()); } public String testMethod(String input) { return "success"; } }
TestWebService.java
@Stateless @WebService @SOAPBinding(style = SOAPBinding.Style.RPC) public class TestWebService { private final Logger logger = Logger.getLogger(this.getClass().getName()); @PostConstruct public void defaultPostConstruct() { logger.info(this.getClass().getCanonicalName() + " constructed"); } @PreDestroy public void defaultPreDestroy() { logger.info("destroying " + this.getClass().getCanonicalName()); } @WebMethod public String helloWorld() { return "Hello, world"; } @WebMethod public String echoString(String input) { return input; } }
When I deploy this on JBoss 6.1.0, this is the error I get:
17:07:07,740 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] Error installing to Start: name=vfs:///Volumes/Development/Java/jboss-6.1.0.Final/server/epmp/deploy/pmreg.ear_WeldBootstrapBean state=Create: org.jboss.weld.exceptions.UnserializableDependencyException: WELD-001413 The bean Managed Bean [test.TestManagedBean] with qualifiers [@Any @Default @Named] declares passivating scope but has non-serializable dependency Managed Bean [class test.session.TestStatelessSessionBean] with qualifiers [@Any @Default] at org.jboss.weld.bootstrap.Validator.validateInjectionPointPassivationCapable(Validator.java:328) [:6.1.0.Final] at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:290) [:6.1.0.Final] at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:106) [:6.1.0.Final] at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:129) [:6.1.0.Final] at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:351) [:6.1.0.Final] at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:336) [:6.1.0.Final] at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:404) [:6.1.0.Final] at org.jboss.weld.integration.deployer.env.helpers.BootstrapBean.boot(BootstrapBean.java:92) [:6.1.0.Final] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_31] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_31] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_31] at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_31] at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:60) [jboss-reflect.jar:2.2.1.SP1] at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:168) [jboss-reflect.jar:2.2.1.SP1] at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66) [jboss-reflect.jar:2.2.1.SP1] at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:257) [jboss-kernel.jar:2.2.0.SP2] at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) [jboss-kernel.jar:2.2.0.SP2] at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:125) [jboss-kernel.jar:2.2.0.SP2] at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:72) [jboss-kernel.jar:2.2.0.SP2] at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:202) [jboss-kernel.jar:2.2.0.SP2] at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.SP2] at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.SP2] at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.deployers.plugins.deployers.DeployersImpl.change(DeployersImpl.java:1983) [:2.2.2.GA] at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:1076) [:2.2.2.GA] at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:679) [:2.2.2.GA] at org.jboss.system.server.profileservice.deployers.MainDeployerPlugin.process(MainDeployerPlugin.java:106) [:6.1.0.Final] at org.jboss.profileservice.dependency.ProfileControllerContext$DelegateDeployer.process(ProfileControllerContext.java:143) [:0.2.2] at org.jboss.profileservice.dependency.ProfileDeployAction.deploy(ProfileDeployAction.java:151) [:0.2.2] at org.jboss.profileservice.dependency.ProfileDeployAction.installActionInternal(ProfileDeployAction.java:94) [:0.2.2] at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54) [jboss-kernel.jar:2.2.0.SP2] at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42) [jboss-kernel.jar:2.2.0.SP2] at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.executeOrIncrementStateDirectly(AbstractController.java:1322) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1246) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1139) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:939) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:654) [jboss-dependency.jar:2.2.0.SP2] at org.jboss.profileservice.dependency.ProfileActivationWrapper$BasicProfileActivation.start(ProfileActivationWrapper.java:190) [:0.2.2] at org.jboss.profileservice.dependency.ProfileActivationWrapper.start(ProfileActivationWrapper.java:87) [:0.2.2] at org.jboss.profileservice.dependency.ProfileActivationService.activateProfile(ProfileActivationService.java:215) [:0.2.2] at org.jboss.profileservice.dependency.ProfileActivationService.activate(ProfileActivationService.java:159) [:0.2.2] at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.activate(AbstractProfileServiceBootstrap.java:112) [:0.2.2] at org.jboss.profileservice.resolver.BasicResolverFactory$ProfileResolverFacade.deploy(BasicResolverFactory.java:87) [:0.2.2] at org.jboss.profileservice.bootstrap.AbstractProfileServiceBootstrap.start(AbstractProfileServiceBootstrap.java:91) [:0.2.2] at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:132) [:6.1.0.Final] at org.jboss.system.server.profileservice.bootstrap.BasicProfileServiceBootstrap.start(BasicProfileServiceBootstrap.java:56) [:6.1.0.Final] at org.jboss.bootstrap.impl.base.server.AbstractServer.startBootstraps(AbstractServer.java:827) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-6] at org.jboss.bootstrap.impl.base.server.AbstractServer$StartServerTask.run(AbstractServer.java:417) [jboss-bootstrap-impl-base.jar:2.1.0-alpha-6] at java.lang.Thread.run(Thread.java:680) [:1.6.0_31]
I have found three ways to make this error go away and get my application to deploy, none of which is an acceptable solution, really.
1. Stop referencing TestStatelessSession from the TestManagedBean. Unfortunately, this kind of ruins the utility of CDI for me, but the web service and EJBs deploy without error.
2. Make TestStatelessSessionBean serializable. This seems wrong to me, as it's my understanding that stateless session beans should not be serializable, practically by definition.
3. Remove TestWebService. This is what I find the most confusing. If I leave everything else intact and just remove TestWebService, the ear deploys just fine, even though TestWebService is not being directly referenced by my stub application at all.
I'm not really sure what I'm doing wrong here. To sum up, I have an otherwise functioning enterprise application that refuses to deploy without an error if I include a single @Stateless @WebService. Can someone help me?