This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Websphere and the fly likes Setting up JMSAppender with Websphere 5.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Setting up JMSAppender with Websphere 5.0" Watch "Setting up JMSAppender with Websphere 5.0" New topic
Author

Setting up JMSAppender with Websphere 5.0

Seema
Greenhorn

Joined: Aug 05, 2002
Posts: 15
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

Joined: Aug 05, 2002
Posts: 15
my problem is solved.
Tom John
Greenhorn

Joined: Apr 15, 2002
Posts: 29
Would you please share you experience for us ?
Thanks !
Seema
Greenhorn

Joined: Aug 05, 2002
Posts: 15
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.
satyendra gurjar
Greenhorn

Joined: Jul 31, 2002
Posts: 10
Thanx Seema.I got it.
Kal Pitansson
Greenhorn

Joined: Dec 31, 2003
Posts: 1
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.


Kalpitan
Vishal Kumar
Greenhorn

Joined: Jan 13, 2005
Posts: 19
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
 
jQuery in Action, 2nd edition
 
subject: Setting up JMSAppender with Websphere 5.0
 
Similar Threads
Logging question : Where should I put the log4j jar file?
i am getting error in log4j.anyone can please reply me?
Configuring JMSAppender in JBoss
JMSAppender and logging
SimpleSocketServer error