在多服务器 Adob​​e Coldfusion 9 中为特定实例添加到 ColdFusion 类路径

2022-01-09 00:00:00 coldfusion java classpath coldfusion-9

Adobe ColdFusion 9 Multi-Server 在 CF Admin 中没有JVM 和 Java 设置"页面,因此要向 CF 类路径添加一些内容,对于给定实例,该实例必须使用备用 jvm 启动.配置.

Adobe ColdFusion 9 Multi-Server doesn't have the "JVM and Java Settings" page in the CF Admin, so to add something to the CF classpath, for a given instance, that instance must be started with an alternate jvm.config.

从备用 jvm.config 开始我没有问题.但是,我确实准确地知道如何以正确的方式编辑该文件.

I don't have a problem with starting with an alternate jvm.config. I do, however, have a problem knowing precisely how to edit that file in the proper way.

我的库存 jvm.config 看起来像这样(忽略换行符——它们不在实际文件中):

My stock jvm.config looks like this (ignore line breaks--they are not in the actual file):

java.args=-server -Xmx512m -Dcoldfusion.sessioncookie.httponly=true -Dsun.io.useCanonCaches=false -XX:MaxPermSize=192m -XX:+UseParallelGC -Xbatch -Djava.awt.headless=true
-Dcoldfusion.rootDir={application.home}/
-Djava.security.policy={application.home}/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/coldfusion.policy
-Djava.security.auth.policy={application.home}/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/neo_jaas.policy

我尝试将类文件夹添加到类路径中的一个比较成功的尝试如下所示.(这里只是一对.)

One of my more successful* attempts at adding a folder of classes to the classpath looks like this. (Here are just a couple.)

java.args=-server -Xmx512m -Dcoldfusion.sessioncookie.httponly=true -Dsun.io.useCanonCaches=false -XX:MaxPermSize=192m -XX:+UseParallelGC -Xbatch -Djava.awt.headless=true
-Dcoldfusion.rootDir={application.home}/
-Djava.security.policy={application.home}/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/coldfusion.policy
-Djava.security.auth.policy={application.home}/servers/cfusion/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/neo_jaas.policy
-Dcoldfusion.classPath={application.home}/servers/hud/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib,/var/www/apps/onecpd/GeoServices_sandbox

*我说我更成功的尝试之一"是因为实例确实启动了,并且这些类在 CF 类路径上[我可以使用 createObject() 实例化它们],但是实例启动并不干净——有许多与 Flex 相关的错误:

*I say "one of my more successful attempts" because the instance does start, and those classes are on the CF classpath [I can instantiate them with createObject()], but the instance start is not clean--there are many Flex-related errors:

jamie@icf109118-ubuntu:/opt/jrun4/servers/hud/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib$ sudo /opt/jrun4/bin/jrun -config /opt/jrun4/bin/jvm_onecpd.config start onecpd
Starting Macromedia JRun 4.0 (Build 108858), onecpd server
03/19 11:37:34 info JRun Naming Service listening on *:2911
03/19 11:37:35 info No JDBC data sources have been configured for this server (see jrun-resources.xml)
03/19 11:37:35 info JRun Web Server listening on *:8303
03/19 11:37:35 info JRun Proxy Server listening on *:51003
03/19 11:37:35 info Deploying enterprise application "JRun 4.0 Internal J2EE Components" from: file:/opt/jrun4/lib/jrun-comp.ear
03/19 11:37:35 info Deploying EJB "JRunSQLInvoker" from: file:/opt/jrun4/lib/jrun-comp.ear
Server onecpd ready (startup time: 2 seconds)
03/19 11:37:35 info Deploying enterprise application "cfusion" from: file:/opt/jrun4/servers/onecpd/cfusion.ear/
03/19 11:37:36 info Deploying web application "cfusion" from: file:/opt/jrun4/servers/onecpd/cfusion.ear/
java.lang.ClassNotFoundException: flex.server.j2ee.cache.CacheFilter
    at coldfusion.bootstrap.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:235)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at coldfusion.bootstrap.ClassloaderHelper.initFilterClass(ClassloaderHelper.java:123)
    at coldfusion.bootstrap.BootstrapFilter.init(BootstrapFilter.java:34)
    at jrun.servlet.FilterObject.init(FilterObject.java:63)
    at jrun.servlet.FilterManager.loadFilter(FilterManager.java:220)
    at jrun.servlet.FilterManager.init(FilterManager.java:158)
    at jrun.servlet.FilterManager.create(FilterManager.java:75)
    at jrun.servlet.WebApplicationService.start(WebApplicationService.java:230)
    at jrun.ea.EnterpriseApplication.start(EnterpriseApplication.java:194)
    at jrun.deployment.DeployerService.initModules(DeployerService.java:708)
    at jrun.deployment.DeployerService.createWatchedDeployment(DeployerService.java:243)
    at jrun.deployment.DeployerService.deploy(DeployerService.java:428)
    at jrun.deployment.DeployerService.checkWatchedDirectories(DeployerService.java:179)
    at jrun.deployment.DeployerService.run(DeployerService.java:889)
    at jrunx.scheduler.SchedulerService.invokeRunnable(SchedulerService.java:230)
    at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
03/19 11:37:36 user failed to load: flex.server.j2ee.cache.CacheFilter
03/19 11:37:36 error Error loading class for Filter CFCacheFilter: Filter is disabled.
[1]java.lang.ClassNotFoundException: flex.server.j2ee.cache.CacheFilter
    at coldfusion.bootstrap.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:235)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at coldfusion.bootstrap.ClassloaderHelper.initFilterClass(ClassloaderHelper.java:123)
    at coldfusion.bootstrap.BootstrapFilter.init(BootstrapFilter.java:34)
    at jrun.servlet.FilterObject.init(FilterObject.java:63)
    at jrun.servlet.FilterManager.loadFilter(FilterManager.java:220)
    at jrun.servlet.FilterManager.init(FilterManager.java:158)
    at jrun.servlet.FilterManager.create(FilterManager.java:75)
    at jrun.servlet.WebApplicationService.start(WebApplicationService.java:230)
    at jrun.ea.EnterpriseApplication.start(EnterpriseApplication.java:194)
    at jrun.deployment.DeployerService.initModules(DeployerService.java:708)
    at jrun.deployment.DeployerService.createWatchedDeployment(DeployerService.java:243)
    at jrun.deployment.DeployerService.deploy(DeployerService.java:428)
    at jrun.deployment.DeployerService.checkWatchedDirectories(DeployerService.java:179)
    at jrun.deployment.DeployerService.run(DeployerService.java:889)
    at jrunx.scheduler.SchedulerService.invokeRunnable(SchedulerService.java:230)
    at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
[0]javax.servlet.ServletException: flex.server.j2ee.cache.CacheFilter
    at coldfusion.bootstrap.ClassloaderHelper.initFilterClass(ClassloaderHelper.java:132)
    at coldfusion.bootstrap.BootstrapFilter.init(BootstrapFilter.java:34)
    at jrun.servlet.FilterObject.init(FilterObject.java:63)
    at jrun.servlet.FilterManager.loadFilter(FilterManager.java:220)
    at jrun.servlet.FilterManager.init(FilterManager.java:158)
    at jrun.servlet.FilterManager.create(FilterManager.java:75)
    at jrun.servlet.WebApplicationService.start(WebApplicationService.java:230)
    at jrun.ea.EnterpriseApplication.start(EnterpriseApplication.java:194)
    at jrun.deployment.DeployerService.initModules(DeployerService.java:708)
    at jrun.deployment.DeployerService.createWatchedDeployment(DeployerService.java:243)
    at jrun.deployment.DeployerService.deploy(DeployerService.java:428)
    at jrun.deployment.DeployerService.checkWatchedDirectories(DeployerService.java:179)
    at jrun.deployment.DeployerService.run(DeployerService.java:889)
    at jrunx.scheduler.SchedulerService.invokeRunnable(SchedulerService.java:230)
    at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
    at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

请注意,如果不将 {application.home}/servers/hud/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib 添加到 Dcoldfusion.classPath,服务器根本不会真正启动.

Note that without adding {application.home}/servers/hud/cfusion.ear/cfusion.war/WEB-INF/cfusion/lib to Dcoldfusion.classPath, as well, the server wouldn't really start at all.

那么,在 jvm.config 中干净地向 ColdFusion 类路径添加内容的神奇公式是什么?

So, what is the magic formula for cleanly adding something to the ColdFusion classpath in jvm.config?

推荐答案

来自 Christian Cantrell - 工程经理和传播者,我给你 ColdFusion 类路径权威指南(虽然有点过时了)

From Christian Cantrell - Engineering Manager and Evangelist, I give you The Definitive Guide to the ColdFusion Classpath (although it is a bit dated)

以下是我认为与您的设置相关的部分摘录:

Here is an excerpt of the portion that I think relates to your setup:

J2EE 部署

  1. 将类或 jar 文件添加到类路径的最简单方法是简单地将它们放到 lib 目录中,它们会自动被拾取.该目录位于 {cf_installation}/servers/lib.这些类文件将可供所有服务器使用.

  1. The easiest way to add class or jar files to your class path is to simply drop them in the lib directory where they are automatically picked up. The directory is located at {cf_installation}/servers/lib. These class files will be available to all servers.

您还可以通过将类文件放到{cf_installation}/servers/default/cfmx/WEB-INF/lib"中,使它们仅对 ColdFusion 服务器可用.(请注意,将它们放入 {cf_installation}/servers/default/cfmx/WEB-INF/cfusion/lib 将不起作用.)

You can also make your class files available only to the ColdFusion server by dropping them in "{cf_installation}/servers/default/cfmx/WEB-INF/lib". (Note that putting them in {cf_installation}/servers/default/cfmx/WEB-INF/cfusion/lib will NOT work.)

您可以将它们放在任何 Java 扩展目录中.要查找 Java 扩展目录列表,请打开 ColdFusion 管理员并单击系统信息".在底部,您将看到一个名为Java Ext Dirs"的系统属性.您可以将 jar 和 class 文件放在任何这些目录中,以让 ColdFusion 服务器获取它们.

You can drop them in any of the Java extension directories. To find a list of the Java extension directories, open the ColdFusion administrator and click on "System Information". Toward the bottom, you will see a system property called "Java Ext Dirs". You can put jar and class files in any of those directories to have them picked up by the ColdFusion server.

另一种方法是通过 JRun 管理控制台添加类.打开控制台,在默认服务器下,单击设置,然后将您的类添加到类路径列表中.(注意您也可以点击默认服务器下的ColdFusion MX 应用程序",然后点击设置进行相同的更改.)

Another way to do it is to add classes through the JRun Management Console. Open up the console, and under the default server, click on settings, then add your classes to the class path list. (Note you can also click on "ColdFusion MX application" under the default server, then click on settings to make the same changes.)

最后,再一次,您可以自己编辑 jvm.config 文件,不过,我还是建议您坚持使用上述方法之一.

And finally, once again, you can edit the jvm.config file yourself, however again, I recommend you stick to using one of the methods above.

以下评论的更新

编辑 jvm.config 文件时(选项 5),尝试将目录路径添加到 jvm.config 文件中的 java.class.path= 行(在底部).不像您在发布的示例中所做的那样在 java.args= 中.

When editing the jvm.config file (option 5), try adding the directory path to the java.class.path= line in the jvm.config file (at the bottom). Not in the java.args= as you have done in the posted example.

相关文章