Re: embedding openJMS into tomcat

Ken M <wgold-WNUMbkg7HQH83n0zhJamUgC/[email protected]>
Newsgroups gmane.comp.java.openjms.user
Message-ID <[email protected]>
TJ -

Sorry, my response was inconplete. 

You also need to pass into tomcat (via the environment variable 
JAVA_OPTS, or some other mechanism[ie editing the catalina script]) the 
location so the OpenJMS home:

if I was running a java app with OpenJMS embedded, I would call 
"-Dopenjms.home=/path/to/openjms/"

for Tomcat5 on Linux: 

export JAVA_OPTS = $JAVA_OPTS -Dopenjms.home=/path/to/openjms/

For windows - reformat and install linux :P heh.

OpenJMS uses the "new JmsServer(configFile)" to start the launch, and 
this "openjms.home" path to load the rest of its configuration 
information from. (Log4j, policy files etc).

We've narrowed it down to just these files being required under 
"openjms.home":

log4j.properties
log4j.xml
openjms.log
openjms.policy
openjms.xml <-- the one you point to in "configFile"

I'm not sure if the newer builds still have thse same requirement, but I 
thought it best to be complete.

Once again - hope this helps.

K


Ken M wrote:

> TJ -
>
> Embedding it isn't so hard.  You just have to be able to pass OpenJMS 
> the location of the configuration file you would have used in the 
> normal standalone startup.
>
> Here's a denatured version of what we do on servlet init().
>
> ...
> JmsServer theJmsServer;
> ...
>
>          String configFile = 
> config.getInitParameter("OpenJms.config"); // readable by the 
> servlet's security manager. maybe none.
>          try
>          {
>             String PROVIDER_URLR = "tcp://" + 
> InetAddress.getByName("localhost").getHostAddress() + ":3035";
>             config.getServletContext().setAttribute("JMS_PROVIDER", 
> PROVIDER_URL);
>          }
>          catch (UnknownHostException e)
>          {
>             logger.log(Level.SEVERE, "Unknown Host in PROVIDER_URL.", e);
>          }
>
>          // Create and start the OpenJMS server
>          // All we can do is fire it off and let it go.
>          logger.info("Loading OpenJMS Server with config [" + 
> configFile + "]");
>
>          try
>          {
>             theJMSServer = new JmsServer(configFile);
>             logger.info("OpenJMS Server instantiated, running init().");
>             theJMSServer.init(); // all of OpenJMS's startup work is 
> done in here.
>          }
>          catch (Throwable e)
>          {
>             logger.log(Level.SEVERE, "OpenJMS Server could not run.", e);
>          }
>
> ...
>
> So when your Servlet init()s  - the server starts.  When tomcat or 
> your webapp dies, so does the JMS server.
> In order to access and use the server - you would get the JNDI context 
> and interact normally using the context's PROVIDER_URL to create 
> Topic/QueueConnections etc.
>
> Hope this helps.
>
>
>
> Ken
>
>
>
>
>
> TJ Greenier wrote:
>
>> I also use OpenJMS with tomcat 5.  I use an http connection and 
>> deployed the openjms tunnel servlet to my tomcat webapp.  This worked 
>> very well for us.
>>
>> I do have a question though.  Currently I start the openJMS server 
>> and tomcat servers seperately using each ones startup script.  Has 
>> anyone started and stopped openJMS programmatically?  if so, any 
>> suggestions?  I want to put some code in a servlet that will start up 
>> openJMS when tomcat is started and shutdown openJMS when tomcat is 
>> shutdown.  For my project this will be sufficient, because if tomcat 
>> is down then openjms can be down as well.  Plus we are only 
>> connecting via http. 
>>
>> Any ideas or thoughts are much appreciated.
>>
>> Thanks,
>> TJ
>>
>> On 9/22/05, *Ken M* <wgold-WNUMbkg7HQH83n0zhJamUgC/[email protected] 
>> <mailto:wgold-WNUMbkg7HQH83n0zhJamUgC/[email protected]>> wrote:
>>
>>     Stas -
>>
>>     I use OpenJMS with Tomcat 5 with great results.
>>
>>     I just embed the OpenJMS initialization into my webapp's servlet
>>     init()
>>     and presto chango - OpenJMS in Tomcat.
>>
>>     I'm not sure if there's a way to make Tomcat use OpenJMS directly
>>     - as
>>     Tomcat doesn't really do anything by itself without a web
>>     application to
>>     control.
>>
>>     OpenJMS is a perfect drop-in.
>>
>>     Ken
>>
>>
>>     Stas Ostapenko wrote:
>>
>>     >Hi !
>>     >
>>     >I'm wery interested in embedding openJMS into Tomcat.There is no
>>     docs
>>     >or some kind of tutorial how its can be done. I'm googling with no
>>     >results on this topic. Only some articles about using standalone
>>     >openJMS with Tomcat. Step by step tutorial will be simlpy great.
>>     >Is it possible to do something similar to Activemq +Tomcat
>>     integration
>>     >(http://activemq.codehaus.org/Tomcat) ?
>>     >
>>     >Plese help. Thanks.
>>     >Regards, Stas.
>>     >
>>     >
>>     >-------------------------------------------------------
>>     >SF.Net email is sponsored by:
>>     >Tame your development challenges with Apache's Geronimo App Server.
>>     >Download it for free - -and be entered to win a 42" plasma tv or
>>     your very
>>     >own Sony(tm)PSP.  Click here to play:
>>     http://sourceforge.net/geronimo.php
>>     >_______________________________________________
>>     >openjms-user mailing list
>>     >[email protected]
>>     <mailto:[email protected]>
>>     >https://lists.sourceforge.net/lists/listinfo/openjms-user
>>     <https://lists.sourceforge.net/lists/listinfo/openjms-user>
>>     >
>>     >
>>     >
>>
>>
>>
>>     -------------------------------------------------------
>>     SF.Net email is sponsored by:
>>     Tame your development challenges with Apache's Geronimo App Server.
>>     Download it for free - -and be entered to win a 42" plasma tv or
>>     your very
>>     own Sony(tm)PSP.  Click here to play:
>>     http://sourceforge.net/geronimo.php
>>     _______________________________________________
>>     openjms-user mailing list
>>     [email protected]
>>     <mailto:[email protected]>
>>     https://lists.sourceforge.net/lists/listinfo/openjms-user
>>
>>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.