IllegalArgumentException when configuring annotated services

1,126 views
Skip to first unread message

perissf

unread,
Mar 18, 2012, 2:44:16 PM3/18/12
to cometd-users
Hi,
I am trying to move a CometD web application from inherited services
to annotated services.
On GlassFish 3.1 I have this exception:
org.apache.catalina.LifecycleException:
java.lang.IllegalArgumentException: javax.servlet.ServletException:
com.sun.enterprise.container.common.spi.util.InjectionException: Error
creating managed object for class: class
org.jboss.weld.servlet.WeldListener

The basic web app has the following 2 classes taken from CometD
reference guides:

@Service("echoService")
public class EchoService {

@Session private ServerSession serverSession;

@Listener("/echo")
public void echo(ServerSession remote, Message message) {
remote.deliver(serverSession, message.getChannel(),
message.getData(), null);
}
}

public class ConfigurationServlet extends GenericServlet {

private final List<Object> services = new ArrayList<Object>();
private ServerAnnotationProcessor processor;

@Override
public void init() throws ServletException {
BayeuxServer bayeux = (BayeuxServer)
getServletContext().getAttribute(BayeuxServer.ATTRIBUTE);
processor = new ServerAnnotationProcessor(bayeux);
Object service = new EchoService();
processor.process(service);
services.add(service);
}

@Override
public void destroy() {
for (Object service : services) {
processor.deprocess(service);
}
}

@Override
public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException {
throw new UnsupportedOperationException("Not supported yet.");
}

}

and here is the web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<servlet>
<servlet-name>cometd</servlet-name>
<servlet-class>org.cometd.server.CometdServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>cometd</servlet-name>
<url-pattern>/cometd/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>cometconfiguration</servlet-name>
<servlet-class>servlets.ConfigurationServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>

Any hints?
Thanks
Francesco
Message has been deleted

Simone Bordet

unread,
Mar 19, 2012, 4:53:20 AM3/19/12
to cometd...@googlegroups.com
Hi,

On Sun, Mar 18, 2012 at 19:44, perissf <per...@gmail.com> wrote:
> Hi,
> I am trying to move a CometD web application from inherited services
> to annotated services.
> On GlassFish 3.1 I have this exception:
> org.apache.catalina.LifecycleException:
> java.lang.IllegalArgumentException: javax.servlet.ServletException:
> com.sun.enterprise.container.common.spi.util.InjectionException: Error
> creating managed object for class: class
> org.jboss.weld.servlet.WeldListener

The error says it cannot create an instance of WeldListener. Does not
seem related to CometD.

Simon
--
http://cometd.org
http://intalio.com
http://bordet.blogspot.com
----
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz

perissf

unread,
Mar 19, 2012, 3:01:29 PM3/19/12
to cometd-users
After deeper investigation, I have found out that ... the problem is
somewhere else!
The code reported above, if deployed after restarting the application
server, works fine.

But when I try to inject the BayeuxServer instance into an EJB
Singleton called MySingleton, I get this exception when deploying:

javax.ejb.CreateException: Initialization failed for Singleton
MySingleton
Caused by: org.jboss.weld.exceptions.IllegalArgumentException:
WELD-001324 Argument bean must not be null

The other exception reported above is thrown after removing the
injection of BayeuxServer, and will always be thrown until I restart
the application server.

I then tried to inject the BayeuxServer in an ApplicationScoped bean,
but I got the following exception when deploying:

org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied
dependencies for type [BayeuxServer] with qualifiers [@Default] at
injection point [[field] @Inject private beans.MySingleton.bayeux]

So my question is: isn't it allowed to inject the BayeuxServer in one
of these Java EE 6 beans?

Thanks again
Francesco

On 19 Mar, 09:53, Simone Bordet <sbor...@intalio.com> wrote:
> Hi,
>
> On Sun, Mar 18, 2012 at 19:44, perissf <peri...@gmail.com> wrote:
> > Hi,
> > I am trying to move a CometD web application from inherited services
> > to annotated services.
> > On GlassFish 3.1 I have this exception:
> > org.apache.catalina.LifecycleException:
> > java.lang.IllegalArgumentException: javax.servlet.ServletException:
> > com.sun.enterprise.container.common.spi.util.InjectionException: Error
> > creating managed object for class: class
> > org.jboss.weld.servlet.WeldListener
>
> The error says it cannot create an instance of WeldListener. Does not
> seem related to CometD.
>
> Simon
> --http://cometd.orghttp://intalio.comhttp://bordet.blogspot.com

Simone Bordet

unread,
Mar 19, 2012, 4:53:42 PM3/19/12
to cometd...@googlegroups.com
Hi,

On Mon, Mar 19, 2012 at 20:01, perissf <per...@gmail.com> wrote:
> After deeper investigation, I have found out that ... the problem is
> somewhere else!
> The code reported above, if deployed after restarting the application
> server, works fine.
>
> But when I try to inject the BayeuxServer instance into an EJB
> Singleton called MySingleton, I get this exception when deploying:
>
> javax.ejb.CreateException: Initialization failed for Singleton
> MySingleton
> Caused by: org.jboss.weld.exceptions.IllegalArgumentException:
> WELD-001324 Argument bean must not be null
>
> The other exception reported above is thrown after removing the
> injection of BayeuxServer, and will always be thrown until I restart
> the application server.
>
> I then tried to inject the BayeuxServer in an ApplicationScoped bean,
> but I got the following exception when deploying:
>
> org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied
> dependencies for type [BayeuxServer] with qualifiers [@Default] at
> injection point [[field] @Inject private beans.MySingleton.bayeux]
>
> So my question is: isn't it allowed to inject the BayeuxServer in one
> of these Java EE 6 beans?

CDI is quite (over)complicated, and I spent only little time on
integrating CometD into CDI, so it's a new terrain that needs to be
explored.

Can you please file a bug at http://bugs.cometd.org so that we won't forget ?

If you find a solution, please keep us posted.

perissf

unread,
Mar 22, 2012, 3:42:26 PM3/22/12
to cometd...@googlegroups.com
Issued an improvement issue: http://bugs.cometd.org/browse/COMETD-351
 
For the mom this is the only thing that I am able to do... hope to be able to do something more in the future, but my knowledge is far from being enough right now...
 

Il giorno lunedì 19 marzo 2012 21:53:42 UTC+1, Simone Bordet ha scritto:
Hi,
Reply all
Reply to author
Forward
0 new messages