Container Classpath
Definition
How to configure the executing container's classpath
This feature is only available for local containers
Explanation
This topic is not about the classpath requirements to run Cargo (see the Installation page for this); it's about configuring the classpath for the executing container. You can therefore add custom JARs (code instrumentation, DataSource JARs, security-related libraries, etc.) to the container's execution classpath as shown below.
The way the JARs will be added are container dependent: for example, on a Tomcat local container with a standalone configuration, the JARs are copied in the $CATALINA_BASE/lib/common
folder, on a similar Jetty configuration it is added to the extraClasspath
attribute of the context.xml
files, etc. If you absolutely need the JARs to be added to the JVM classpath (for example, because you are changing the Java logger and it needs additional JARs), you can add the -classpath
(or -cp
) argument as a JVM argument in the container configuration.
Note that some containers also support adding custom JARs to the applications' classpath only: see Application Classpath for details.
Example using the Java API
Starting Orion 1.x with Clover jar added to its classpath. For example if you have instrumented your source code with Clover you'll need to add the Clover jar to the classpath.
InstalledLocalContainer container = new Orion1xInstalledLocalContainer( new OrionStandaloneLocalConfiguration("target/orion1x")); container.setHome("c:/apps/orion-1.6.0b"); container.setExtraClasspath(new String[] { "libs/clover.jar" }); container.start();
Example using the Ant tasks
Starting Orion 1.x with some additional classpath entries:
<cargo containerId="orion1x" home="c:/apps/orion-1.6.0b" action="start"> <extraClasspath> <pathelement location="libs/clover.jar"/> </extraClasspath> </cargo>
Example using the Maven 3 Plugin
See Starting and stopping a container - Adding jars to a container's classpath
Adding via a -classpath
JVM argument
Starting from Cargo 1.9.3, you can also use the GeneralPropertySet.JVMARGS
and GeneralPropertySet.START_JVMARGS
container properties with a -classpath
(or -cp
) argument to have the associated classpath elements added to the container JVM's classpath, independently from how the container manages the extra classpath.