You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Christoph Burmeister <ch...@googlemail.com> on 2012/01/30 09:06:17 UTC

custom libraries for activemq in another location (activemq.classpath)

Hi users,

I've written some classes (message-transformers for camel-routing) which
should be used inside ActiveMQ. Actually at the moment I put them into the
%ACTIVEMQ_HOME%\libs-folder and it works. In real-world deployment I want
to separate the custom libraries from the ActiveMQ-own libraries while
putting my own classes in another folder.

After reading some documentation, it should work with the
activemq.home-system-property. But my own classes are not found if I change
the %ACTIVEMQ_CLASSPATH%-variable in activemq.bat from

set
ACTIVEMQ_CLASSPATH=%ACTIVEMQ_BASE%/conf;%ACTIVEMQ_HOME%/conf;%ACTIVEMQ_CLASSPATH%
to
set
ACTIVEMQ_CLASSPATH=%ACTIVEMQ_BASE%/conf;%ACTIVEMQ_HOME%/conf;%ACTIVEMQ_HOME%/customlibs;%ACTIVEMQ_CLASSPATH%

As a workaround I use java.ext.dirs-property this way:

set ACTIVEMQ_CUSTOM_LIBRARIES = %ACTIVEMQ_HOME%/customlibs
and then add a property to the calling java-command in activemq.bat:
-Djava.ext.dirs="%ACTIVEMQ_CUSTOM_LIBRARIES%"
And now while starting up the broker, my custom libraries are picked up
from the customlibs-folder.

This works, no questions, but it would be nicer if somebody could explain
me, how to use the way with the activemq.classpath-property.

best,
christoph

OS:    Win2k8 R2
AMQ: 5.5.1
JVM:  1.6.0_26

Re: custom libraries for activemq in another location (activemq.classpath)

Posted by Christoph Burmeister <ch...@googlemail.com>.
Hi Thorsten,

Thanks for your help. Is it possible to use wildcards in ACTIVEMQ_CLASSPATH
? If not, this would be definitely an improvement.
Meanwhile I got my scenario running by using the tanuki wrapper. I didn't
recognize before, that the wrapper-specific activemq.bat is not the same as
the "normal" activemq.bat and all the path-stuff is managed via
wrapper.conf. For those who might need something similiar to my
requirements, here are the important parts of my wrapper.conf:

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1
wrapper.java.classpath.1=%ACTIVEMQ_HOME%/bin/wrapper.jar
wrapper.java.classpath.2=%ACTIVEMQ_HOME%/bin/run.jar
wrapper.java.classpath.3=%MY_OWN_LIBRARY_LOCATION_1%/*
wrapper.java.classpath.4=%MY_OWN_LIBRARY_LOCATION_2%/*
wrapper.java.classpath.5=%MY_OWN_LIBRARY_LOCATION_3%/*
wrapper.java.classpath.6=%ACTIVEMQ_HOME%/lib/*
wrapper.java.classpath.7=%ACTIVEMQ_HOME%/lib/web/*
wrapper.java.classpath.8=%ACTIVEMQ_HOME%/lib/optional/*

note the numbering ;-)

best,
christoph




2012/1/30 Torsten Mielke <to...@fusesource.com>

> Hello Christoph,
>
> ACTIVEMQ_CLASSPATH is by default only set to include the conf/ directory.
> E.g. if you start a default AMQ instance and connect to it using jconsole
> and click on the VM Summary tab, then you can see this parameter being
> passed into the JVM as follows
>
> -Dactivemq.classpath=/opt/FUSE/AMQ/apache-activemq-5.5.1-fuse-01-13/conf;
>
> Looking at Main.java of activemq-console, subproject, it seems to be
> possible to add additional classpath entries to activemq.classpath, as this
> code section suggests:
>
> // Add any custom classpath specified from the system property
> // activemq.classpath
> app.addClassPathList(System.getProperty("activemq.classpath"));
>
>
> Assuming you have packaged your custom classes into a jar file, you need
> to add the full jar file to the classpath, i.e.
> %ACTIVEMQ_HOME%/customlibs/<file>.jar
>
> and not just the folder containing the jar file.
>
>
> The easiest option for you is probably to place you custom classes in form
> of a jar file into the AMQ_HOME/lib/optional folder. That way these classes
> will be found at runtime.
>
> Hope this helps.
>
>
>
> Torsten Mielke
> torsten@fusesource.com
> tmielke@blogspot.com
>
>

Re: custom libraries for activemq in another location (activemq.classpath)

Posted by Torsten Mielke <to...@fusesource.com>.
Hello Christoph,

ACTIVEMQ_CLASSPATH is by default only set to include the conf/ directory.
E.g. if you start a default AMQ instance and connect to it using jconsole and click on the VM Summary tab, then you can see this parameter being passed into the JVM as follows

-Dactivemq.classpath=/opt/FUSE/AMQ/apache-activemq-5.5.1-fuse-01-13/conf;                

Looking at Main.java of activemq-console, subproject, it seems to be possible to add additional classpath entries to activemq.classpath, as this code section suggests:

// Add any custom classpath specified from the system property
// activemq.classpath
app.addClassPathList(System.getProperty("activemq.classpath"));


Assuming you have packaged your custom classes into a jar file, you need to add the full jar file to the classpath, i.e. 
%ACTIVEMQ_HOME%/customlibs/<file>.jar 

and not just the folder containing the jar file.


The easiest option for you is probably to place you custom classes in form of a jar file into the AMQ_HOME/lib/optional folder. That way these classes will be found at runtime. 

Hope this helps.



Torsten Mielke
torsten@fusesource.com
tmielke@blogspot.com

On Jan 30, 2012, at 9:06 AM, Christoph Burmeister wrote:

> Hi users,
> 
> I've written some classes (message-transformers for camel-routing) which
> should be used inside ActiveMQ. Actually at the moment I put them into the
> %ACTIVEMQ_HOME%\libs-folder and it works. In real-world deployment I want
> to separate the custom libraries from the ActiveMQ-own libraries while
> putting my own classes in another folder.
> 
> After reading some documentation, it should work with the
> activemq.home-system-property. But my own classes are not found if I change
> the %ACTIVEMQ_CLASSPATH%-variable in activemq.bat from
> 
> set
> ACTIVEMQ_CLASSPATH=%ACTIVEMQ_BASE%/conf;%ACTIVEMQ_HOME%/conf;%ACTIVEMQ_CLASSPATH%
> to
> set
> ACTIVEMQ_CLASSPATH=%ACTIVEMQ_BASE%/conf;%ACTIVEMQ_HOME%/conf;%ACTIVEMQ_HOME%/customlibs;%ACTIVEMQ_CLASSPATH%
> 
> As a workaround I use java.ext.dirs-property this way:
> 
> set ACTIVEMQ_CUSTOM_LIBRARIES = %ACTIVEMQ_HOME%/customlibs
> and then add a property to the calling java-command in activemq.bat:
> -Djava.ext.dirs="%ACTIVEMQ_CUSTOM_LIBRARIES%"
> And now while starting up the broker, my custom libraries are picked up
> from the customlibs-folder.
> 
> This works, no questions, but it would be nicer if somebody could explain
> me, how to use the way with the activemq.classpath-property.
> 
> best,
> christoph
> 
> OS:    Win2k8 R2
> AMQ: 5.5.1
> JVM:  1.6.0_26