<p>
hey i am using the sun java system administration server 8.2 for deploying an jms application created in eclipse.<br />
the application is a modified version of one taken from link<br />
<u>
http://ramakrsna.wordpress.com/2008/02/13/a-j2ee-application-using-jms/</u><br />
as i found it to be incomplete<br />
but my query is while running my application through a junittest case <br />
when i keep the logging level of server from the admin console to <strong>info (default)<br />
</strong>the application shows no exception though it does give the desired result.<br />
but the apparently shows that the junittest case is a success.<br />
the problem arises when i change the logging level of server to <strong>fine</strong><br />
now just after making this modification and keeping everything as it is<br />
running the application shows exception. what i find more confusing to me that my junittest case is a failure now. what the logging level of the server has to do with junit, an exception is always an exception (as i have my try catch block for it which works for logging level <strong>fine</strong>) the logging level cannot affect exception handling mechanism can it.<br />
the logging level for jms & connector is set to <strong>fine<br />
</strong>i created the necessary connection factory and the jms destination resource & jms physical destination.<br />
The jar added by me in my client application are <br />
j2ee.jar<br />
appserv-rt.jar<br />
appserv-admin.jar<br />
appserv-ext.jar<br />
imqjmsra.jar<br />
derbyclient.jar<br />
projBeans.jar<br />
sun-appserv-ant.jar<br />
junit-4.5.jar<br />
My client java file for which i get error is:<br />
<strong>UserJMSClient .java</strong>
</p>
<br />
<p>
package com.client;<br />
import javax.jms.JMSException;<br />
import javax.jms.MessageProducer;<br />
import javax.jms.ObjectMessage;<br />
import javax.jms.Queue;<br />
import javax.jms.QueueConnection;<br />
import javax.jms.QueueConnectionFactory;<br />
import javax.jms.Session;<br />
import javax.naming.Context;<br />
import javax.naming.InitialContext;<br />
import javax.naming.NamingException;<br />
import com.beans.User;<br />
public class UserJMSClient {<br />
Context jndi = null;<br />
QueueConnectionFactory qFactory = null;<br />
Queue queue = null;<br />
boolean initialized = false;<br />
MessageProducer producer;<br />
private void initialize() throws NamingException {<br />
jndi = new InitialContext();<br />
qFactory = (QueueConnectionFactory)jndi.lookup("persistUserConnectionFactory");<br />
queue = (Queue)jndi.lookup("persistUserQueue");<br />
}<br />
public void sendObject(User user) throws Exception {<br />
if (!initialized) {<br />
try {<br />
initialize();<br />
} catch(NamingException e) {<br />
e.printStackTrace();<br />
throw new Exception("Jndi lookup failed");<br />
} catch(Exception e) {<br />
e.printStackTrace();<br />
}<br />
initialized = true;<br />
}<br />
try {<br />
QueueConnection qConn = (QueueConnection)qFactory.createQueueConnection("admin","admin");<br />
Session session = qConn.createSession(false, Session.AUTO_ACKNOWLEDGE);<br />
ObjectMessage oMsg = session.createObjectMessage(user);<br />
producer = session.createProducer(queue);<br />
producer.send(oMsg);<br />
} catch (JMSException e) {<br />
e.printStackTrace();<br />
throw new Exception("sendObject Method Failure");<br />
} catch (Exception e) {<br />
e.printStackTrace();<br />
}<br />
}<br />
}<br />
<strong>UserJMSClientTest.java</strong> <br />
package com.client;<br />
import static org.junit.Assert.;<br />
import org.junit.BeforeClass;<br />
import org.junit.Test;<br />
import com.beans.User;<br />
public class UserJMSClientTest {<br />
private static UserJMSClient userJMSClient = null;<br />
private static User user = null;<br />
@BeforeClass<br />
public static void setUpBeforeClass*() throws Exception {<br />
try {<br />
userJMSClient = new UserJMSClient();<br />
user = new User("rama", "krishna", "s", 24, "india");<br />
}<br />
catch(Exception ex) {<br />
ex.printStackTrace(System.out);<br />
fail("Exception thrown");<br />
}<br />
}<br />
@Test<br />
The exception after logging level change is:
</p>
<p>
May 7, 2009 9:02:17 PM com.sun.corba.ee.spi.logging.LogWrapperBase doLog<br />
INFO: "IOP00710299: (INTERNAL) Successfully created IIOP listener on the specified host/port: all interfaces/3855"<br />
javax.naming.NameNotFoundException: persistUserConnectionFactory not found<br />
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:185)<br />
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:157)<br />
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:101)
*********************************************************************<br />
</p>
[Message sent by forum member 'anishu' (anishu)]
http://forums.java.net/jive/thread.jspa?messageID=345775