-
1. Re: Shared JNDI between cluster nodes
roberto Apr 6, 2005 11:02 AM (in response to roberto)i forgot...
i'm using JBoss AS 4.01sp1 on window XP environment -
2. Re: Shared JNDI between cluster nodes
anguyen Apr 6, 2005 4:22 PM (in response to roberto)"roberto" wrote:
... try { object = new InitialContext().lookup("myinformation"); } catch(Exception vErr) {} ...
That piece of code is using the local JDNI context, not the global one. I think you want to use the global JNDI context. Assuming you're using the all configuration, you would do something like this:try { Properties properties = new Properties(); properties.setProperty(javax.naming.Context.PROVIDER_URL, "localhost:1100"); object = new InitialContext(properties).lookup("myinformation"); } catch (Exception vErr) {}
If you've changed the port number for the HAJNDI service, then adjust the localhost:xxxx property. -
3. Re: Shared JNDI between cluster nodes
roberto Apr 7, 2005 1:59 AM (in response to roberto)Thank You,
i try this way, but in every case, how can i retrieve the port number at runtime?
In all my project (web and ejb container) when i execute a lookup on the JNDI context, i initialize it only using new InitialContext() without using properties.
It's possible to set as default PROVIDER_URL from configuration?
The same application is used under JBoss, WebSphere, SAP WebAS and Weblogic.. so i can't specify a port.
THank You -
4. Re: Shared JNDI between cluster nodes
roberto Apr 7, 2005 2:35 AM (in response to roberto)I try it and works fine.
So the problem now is how use as defualt the HA-JNDI port when in my code (web container and ejb container.. and not in a client) i use new InitialContext() without setting properties directly.
Maybe it is necessary change same configuration file.
I think that the standard class InitialContext retrieve std properties value from some cfg file.. but which one?
Thank You again. -
5. Re: Shared JNDI between cluster nodes
anguyen Apr 7, 2005 9:28 AM (in response to roberto)Try this: http://java.sun.com/products/jndi/tutorial/beyond/env/source.html
You can specify the provider url in jndi.properties. Make sure the file is in the client's classpath. -
6. Re: Shared JNDI between cluster nodes
roberto Apr 8, 2005 2:14 AM (in response to roberto)i haven't a client!
all my code is only a enterprise application composed by Web and EJB modules.
So i must configure jboss server environment to use the new provider url.
i try to change the jndi.properties in the server/all/conf dir (all is my server) but if i do it i cannot more deploy: many exception occurs.
So how can i configure jboss server to use this new provider url as stardard one when SERVER code (jsp and ejb) excute the "new InitialContext()" statement?
Thank You -
7. Re: Shared JNDI between cluster nodes
anguyen Apr 8, 2005 11:01 AM (in response to roberto)Ok, so let me just make sure I understand what you're doing.
Yo have a JSP that binds some object to JNDI by doing something like:... InitialContext context = new InitialContext(); context.rebind("myObject", myObject); ...
Then, in your EJB, you are looking up this object, with something like:... InitialContext context = new InitialContext(); MyClass myObject = (MyClass)context.lookup("myObject"); ...
Some things to try:
1) Pass myObject as an argument into the EJB's business method. This would work if the JSP is invoking a method directly on the EJB during the same request.
2) If instead you are calling a JSP to bind this object, then making a separate request to invoke the EJB that uses the bound object, then try storing your object in the HttpSession in the first JSP, look it up in the session from the second JSP, and then pass it to the EJB during the business method invocation.
3) Create a jndi.properties and put it in the root of your EAR. Your EJB should prefer that jndi.properties over the system jndi.properties.
It sounds like your using JNDI as a way to pass arguments from your JSP to your EJB. I'm sure you have a good reason for doing this, but if I were you, I would redesign the JSPs/EJBs to use a more conventional means of passing arguments (i.e. suggestion 1 or 2). -
8. Re: Shared JNDI between cluster nodes
roberto Apr 9, 2005 3:55 AM (in response to roberto)Ty Andy.
i will try using a jndi.properties in my ear.
I'm not able to pass a new argument in the business method, because i need to pass this to all methods.. and i have about 300 Entity and over 500 session bean... and so too much methods...
ty very much