aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JMS Queue : Log4j Warning Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JMS Queue : Log4j Warning" Watch "JMS Queue : Log4j Warning" New topic
Author

JMS Queue : Log4j Warning

Csk Kumar
Greenhorn

Joined: Mar 07, 2011
Posts: 13
Hi,
Im using jboss5.1.0GA as an application server. While sending a JMS message to the queue in linux machine its throwing a warning as pasted below:

java SendJmsEvents
log4j:WARN No appenders could be found for logger (org.jnp.interfaces.TimedSocketFactory).
log4j:WARN Please initialize the log4j system properly.
Connection started
Sending an Event to the StateMachine Event=2
Connection stopped

My program SendJmsEvents is able to send text message to the queue but i need to resolve this warning. Please help me out.


Class file for reference :
SendJmsEvents.java

import java.util.Properties;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class SendJmsEvents {
QueueConnection conn;
QueueSession session;
Queue que;

public void setupConnection() throws JMSException, NamingException {
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES,
"org.jboss.namingrg.jnp.interfaces");
properties.put(Context.PROVIDER_URL, "jnp://127.0.0.1:1099");
InitialContext iniCtx = new InitialContext(properties);
QueueConnectionFactory qcf = (QueueConnectionFactory) iniCtx
.lookup("ConnectionFactory");

que = (Queue) iniCtx.lookup("MyQueue");

conn = qcf.createQueueConnection();
session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
conn.start();
System.out.println("Connection started");
}

public void stop() throws JMSException {
conn.stop();
session.close();
conn.close();
System.out.println("Connection stopped");
}

public void sendAnEventToQueue(String event) throws JMSException {
QueueSender send = session.createSender(que);
TextMessage tm = session.createTextMessage(event);
System.out.println("Sending an Event to the StateMachine Event="+event);
send.send(tm);
send.close();
}

public static void main(String args[]) throws Exception {
SendJmsEvents sm = new SendJmsEvents();

sm.setupConnection();
sm.sendAnEventToQueue("2");
sm.stop();
}

}
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10207
    
166

You are missing a log4j.properties (or log4j.xml) from the classpath.

[My Blog] [JavaRanch Journal]
Csk Kumar
Greenhorn

Joined: Mar 07, 2011
Posts: 13
Hi,
I have already set jboss-log4j.xml to the classpath like below:
export CLASSPATH=$CLASSPATH:$JBOSS_HOME/server/default/conf/jboss-log4j.xml

Am still getting the same warning.

My jboss-log4j.xml configuration looks like this:



Here JMSAppender configuration is present only for Topic, but i am using Queue. Will this cause a problem? and if so please let me know how to configure JMSAppender for Queue.
Csk Kumar
Greenhorn

Joined: Mar 07, 2011
Posts: 13
Waiting for the response. Please reply.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Please be patient. Everyone on the JavaRanch is a volunteer, answering questions in their free time.
As for your problem, one does not specify file names on the classpath unless they are archives like zip or jar files (see our FAQ, HowToSetTheClasspath).


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMS Queue : Log4j Warning