geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <>
Subject Re: adding dependency jars to a GBean at run-time?
Date Tue, 05 Jun 2007 21:55:25 GMT

On Jun 5, 2007, at 1:46 PM, toby cabot wrote:

> Hi Folks,
> In my application of Geronimo I need to add a third-party log4j
> appender to send log messages as SNMP traps.  I can add the jars I
> need to the j2ee-system pom.xml and build a custom Geronimo image, but
> it would be better if I could do everything at run-time so I could use
> an unmolested Geronimo.
> Is there a way to add dependency jars to a configuration at run-time?

No.  Some people think this is a good thing (me) and some people  
think this is a bad thing.

It might work to put them in lib/endorsed, but I don't know if this  
would work or if it would have other side effects.

Is there any way to do something like write a gbean to instantiate  
the appender and register it with log4j?  Then perhaps your appender  
doesn't need to be in the same classloader as the rest of log4j.

In case that doesn't work...

One trick to be aware of (for g 2.0 and I think 1.2 but probably not  
earlier versions) is that you can use to  
replace dependencies on one configuration with another.  So you could  
build your own replacement server.jar (which is a renamed j2ee- and by a line like this in run the  
rest of the g. modules unmodified on top of your replacement system  


hope this helps
david jencks

> For example, could I add something to config.xml so that my jars would
> get added to the j2ee-system classpath?  I tried adding the following
> to var/config/config.xml (based on some other :
>     <module name="org.apache.geronimo.configs/j2ee-system/2.0- 
> SNAPSHOT/car">
>         <gbean name="org.apache.geronimo.configs/j2ee-system/2.0- 
> SNAPSHOT/car?ServiceModule=org.apache.geronimo.configs/j2ee-system/ 
> 2.0-SNAPSHOT/car,j2eeType=SystemLog,name=Logger">
>             <attribute name="configFileName">/path/to/my/log4j.xml</ 
> attribute>
>             <attribute name="defaultEnvironment">
>                 <environment xmlns=" 
> ns/deployment-1.2">
>                  <dependencies>
>                   <dependency>
>                       <groupId>westhawk</groupId>
>                       <artifactId>snmp</artifactId>
>                       <type>jar</type>
>                       <version>5.1</version>
>                   </dependency>
>                   <dependency>
>                       <groupId>mycode</groupId>
>                       <artifactId>log</artifactId>
>                       <type>jar</type>
>                       <version>1.0</version>
>                   </dependency>
>                  </dependencies>
>                </environment>
>             </attribute>
>         </gbean>
>     </module>
> This partially worked - Geronimo used my log4j.xml file.  It didn't
> add the jars to the classpath, though.  The jars are in the repository
> and they're added to the classpath when I declare them in the pom.xml
> and rebuild.
> Thanks,
> Toby

View raw message