I've recently developed an app with Glassfish and the development goes very smoothly, now with JBoss I'm trying to do the same but is being slow down by various problems such as: @EJB works but @Inject fails. I don't have a fancy class yet, I just have a Singleton Startup class and a simple Stateless class that I inject, and to my surprise injection doesn't work. Here's my class:
package com.czetsuya.dropship;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton
@Startup
public class StartupListener {
private Logger log = LoggerFactory.getLogger(StartupListener.class);
@EJB
private TestService testService;
public StartupListener() {
}
@PostConstruct
private void init() {
testService.test();
log.debug("startup");
}
}
The service class:
package com.czetsuya.dropship;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
@Stateless
@LocalBean
public class TestService {
public TestService() {
}
public void test() {
System.out.println("run");
}
}
The other thing is if I inject my logger with the following producer it also doesn't work and throws:
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Logger] with qualifiers [@Default] at injection point [[field] @Inject private com.czetsuya.dropship.StartupListener.log]
The logger producer:
@Produces
Logger createLogger(InjectionPoint injectionPoint) {
return LoggerFactory.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
Note that I have beans.xml in my ejb and war project.
My beans.xml file:
<beans 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/javaeehttp://java.sun.com/xml/ns/javaee/beans_1_0.xsd"></beans>