java - Can't do a lookup for JNDI -


i have following declaration in ejb-jar.xml

<enterprise-beans>          <entity>             <description>simple cmp entity bean example</description>             <ejb-name>calculatorbean</ejb-name>             <remote>ejb3.stateless.calculatorremote</remote>             <ejb-class>ejb3.stateless.calculatorbean</ejb-class>             <persistence-type>container</persistence-type>             <prim-key-class>java.lang.integer</prim-key-class>             <reentrant>false</reentrant>         </entity>  </enterprise-beans> 

and tried servlet follows;

 calculatorremote calculator = (calculatorremote)ic.lookup("java/comp/env/:calculatorbean"); 

but says name specified cannot found.

i have created classes calculatorremote , calculatorbean.

here calculatorremote

@remote public interface calculatorremote {      public float add(float x, float y);      public float subtract(float x, float y);      public float multiply(float x, float y);      public float division(float x, float y); } 

calculatorbean implementation of calculatorremote. ic initialcontext.

try way lookup bean

 calculatorremote calculator = (calculatorremote)ic.lookup("java:comp/env/calculatorbean"); 

edit:

for glassfish no need add remove java:comp/env/ part.

 calculatorremote calculator = (calculatorremote)ic.lookup("calculatorbean"); 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -