Page 1 of 1
About Question enthuware.oce-ejbd.v6.2.553 :
Posted: Fri May 27, 2011 2:28 pm
by deadlock_gr
If the lookup fails it throws a NamingException. If this is not caught and properly handed, the statement after the lookup will never execute. I would recommend to enclose the lookup in a try / catch block.
Re: About Question enthuware.oce-ejbd.v6.2.553 :
Posted: Sat May 28, 2011 7:17 am
by admin
I don't think it is really relevant to the question. Also it does not claim to show the whole code of the bean.
thanks for your feedback!
-Paul.
Re: About Question enthuware.oce-ejbd.v6.2.553 :
Posted: Wed Feb 01, 2012 6:13 pm
by Mark
I think that the answer is wrong.
I am able to execute the following code:
Context ctx = new InitialContext();
ctx.rebind("java:global/MatrixEAR/Matrix/Calculator!interfaces.CalculatorRemote", "test");
and everyting works fine. After lookup for "java:global/MatrixEAR/Matrix/Calculator!interfaces.CalculatorRemote" - 'test' is returned.
I am using Glassfish 3.1.
Can anyone clear this out?
Re: About Question enthuware.oce-ejbd.v6.2.553 :
Posted: Thu Feb 02, 2012 6:33 am
by admin
Section 16.3.4 - Container Provider Responsibility - says,
The container must ensure that the enterprise bean instances have only read access to their environment variables. The container must throw the javax.naming.OperationNotSupportedException from all the methods of the javax.naming.Context interface that modify the environment naming context and its subcontexts.
One interpretation of this could be: only the entries that exist in the context can't be changed but if an entry doesn't exist in the context (as is illustrated in the given code), a bean code can change it.
Another interpretation could be that the environment itself is read only, which seems too restrictive but the language seems to imply just that.
It is really difficult to say why Glashfish implemented it that way
HTH,
Paul.
Re: About Question enthuware.oce-ejbd.v6.2.553 :
Posted: Thu Feb 02, 2012 9:28 am
by Mark
OK, but "java:global/MatrixEAR/Matrix/Calculator!interfaces.CalculatorRemote" is bounded to the bean and Glassfish allows to rebind that name. It is Java EE Certified server so it is very odd that it does not follow the specs. Can someone say samething more on that?
Regards.
Re: About Question enthuware.oce-ejbd.v6.2.553 :
Posted: Thu Apr 23, 2015 6:54 pm
by himaiMinh
I tried an example with Glassfish 3.1.2, it throws this exception:
Severe: javax.naming.NamingException: java:comp namespace cannot be modified
at com.sun.enterprise.naming.impl.JavaURLContext.rebind(JavaURLContext.java:285)
at com.sun.enterprise.naming.impl.SerialContext.rebind(SerialContext.java:704)
at javax.naming.InitialContext.rebind(InitialContext.java:408)
at javax.naming.InitialContext.rebind(InitialContext.java:408)
The code is like this:
Code: Select all
try{
InitialContext context= new InitialContext();
context.rebind("java:comp/env/com.ivan.scbcd6.FirstBean/i", new Integer(120));
}
catch (NamingException e){
e.printStackTrace();
}
As I checked on the API at
http://docs.oracle.com/javase/7/docs/ap ... .Object%29,
It says, the rebind method throws NamingException.