Can u Help me, how to solved this message bean, Error?

Hi All,

I am new bie for this J2EE. How can i solved this.. always javax.naming.NameNot FoundException but i 've already done to put in jndi name in the ejb.xml descriptor .

try

{

connectionfactory = (ConnectionFactory)jndiContext.lookup("jms/SimpleMessageDestinationFactory");

destination = (Queue)jndiContext.lookup("jms/SimpleMessageBean");

}catch(NamingException e){

System.err.println("Jndi lookup failed:" + e.toString());

System.exit(1);

}

try{

connection = connectionfactory.createConnection();

session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

messageProducer = session.createProducer(destination);

Error for compilation.

init:

deps-jar:

compile-single:

run-single:

Jndi lookup failed:javax.naming.NameNotFoundException: SimpleMessageDestinationFactory not found

Java Result: 1

BUILD SUCCESSFUL (total time: 5 seconds)

Thanks for your reply..

CJ_125

[1026 byte] By [CJ_125a] at [2007-11-27 4:18:37]
# 1

CJ,

Do you mean ejb-jar.xml? The portable way to lookup this kind of resource dependency in Java EE

is to define an @Resource annotation or a resource-ref in ejb-jar.xml.The res-ref-name element

of resource-ref corresponds to the private component naming environment of the component.

Your code snippet does not show how the jndiContext was instantiated but the code

should look like this :

InitialContext ic = new InitialContext();

destination = (ConnectionFactory) ic.lookup("java:comp/env/jms/SimpleMessageDestinationFactory");

In this case, the name of the dependency within your component environment(res-ref-name) must be

"jms/SimpleMessageDestinationFactory".Note that this is not the same thing as the

global JNDI name of the Connection Factory.

If you're defining a Queue dependency in the descriptor, use a resource-env-ref instead.

--ken

ksaksa at 2007-7-12 9:25:26 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

This is an xml based for ejb.xml descriptor

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">

<sun-ejb-jar>

<enterprise-beans>

<name>SimpleMessage</name>

<ejb>

<ejb-name>SimpleMessage</ejb-name>

<jndi-name>jms/SimpleMessageBean</jndi-name>

<mdb-connection-factory>

<jndi-name>jms/SimpleMessageDestinationFactory</jndi-name>

</mdb-connection-factory>

</ejb>

<cmp-resource>

<jndi-name>jms/SimpleMessageBean</jndi-name>

</cmp-resource>

<message-destination>

<message-destination-name>Test</message-destination-name>

<jndi-name>jms/SimpleMessageDestinationFactory</jndi-name>

</message-destination>

</enterprise-beans>

</sun-ejb-jar>

Thanks ken for reply.

CJ_125a at 2007-7-12 9:25:26 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Are you trying to connect from a stand-alone client? In this case, you must include for the client several jars that you will find in lib server directory

sun/sdk/lib/javaee.jar

sun/sdk/lib/j2ee.jar

sun/sdk/lib/appserv-rt.jar

sun/sdk/lib/appserv-admin.jar

sun/sdk/lib/appserv-ws.jar

And moreover you must include the next. I show separately because at the beggining I didn磘 know and jms fails me.

sun/sdk/lib/install/applications/jmsra/imqjmsra.jar

I hope it helps you.

Hayken.

haykena at 2007-7-12 9:25:26 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...