I have some problem with using weld logger injection.
Scenario: I have ear with ejb-jar inside.
This is my ejb bean:
@Stateless
@LocalBean
public class PartnersService {
@Inject
Logger log;
@PersistenceContext(unitName = "Utopia")
EntityManager em;
public PartnersService() {
}
public OasysPartnerEntity getPartner(long id){
return em.find(OasysPartnerEntity.class, id);
}
@Schedule( hour = "*", minute = "*", second = "*/15")
public void print1Partner(){
System.out.println("This is test");
log.info("This is partner`s email under id 1 = ");
}
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void saveTempPartnerTemp(OasysPartnerTempEntity part){
em.persist(part);
}
}
when print1Partner called I got exception:
|2010-07-02T19:25:35.003+0300|WARNING|oracle-glassfish3.0.1|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=48;_ThreadName=Thread-1;|A system exception occurred during an invocation on EJB PartnersService method public void ua.co.oasys.fenix.persistence.PartnersService.print1Partner() javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:448) at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2467) at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1860) at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:3962) at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1667) at com.sun.ejb.containers.EJBTimerService.access$100(EJBTimerService.java:98) at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:2485) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:720) at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:200) at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:443) ... 12 more Caused by: javax.ejb.CreateException: Could not create stateless EJB at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:528) at com.sun.ejb.containers.StatelessSessionContainer.access$000(StatelessSessionContainer.java:90) at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:718) ... 14 more Caused by: java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768) at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:1171) at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:132) at org.glassfish.weld.services.JCDIServiceImpl._createJCDIInjectionContext(JCDIServiceImpl.java:145) at org.glassfish.weld.services.JCDIServiceImpl.createJCDIInjectionContext(JCDIServiceImpl.java:122) at com.sun.ejb.containers.BaseContainer.createEjbInstanceAndContext(BaseContainer.java:1616) at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:469) ... 16 more |#]
Using: ejb 3.1, glassfish 3.0.1
Some of maven dependency:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.ejb</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<!-- SL4J API -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.0</version>
<scope>provided</scope>
</dependency>
<!-- SLF4J JDK14 Binding -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.6.0</version>
<scope>provided</scope>
</dependency>
<!-- Injectable Weld-Logger -->
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-logger</artifactId>
<version>1.0.0-CR2</version>
<scope>provided</scope>
</dependency>
<!--CDI-->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
<version>1.0-CR4</version>
</dependency>
ear pom.xml
<dependencies>
....
<!--weld-->
<!-- SL4J API -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.0</version>
</dependency>
<!-- SLF4J JDK14 Binding -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.6.0</version>
</dependency>
<!-- Injectable Weld-Logger -->
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-logger</artifactId>
<version>1.0.0-CR2</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.0-CR4</version>
</dependency>
</dependencies>
<build>
...
<configuration>
<modules>
...
<!--weld-->
<!-- SL4J API -->
<jarModule>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<bundleDir>lib</bundleDir>
</jarModule>
<!-- SLF4J JDK14 Binding -->
<jarModule>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<bundleDir>lib</bundleDir>
</jarModule>
<!-- Injectable Weld-Logger -->
<jarModule>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-logger</artifactId>
<bundleDir>lib</bundleDir>
</jarModule>
<jarModule>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<bundleDir>lib</bundleDir>
</jarModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
bean.xml in META-INF/
Same configuration working with war in ear without ejb (in war, but if I use ejb in war and weld - same exception)
Q1: what is wrong?
Q2: what is the rules of using weld & ejb 3.1 ?