使用的图片:https://access.redhat.com/containers/#/registry.access.redhat.com/jboss-eap-7/eap70-openshift
我可以设置一个ENV变量,但它不起作用。
Dockerfile:
FROM registry.access.redhat.com/jboss-eap-7/eap70-openshift
ENV CLASSPATH $CLASSPATH:/opt/eap/standalone/lib/required_libs/fscontext.jar
它设置了这个变量,但我仍然得到以下异常,
Caused by: java.lang.ClassNotFoundException: com.sun.jndi.fscontext.RefFSContextFactory from [Module "org.jboss.as.naming:main" from local module loader @b97c004 (finder: local module finder @4590c9c3 (roots: /opt/eap/modules,/opt/eap/modules/system/layers/openshift,/opt/eap/modules/system/layers/base/.overlays/layer-base-jboss-eap-7.0.6.CP,/opt/eap/modules/system/layers/base,/opt/eap/modules/system/add-ons/keycloak))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:196)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.jboss.as.naming.InitialContext.getDefaultInitCtx(InitialContext.java:113)
在容器内设置classpath也不起作用。
寻找设置一个类路径,它将显示在java进程中,如下所示:
[root@9a290d7939bb ~]# ps -ef | grep java
root 1 0 0 Jul18 ? 00:05:49 /usr/lib/jvm/java-1.8.0/bin/java -Dnop -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.library.path=/opt/webserver/lib -Djava.security.egd=file:/dev/./urandom -javaagent:/opt/jolokia/jolokia.jar=config=/opt/jolokia/etc/jolokia.properties -XX:+UseParallelGC -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=100m -XX:+ExitOnOutOfMemoryError -Djava.endorsed.dirs=/opt/webserver/endorsed **-classpath /opt/webserver/fscontext.jar:/opt/webserver/ldap.jar** -Dcatalina.base=/opt/webserver -Dcatalina.home=/opt/webserver -Djava.io.tmpdir=/opt/webserver/temp org.apache.catalina.startup.Bootstrap start
答案 0 :(得分:1)
为什么不把你的lib放在/ opt / eap / modules中,或者放在stacktrace中提到的目录中?
不要忘记在EAP_HOME / modules / your / package / name / main中创建一个module.xml文件,例如:
<module xmlns="urn:jboss:module:1.1" name="your.package.name">
<resources>
<resource-root path="fscontext.jar"/>
</resources>
<dependencies>
<module name="com.ibm.mq"/>
</dependencies>
</module>