Tomee, Arquillian and CLASSPATH

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Tomee, Arquillian and CLASSPATH

Makarov Alexey-2
Hello!
How I can set "CLASSPATH" variable for remote container?

I try to replace JULI with Slf4j and Logback for remote container, but I receive exception if I run tests:

...
Handler error
java.lang.ClassNotFoundException: org.slf4j.bridge.SLF4JBridgeHandler
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:601)
        at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:538)
        at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:336)
        at java.logging/java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:445)
        at java.logging/java.util.logging.LogManager$2.run(LogManager.java:394)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.logging/java.util.logging.LogManager.ensureLogManagerInitialized(LogManager.java:382)
        at java.logging/java.util.logging.LogManager.getLogManager(LogManager.java:430)
        at java.logging/java.util.logging.Logger.demandLogger(Logger.java:648)
        at java.logging/java.util.logging.Logger.getLogger(Logger.java:717)
        at java.logging/java.util.logging.Logger.getLogger(Logger.java:701)
        at org.apache.tomee.jul.formatter.log.JULLogger.<init>(JULLogger.java:67)
        at org.apache.tomee.jul.formatter.log.ReloadableLog$ReloadableLogHandler.initDelegate(ReloadableLog.java:93)
        at org.apache.tomee.jul.formatter.log.ReloadableLog$ReloadableLogHandler.<init>(ReloadableLog.java:54)
        at org.apache.tomee.jul.formatter.log.ReloadableLog.newLog(ReloadableLog.java:37)
        at org.apache.tomee.jul.formatter.log.TomEELog.<init>(TomEELog.java:79)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:134)
        at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:153)
        at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:208)
        at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:52)
...

1. I have put "setenv.sh" in "src/test/tomee/bin" project with content:

CLASSPATH=$CATALINA_HOME/lib/jul-to-slf4j-1.7.2.jar:\
$CATALINA_HOME/lib/slf4j-api-1.7.2.jar:\
$CATALINA_HOME/lib/logback-classic-1.0.6.jar:\
$CATALINA_HOME/lib/logback-core-1.0.6.jar:\
$CATALINA_HOME/conf/logback/

2. I specified the necessary properties in arquillian.xml:

<container qualifier="tomee" default="true">
        <configuration>
            ...
            <property name="additionalLibs">
                remove:slf4j-jdk14-1.7.21.jar
            </property>
            <property name="lib">target/additional-libs</property>
            <property name="bin">src/test/tomee/bin</property>
            <property name="conf">src/test/tomee/conf</property>
            ...
        </configuration>
</container>

- all declared libraries in (1) are in "target/additional-libs";
- config file for Logback is in "$CATALINA_HOME/conf/logback/";
- all necessary dependencies in pom.xml are declared.

"setenv.sh" appeared in $CATALINA_HOME/bin but, looks like, don't used in bootstrap and not set  "CLASSPATH" variable...

-- 
WIth best regards,
Makarov Alexey

Reply | Threaded
Open this post in threaded view
|

Re: Tomee, Arquillian and CLASSPATH

Makarov Alexey-2
Hello! I found answer.
Look's like, in this moment, specifiyng classpath in arquillian.xml is impossible.
I looked at: https://github.com/apache/tomee/blob/master/container/openejb-core/src/main/java/org/apache/openejb/config/RemoteServer.java

and found that setenv.sh not work becouse container start by running java VM and all options are passed as parameters, hence catalina.sh and setenv.sh not used.

-- 
WIth best regards,
Makarov Alexey


30.05.2020, 19:21, "Makarov Alexey" <[hidden email]>:

> Hello!
> How I can set "CLASSPATH" variable for remote container?
>
> I try to replace JULI with Slf4j and Logback for remote container, but I receive exception if I run tests:
>
> ...
> Handler error
> java.lang.ClassNotFoundException: org.slf4j.bridge.SLF4JBridgeHandler
>         at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
>         at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
>         at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
>         at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:601)
>         at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:538)
>         at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:336)
>         at java.logging/java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:445)
>         at java.logging/java.util.logging.LogManager$2.run(LogManager.java:394)
>         at java.base/java.security.AccessController.doPrivileged(Native Method)
>         at java.logging/java.util.logging.LogManager.ensureLogManagerInitialized(LogManager.java:382)
>         at java.logging/java.util.logging.LogManager.getLogManager(LogManager.java:430)
>         at java.logging/java.util.logging.Logger.demandLogger(Logger.java:648)
>         at java.logging/java.util.logging.Logger.getLogger(Logger.java:717)
>         at java.logging/java.util.logging.Logger.getLogger(Logger.java:701)
>         at org.apache.tomee.jul.formatter.log.JULLogger.<init>(JULLogger.java:67)
>         at org.apache.tomee.jul.formatter.log.ReloadableLog$ReloadableLogHandler.initDelegate(ReloadableLog.java:93)
>         at org.apache.tomee.jul.formatter.log.ReloadableLog$ReloadableLogHandler.<init>(ReloadableLog.java:54)
>         at org.apache.tomee.jul.formatter.log.ReloadableLog.newLog(ReloadableLog.java:37)
>         at org.apache.tomee.jul.formatter.log.TomEELog.<init>(TomEELog.java:79)
>         at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>         at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>         at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>         at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
>         at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:134)
>         at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:153)
>         at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:208)
>         at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:52)
> ...
>
> 1. I have put "setenv.sh" in "src/test/tomee/bin" project with content:
>
> CLASSPATH=$CATALINA_HOME/lib/jul-to-slf4j-1.7.2.jar:\
> $CATALINA_HOME/lib/slf4j-api-1.7.2.jar:\
> $CATALINA_HOME/lib/logback-classic-1.0.6.jar:\
> $CATALINA_HOME/lib/logback-core-1.0.6.jar:\
> $CATALINA_HOME/conf/logback/
>
> 2. I specified the necessary properties in arquillian.xml:
>
> <container qualifier="tomee" default="true">
>         <configuration>
>             ...
>             <property name="additionalLibs">
>                 remove:slf4j-jdk14-1.7.21.jar
>             </property>
>             <property name="lib">target/additional-libs</property>
>             <property name="bin">src/test/tomee/bin</property>
>             <property name="conf">src/test/tomee/conf</property>
>             ...
>         </configuration>
> </container>
>
> - all declared libraries in (1) are in "target/additional-libs";
> - config file for Logback is in "$CATALINA_HOME/conf/logback/";
> - all necessary dependencies in pom.xml are declared.
>
> "setenv.sh" appeared in $CATALINA_HOME/bin but, looks like, don't used in bootstrap and not set "CLASSPATH" variable...
>
> --
> WIth best regards,
> Makarov Alexey