-
1. Re: I know, another JNDI lookup issue - local ejb
philc_jboss Dec 12, 2005 10:29 PM (in response to philc_jboss)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
<local-tx-datasource>
<jndi-name>GenericDS</jndi-name>
<connection-url>[jdbc: url for use with Driver class]</connection-url>
<driver-class>[fully qualified class name of java.sql.Driver implementation]</driver-class>
<user-name>x</user-name>
y
</local-tx-datasource>
WRONG!
new InitialContext().lookup("GenericDS");
CORRECT
new InitialContext().lookup("java:/GenericDS");
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();
...
props.put(javax.naming.Context.PROVIDER_URL,"jnp://localhost:1099");
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. -
2. Re: I know, another JNDI lookup issue - local ejb
philc_jboss Dec 15, 2005 11:14 PM (in response to philc_jboss)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.
-
3. Re: I know, another JNDI lookup issue - local ejb
lepe Dec 16, 2005 12:46 AM (in response to philc_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.
/L -
4. Re: I know, another JNDI lookup issue - local ejb
philc_jboss Dec 16, 2005 1:26 AM (in response to philc_jboss)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
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
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.
-Phil -
5. Re: I know, another JNDI lookup issue - local ejb
jaikiran Dec 16, 2005 2:40 AM (in response to philc_jboss)"philc_jboss" wrote:
jmx-console
service=JNDIView:
+- 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). -
6. Re: I know, another JNDI lookup issue - local ejb
philc_jboss Dec 17, 2005 9:49 PM (in response to philc_jboss)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)