Ok Jaikiran...by coincidence, you wrote a blog about JNDI naming in MyWiki in October 2007
which helped me understand (a bit) about my problem.
Since I was not using an EJB, I was accessing the server directly through JNDI from my
standalone client with the java:/OracleXE1_DS. As your blog said, I cannot do this with
the java namespace because my standalone client and the JBoss server are running in
separate JVMs.
So I've decided to try 2 alternatives :-
(1) To do a stateless EJB3 to access the datasource through the java: namespace. Since the
EJB and the datasource are both managed by the JBoss Server, they should be both running
in the same JBoss JVM.
Here is my new context iniation code in the client. Instead of looking up the datasource
through java namespace, it accesses the EJB3 :-
| Properties p = new Properties();
| p.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
| p.put("java.naming.provider.url", "jnp://localhost:1099");
| p.put("java.naming.factory.url.pkgs", "org.jboss.naming.client");
|
| InitialContext ctx = new InitialContext(p);
| BiddingTestBeanRemote bidder = (BiddingTestBeanRemote)
ctx.lookup("BiddingTestEAR/BiddingTestBean/remote");
| bidder.saveBidder();
|
However, I'm getting a class cast exception as below. Is it because I am using a
remote interface when I am running the database, JBoss, the EJB and the client all on only
my computer - so I cannot use remote interface?
| - Container
jboss.j2ee:ear=BiddingTestEAR.ear,jar=BiddingTestEJB.jar,name=BiddingTestBean,service=EJB3,VMID=413b70d7e6d9776b:-49ef6645:11eaf86b9cb:-7fff
is not yet available
| javax.ejb.EJBException: Invalid (i.e. remote) invocation of local interface (null
container)
| at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:80)
| at $Proxy0.saveBidder(Unknown Source)
| at BidClient.main(BidClient.java:87)
| Exception in thread "main" java.lang.NullPointerException
| at BidClient.main(BidClient.java:99)
|
(2) One other way is to try to move the datasource out of the java namespace to the Global
JNDI namespace in JBoss JNDI view. Do you know a way I can do this?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4199990#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...