Ok so I finally stumbled across a Wiki entry (still no luck):
Why do I get NameNotFoundException??
By default JBoss binds ConnectionFactorys/DataSources in the java: namespace. This is only visible inside the same virtual machine and only when using a naming context that is not configured to use a transport.
Mistake 1 - Not using the java: namespace
<connection-url>[jdbc: url for use with Driver class]</connection-url>
<driver-class>[fully qualified class name of java.sql.Driver implementation]</driver-class>
Mistake 2 - Going over a transport
By using a provider url, you are effectively make your jndi access remote, meaning the java: namespace is not visible.
Properties props = new Properties();
IntialContext context = new InitialContext(props)
I updated my code to not make mistake 2 (props provider url), and used the "correct" example in mistake 1 - still no luck. This is driving me crazy.
Please if anyone has overcome the same type of issue please let me know. Thanks.
Ok, I can't imagine there is not an answer to this issue (nobody else has experienced this issue). I guess this is seen as a newbie/configuration addressed in configuration documents that I overlooked. Either way I will continue to try to get this working somehow otherwise I will have to switch back to my previous app server - I was hoping to be able to use JBoss.
Are you doing the lookup inside the JBoss JVM?
In that case:
1. Use the in JBoss already existent jndi.properties (dont edit it!) and just do a new InitialContext()
2. Do the lookup like in your first post - that is dont use the java:/ namespace.
Reviewing my initial post, I see with the calling code I did not mention that I was calling from a struts action / servlet (Tomcat bundled with JBoss). I know that Tomcat has its' own JNDI Server and from what I read I have to make a global reference.
I am using the default jndi.properties in my classpath:
### JBossNS properties
Thanks for your reply, I am so frustrated I am sure I have overlooked something (otherwise I would not be having this issue). Discovering resolution is becomming a personal quest. Thanks again.
+- local (class: org.jnp.interfaces.NamingContext)
| +- MyBeanLocal@800877 (proxy: $Proxy149 implements interface org.ejb.MyBeanLocalHome)
This i think should just be MyBeanLocal and NOT MyBeanLocal@800877. I had seen a similar issue being reported in the forums. Currently i am not able to locate the same(I guess it was in EJB/JBOSS forum).
Thanks for your reply jaikiran!! You were correct. I searched for some time through EJB/JBOSS and found another related post. I changed my jboss.xml <jndi-name/> tag to <local-jndi-name/> and a couple other changes and finally got my deployment working :). I still have a class loader issue that I will continue to work with (many people have the same issue and have to set a global flag to "true"), but I don't have other context apps so this is fine for now. Thanks to your reply I was able to head down a path to resolution.
Now my jmx-console show the bean deployment as:
Global JNDI Namespace
+- MyBeanLocalHome (proxy: $Proxy100 implements interface org.blah.ejb.MyBeanLocalHome)