- This topic has 6 replies, 6 voices, and was last updated 16 years, 9 months ago by fjefeoi.
-
AuthorPosts
-
paata_lomMemberfierst of all sorry for my english :).
1.Eclipse Version: 3.1.0
2.jboss-4.0.4.GA
3.Ejb 3.0there is my simple example :
1.Remote Interfacepackage org.jboss.tutorial.stateless.bean; import javax.ejb.Remote; @Remote public interface CalculatorRemote { public int add(int x, int y); public int subtract(int x, int y); }
2.Local Interface
package org.jboss.tutorial.stateless.bean; import javax.ejb.Local; @Local public interface CalculatorLocal extends CalculatorRemote { public int add(int x, int y); public int subtract(int x, int y); }
3.Bean
package org.jboss.tutorial.stateless.bean; import javax.ejb.Stateless; import org.jboss.tutorial.stateless.bean.CalculatorRemote; public @Stateless class CalculatorBean implements CalculatorRemote { public int add(int x, int y) { return x + y; } public int subtract(int x, int y) { return x - y; } }
4. and Client
package org.jboss.tutorial.stateless.client; import org.jboss.tutorial.stateless.bean.CalculatorRemote; import javax.naming.InitialContext; public class Client { public static void main(String[] args) throws Exception { InitialContext ctx = new InitialContext(); CalculatorRemote calculator = (CalculatorRemote) ctx.lookup("CalculatorBean/remote"); System.out.println("1 + 1 = " + calculator.add(1, 1)); System.out.println("1 - 1 = " + calculator.subtract(1, 1)); } }
then in eclipse ide i did project jar file using export and copy it in the
jboss_home/server/all/deploy folder
then start jboss from eclipse
when i’m running client a get an error like that :Exception in thread “main” javax.naming.NameNotFoundException: CalculatorBean not bound
is there enything wrong ?
Riyad KallaMemberMoving to OT > Soft Dev
zambizziMemberYes, you’ve made a syntactical error.
When looking the bean up via JNDI you need to specify EarProjectName/BeanName/local (or remote in your case).
Try this:
InitialContext ctx = new InitialContext();
CalculatorRemote calculator = (CalculatorRemote) ctx.lookup(“MyEarProjectName/CalculatorBean/remote”);Substitute “MyEarProjectName” with the name of your enterprise project.
Also, why does your local interface derive from your remote interface? You should use just one or the other on the bean implementation.
HTH
-v
maheshdssMemberHI ,
What you said i have done the same thing but still i m facing the same problem.Step 1:
InitialContext ctx = new InitialContext();
Calculator calculator = (Calculator) ctx.lookup(“CalculatorBean/remote”);System.out.println(“1 + 1 = ” + calculator.add(1, 1));
System.out.println(“1 – 1 = ” + calculator.subtract(1, 1));i got following error :
run:
[java] Exception in thread “main” javax.naming.NameNotFoundException: CalculatorBean not bound
[java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
[java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
[java] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
[java] at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
[java] at sun.rmi.transport.Transport$1.run(Transport.java:153)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
[java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
[java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
[java] at java.lang.Thread.run(Thread.java:595)
[java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
[java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
[java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
[java] at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
[java] at javax.naming.InitialContext.lookup(InitialContext.java:351)
[java] at client.Client.main(Client.java:33)
[java] Java Result: 1Step 2:
InitialContext ctx = new InitialContext();
Calculator calculator = (Calculator) ctx.lookup(“sampleproject/CalculatorBean/remote”);System.out.println(“1 + 1 = ” + calculator.add(1, 1));
System.out.println(“1 – 1 = ” + calculator.subtract(1, 1));then i got following error :
run:
[java] Exception in thread “main” javax.naming.NameNotFoundException: sampleproject not bound
[java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
[java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
[java] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
[java] at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:585)
[java] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
[java] at sun.rmi.transport.Transport$1.run(Transport.java:153)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
[java] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
[java] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
[java] at java.lang.Thread.run(Thread.java:595)
[java] at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
[java] at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
[java] at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
[java] at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
[java] at javax.naming.InitialContext.lookup(InitialContext.java:351)
[java] at client.Client.main(Client.java:33)
[java] Java Result: 1Here i have made sampleproject.jar file and uploaded on all/deploy folder.
Please suggest me.
prasadsagalaMemberhi to all,
I am also getting the same problem as u explained above…..can any body help me be out the above problem…..if u got solution to the above problem plz send me a mail or reply to the post…Thanks in Advance
Prasad Sagala (sagala.prasad@yahoo.co.in)
fjefeoiMemberThis message has not been recovered.
fjefeoiMemberThis message has not been recovered.
-
AuthorPosts