• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cactus EJB(MDB) Issue

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am getting following erro when running cactus MDB test case.

EJB :
public class MDBBean implements MessageDrivenBean,MessageListener(
.
.
.


public void onMessage(javax.jms.Message message) {

Context env = (Context) ic.lookup("java:comp/env");
value= (String) env.lookup("dsname"); DataSource xads = (DataSource) ic.lookup(value);

}


}

ejb_jar.xml:
<message-driven>
<ejb-name>MDBBeam</ejb-name>
<ejb-class>com.test.MDBBean </ejb-class>
<transaction-type>Container</transaction-type>
<message-driven-destination>
<destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<env-entry>
<env-entry-name>dsname</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>dsValue</env-entry-value>
</env-entry>
</message-driven>



Cactus UniT Test:

public void testOnMessageOk() throws Exception {
Mock mockMessage = new Mock(TextMessage.class);
TextMessage message = (TextMessage) mockMessage.proxy();
mockMessage.matchAndReturn("setText", C.ANY_ARGS, "JMX Text");
mockMessage.matchAndReturn("getJMSMessageID", C.ANY_ARGS,
"123456789");
mockMessage.matchAndReturn("getText", C.ANY_ARGS, "JMX Text MESSAGE");

message.setText("JMX Text MESSAGE");
try{
mrsReceiverBean.ejbCreate();
mrsReceiverBean.onMessage(message);
}
catch(Exception ex){
fail("Failig here");
}

mockMessage.verify();
}



Exception :
<08-Apr-2010 14:42:20 o'clock BST> <Error> <NCLMRS> <BEA-000000> <MDBBean.onMessage Naming ex
ception raised javax.naming.NameNotFoundException: While trying to look up dsname in java:com
p/env.; remaining name 'dsname'>
javax.naming.NameNotFoundException: While trying to look up dsname in java:comp/env.; remaini
ng name 'dsname'
at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139
)
at weblogic.jndi.internal.ApplicationNamingNode.lookup(ApplicationNamingNode.java:144)
at weblogic.jndi.internal.WLEventContextImpl.lookup(WLEventContextImpl.java:254)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:380)
at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45
)

When I am running this through cactus it fails in the look up method. I think we need to setup ejb environemnt before running cactus test.
Can some one help me to resolve this issues.

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<08-Apr-2010 14:42:20 o'clock BST> <Error> <NCLMRS> <BEA-000000> <MDBBean.onMessage Naming ex
ception raised javax.naming.NameNotFoundException: While trying to look up dsname in java:com
p/env.; remaining name 'dsname'>

javax.naming.NameNotFoundException: While trying to look up dsname in java:comp/env.; remaini
ng name 'dsname'

Please check your data source name. Looks issues in the data source look up.
 
Marius Chaminda
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thansks .
It didnt work .
I think the problem is when we involke throhj mock objects how the it is not loading ejb context data. Here the configuration parameters are set as env confgurationa and these will be loaded during the EJB loading .

<env-entry>
<env-entry-name>dsname</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>dsValue</env-entry-value>
</env-entry>

With the mock how can i load these parameters ?#
 
reply
    Bookmark Topic Watch Topic
  • New Topic