Hi altogether,
I wrote a simple counter singleton using the EJB 3.1 @Singleton and the Servlet 3.0 @WebListener to get event. Deployment in JBoss AS7.0.2 does not work. See code and error below Thanks in advance for some hints.
--- sample singleton
@Singleton
@WebListener
public class CounterBean implements HttpSessionListener{
private static int counter = 0;
@Override
public void sessionCreated(HttpSessionEvent se) {
counter++;
}
@Override
public void sessionDestroyed(HttpSessionEvent se) {
counter--;
}
public int getActiveSessionsCount() {
return counter;
}
}
-- Error from the JBossAS7.0.2 log
13:42:00,031 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."acme.newsapp.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."acme.newsapp.war".PARSE: Failed to process phase PARSE of deployment "acme.newsapp.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
at java.lang.Thread.run(Thread.java:680) [:1.6.0_26]
Caused by: java.lang.RuntimeException: foo.controller.CounterBean has the wrong component type, is cannot be used as a web component
at org.jboss.as.web.deployment.component.WebComponentProcessor.deploy(WebComponentProcessor.java:111)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
... 5 more