-
1. Re: @Inject Logger does not work
sg26565 Aug 22, 2011 2:31 PM (in response to sg26565)I found a solution.
The seam-solder-3.0.0.Final.jar needs to be packaged into the lib subfolder of the ear. This is how my pom.xml for the ear looks like:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ear-plugin</artifactId> <version>2.4.2</version> <configuration> <version>6</version> <defaultLibBundleDir>lib</defaultLibBundleDir> </configuration> </plugin> ... </plugins> </build>
Details can be found in https://docs.jboss.org/author/display/AS7/Class+Loading+in+AS7. I assume that adding a Class-Path: entry to MANIFEST.MF would also work, but I didn't test this.
Here is another post on a related issue: http://community.jboss.org/thread/167102
-
2. Re: @Inject Logger does not work
jimdwyer Aug 22, 2011 3:05 PM (in response to sg26565)Can you post you import statements. I have a similar issue. My code compiles but will not deploy.
I get this error
Caused by: java.lang.NoClassDefFoundError: Lorg/apache/log4j/Logger
It seems that log4j is part of the server but I can't seem to get ahold of it.
Here is my code:
@Startup
@Singleton
@Remote(IngestRemote.class)
@Local(IngestLocal.class)
public class IngestMBean implements IngestRemote, IngestLocal{
private static final Logger log = Logger.getLogger(IngestMBean.class);
//@Inject private Logger log;
@PostConstruct
public void postConstruct() throws Exception{
log.info("postConstruct");
}
@PreDestroy
public void preDestroy() throws Exception{
log.info("preDestroy");
}}
I tried the @Inject and the old fashioned way with the same result. What am I doing wrong. I have no .xml files. I let the bean autowire.
-
3. Re: @Inject Logger does not work
sg26565 Aug 22, 2011 3:14 PM (in response to jimdwyer)I'm using JBoss logging:
import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
import org.jboss.logging.Logger
Don't use org.apache.log4j.Logger directly. JBoss logging is a logging facade that abstracts the actual logging framework similar to commons logging or slf4j.
-
4. Re: @Inject Logger does not work
jimdwyer Aug 22, 2011 3:30 PM (in response to sg26565)Thats it. Thanks.