logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-1461) could not load library jansi-1.8
Date Tue, 12 Jul 2016 19:41:21 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-1461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15373559#comment-15373559
] 

Gary Gregory commented on LOG4J2-1461:
--------------------------------------

It could also be that Jansi's clever native code extraction logic does not play well with
your container... Let's start with step 1, which is to make sure the Log4j and expected JAnsi
version match up.

> could not load library jansi-1.8
> --------------------------------
>
>                 Key: LOG4J2-1461
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1461
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.3, 2.5
>         Environment: Windows 7 and Java 8.0_91x64
>            Reporter: Pascal Kn├╝ppel
>            Priority: Critical
>
> HI I get an log4j2 error I can only reproduce in conjunction with openejb. I only need
to create a simple static final Logger in a class annotated @Stateless and I get the following
error:
> {noformat}
> java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no jansi32-1.8 in java.library.path,
no jansi-1.8 in java.library.path, no jansi in java.library.path, Native Library C:\Users\praktikant\AppData\Local\Temp\jansi-32-1.8.dll
already loaded in another classloader]
> 	at org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:184)
> 	at org.fusesource.hawtjni.runtime.Library.load(Library.java:142)
> 	at org.fusesource.jansi.internal.Kernel32.<clinit>(Kernel32.java:37)
> 	at org.fusesource.jansi.WindowsAnsiOutputStream.<clinit>(WindowsAnsiOutputStream.java:52)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
> 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> 	at org.apache.logging.log4j.core.appender.ConsoleAppender.getOutputStream(ConsoleAppender.java:204)
> 	at org.apache.logging.log4j.core.appender.ConsoleAppender.getManager(ConsoleAppender.java:178)
> 	at org.apache.logging.log4j.core.appender.ConsoleAppender.createDefaultAppenderForLayout(ConsoleAppender.java:109)
> 	at org.apache.logging.log4j.core.config.DefaultConfiguration.<init>(DefaultConfiguration.java:62)
> 	at org.apache.logging.log4j.core.LoggerContext.<init>(LoggerContext.java:70)
> 	at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145)
> 	at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70)
> 	at org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:142)
> 	at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:41)
> 	at org.apache.logging.log4j.LogManager.getContext(LogManager.java:175)
> 	at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:426)
> 	at de.fiverx.backend.service.LadeRzZertifikatRessource.<clinit>(LadeRzZertifikatRessource.java:34)
> 	at java.lang.Class.forName0(Native Method)
> 	at java.lang.Class.forName(Class.java:348)
> 	at org.apache.openejb.util.Classes.forName(Classes.java:64)
> 	at org.apache.openejb.config.rules.ValidationBase.loadClass(ValidationBase.java:151)
> 	at org.apache.openejb.config.rules.CheckMethods.check_unusedCreateMethods(CheckMethods.java:318)
> 	at org.apache.openejb.config.rules.CheckMethods.validate(CheckMethods.java:55)
> 	at org.apache.openejb.config.rules.ValidationBase.validate(ValidationBase.java:50)
> 	at org.apache.openejb.config.AppValidator.validate(AppValidator.java:101)
> 	at org.apache.openejb.config.ValidateModules.deploy(ValidateModules.java:38)
> 	at org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:403)
> 	at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:971)
> 	at org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:832)
> 	at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:546)
> 	at org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:591)
> 	at org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:459)
> 	at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:438)
> 	at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:150)
> 	at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:67)
> 	at org.apache.openejb.OpenEJB.init(OpenEJB.java:298)
> 	at org.apache.openejb.OpenEJB.init(OpenEJB.java:278)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
> 	at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:98)
> 	at org.apache.openejb.core.LocalInitialContextFactory.init(LocalInitialContextFactory.java:62)
> 	at org.apache.openejb.core.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:46)
> 	at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
> 	at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
> 	at javax.naming.InitialContext.init(InitialContext.java:244)
> 	at javax.naming.InitialContext.<init>(InitialContext.java:216)
> 	at de.fiverx.backend.openejbUtils.OpenEjbTest.setUp(OpenEjbTest.java:51)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
> 	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> 	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> 	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
> 	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
> 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
> 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
> ERROR - ERROR ... null:	Cannot validate jar: Could not load library. Reasons: [no jansi32-1.8
in java.library.path, no jansi-1.8 in java.library.path, no jansi in java.library.path, Native
Library C:\Users\praktikant\AppData\Local\Temp\jansi-32-1.8.dll already loaded in another
classloader]
> ERROR - Invalid AppModule(name=classpath.ear, path=classpath.ear)
> {noformat}
> the code I am using is the following:
> {code:title=test.java.java|borderStyle=solid}
> @LocalClient
> public class test extends OpenEjbTest {
>     @Test
>     public void test() {
>         // when executing this empty test the error occurs
>     }
> }
> {code}
> {code:title=OpenEjbTest.java|borderStyle=solid}
> public abstract class OpenEjbTest {
>     protected Context initialContext;
>     @EJB
>     protected OpenEjbTransactionCaller transactionCaller;
>     @Before
>     public void setUp() throws NamingException {
>         Properties p = new Properties();
>         p.put("log4j.rootLogger", "fatal,C");
>         p.put("log4j.category.OpenEJB", "error");
>         p.put("log4j.category.OpenEJB.options", "error");
>         p.put("log4j.category.OpenEJB.server", "error");
>         p.put("log4j.category.OpenEJB.startup", "error");
>         p.put("log4j.category.OpenEJB.startup.service", "error");
>         p.put("log4j.category.OpenEJB.startup.config", "error");
>         p.put("log4j.category.OpenEJB.hsql", "error");
>         p.put("log4j.category.CORBA-Adapter", "error");
>         p.put("log4j.category.Transaction", "error");
>         p.put("log4j.category.org.apache.activemq", "error");
>         p.put("log4j.category.org.apache.geronimo", "error");
>         p.put("log4j.category.openjpa", "error");
>         p.put("log4j.appender.C", "org.apache.log4j.ConsoleAppender");
>         p.put("log4j.appender.C.layout", "org.apache.log4j.SimpleLayout");
>         p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");
>         initialContext = new InitialContext(p);
>         initialContext.bind("inject", this);
>     }
>     @After
>     public void cleanUp() throws NamingException {
>         initialContext.unbind("inject");
>         initialContext.close();
>     }
> }
> {code}
> {code:title=OpenEjbTransactionCaller.java|borderStyle=solid}
> public interface OpenEjbTransactionCaller {
>     public <V> V call(Callable<V> callable) throws Exception;
> }
> {code}
> {code:title=OpenEjbTransactionCaller.java|borderStyle=solid}
> @Stateless
> public class OpenEjbTransactionCallerBean implements OpenEjbTransactionCaller {
>     private static final Logger LOGGER = LogManager.getLogger(OpenEjbTransactionCallerBean.class);
>     @Inject
>     @Named(ManagedBeanProducer.oracleEntityManagerName)
>     private EntityManager oracleEntityManager;
>     @Inject
>     @Named(ManagedBeanProducer.navisionEntityManagerName)
>     private EntityManager navisionEntityManager;
>     @Resource
>     private SessionContext sessionContext;
>     @Override
>     public <V> V call (Callable<V> callable) throws Exception {
>             return callable.call();
>     }
> }
> {code}
> the declaration of the logger in the last class is the culprit and generates the error.
I am using the following dependencies:
> {nofornat}
> <dependency>
>     <groupId>org.apache.openejb</groupId>
>     <artifactId>openejb-junit</artifactId>
>     <version>4.7.4</version>
> </dependency>
> <dependency>
>     <groupId>org.apache.logging.log4j</groupId>
>     <artifactId>log4j-core</artifactId>
>     <version>2.5</version>
> </dependency>
> <dependency>
>     <groupId>org.apache.logging.log4j</groupId>
>     <artifactId>log4j-api</artifactId>
>     <version>2.5</version>
> </dependency>
> {nofornat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message