This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Setting up JMSAppender with Websphere 5.0

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have written a standalone client using Log4j JMSAppender for publishing messages .I am using Websphere application server 5.0.I have created TopicConection Factory as well as Topic in Websphere .
My Log4j property file is like this:
log4j.rootLogger=DEBUG,A1
log4j.appender.A1=org.apache.log4j.net.JMSAppender
log4j.appender.A1.InitialContextFactoryName=com.ibm.websphere.naming.WsnInitialContextFactory
log4j.appender.A1.ProviderURL=iiop://domain:2809
log4j.appender.A1.TopicConnectionFactoryBindingName=jms/TopicFactoryJNDI
log4j.appender.A1.TopicBindingName=jms/TopicJNDI
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{DATE} %c %-5p %x- %m%n

and my TestClient java file has the following code:

import org.apache.log4j.Logger;
import java.util.*;
import java.io.*;
import javax.naming.Context;
import javax.naming.InitialContext;

public class TestJMS {
public static void main(String[] args) {
try{
Logger log = Logger.getLogger(TestJMS.class);
log.info("Hello this JMS Appender log message"); ;

} catch(Exception e){
System.out.println(e);
}
}
}

I have created a Aplication client Ear file using Assembly Applciation Tool and added java client file ,log4j.properties file and log4j jar file.
and I am running my client using launchClient tool .But its giving me the following error :
WSCL0014I: Invoking the Application Client class TestJMS
log4j:ERROR Could not find name [jms/TopicFactoryJNDI].
log4j:ERROR Error while activating options for appender named [A1].
javax.naming.NameNotFoundException: jms/TopicFactoryJNDI. Root exceptio
n is org.omg.CosNaming.NamingContextPackage.NotFound
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHe
lper.java:48)
at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(U
nknown Source)
at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java
:3534)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1
565)
at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1
525)
at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:122
5)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)
at javax.naming.InitialContext.lookup(InitialContext.java:359)
at org.apache.log4j.net.JMSAppender.lookup(Unknown Source)
at org.apache.log4j.net.JMSAppender.activateOptions(Unknown Source)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:2
47)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.j
ava:123)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.j
ava:87)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigura
tor.java:645)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigura
tor.java:603)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyC
onfigurator.java:500)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurato
r.java:406)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurato
r.java:432)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionCon
verter.java:460)
at org.apache.log4j.LogManager.<clinit>(LogManager.java:113)
at org.apache.log4j.Logger.getLogger(Logger.java:94)
at TestJMS.main(TestJMS.java:53)
at java.lang.reflect.Method.invoke(Native Method)
at com.ibm.websphere.client.applicationclient.launchClient.createContain
erAndLaunchApp(launchClient.java:616)
at com.ibm.websphere.client.applicationclient.launchClient.main(launchCl
ient.java:420)
at java.lang.reflect.Method.invoke(Native Method)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
I dont understand why???
 
Seema
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my problem is solved.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Would you please share you experience for us ?
Thanks !
 
Seema
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tom,
Actually I am writing a component that will used to log messages over Log 4j JMS Appender .JMS Appender works on Publish to Subscribe .So to configure JMS Appender ,I make changes in Log4j.properties file as follows:
log4j.rootLogger=DEBUG,A1
log4j.appender.A1=org.apache.log4j.net.JMSAppender
log4j.appender.A1.InitialContextFactoryName=com.ibm.websphere.naming.WsnInitialContextFactory
log4j.appender.A1.ProviderURL=iiop://serverdomain:2809
log4j.appender.A1.TopicConnectionFactoryBindingName=jms/TestTopicConFactoryJNDI
log4j.appender.A1.TopicBindingName=jms/TestTopicJNDI
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%d{DATE} %c %-5p %x- %m%n

I created Topic Connection Factory and Topic on Websphere Applciation Server 5.0.
I created application client ear file via Application Assembly tool and run application client ear file using launchClient.bat file and successfully send messages over Topic.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanx Seema.I got it.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Be aware that JMSAppender adds a significant performance hit. Preliminary analysis shows a log event takes between 3 to 4 millis with JMSAppender which is pretty heavy as compared to a 0.1 millis for a FileAppender.

On taking a closer look, it looks like the time taken is for the basic creating and publishing of a JMS Message.

TopicConnection is gotten only once and is cached, so no repeated invocations there. Mentioning this in case someone is thinking of writing caching/pooling logic for the Topic connections. it won't help.

Kal.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I get the error:

log4j:ERROR Error while activating options for appender named [JMS1].
java.lang.NullPointerException
at javax.naming.InitialContext.getURLScheme(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.apache.log4j.net.JMSAppender.lookup(Unknown Source)

The steps that I took are:

1. I configured and installed OpenJMS on the server. Server running.
2. Next in my log4.properties file - I have:

log4j.rootLogger=INFO, JMS1
log4j.appender.JMS1=org.apache.log4j.net.JMSAppender
log4j.appender.JMS1.InitialContextFactoryName=org.exolab.jms.jndi.InitialContextFactory
log4j.appender.JMS1.ProviderURL=rmi://localhost:1099
#log4j.appender.JMS1.TopicBindingName=testtopic
#log4j.appender.JMS1.TopicConnectionFactoryBindingName=JmsTopicConnectionFactory

I do not know if I do need the TopicBindingName and TopicConnectionFactoryBindingName?

Could this be the reason that I am getting the error?

Thanks,

Vishal Chitkara
 
A timing clock, fuse wire, high explosives and a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic