About Question enthuware.oce-ejbd.v6.2.553 :
Moderator: admin
-
- Posts: 54
- Joined: Tue Apr 19, 2011 10:32 am
- Contact:
About Question enthuware.oce-ejbd.v6.2.553 :
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.
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.553 :
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.
thanks for your feedback!
-Paul.
Re: About Question enthuware.oce-ejbd.v6.2.553 :
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?
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?
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.553 :
Section 16.3.4 - Container Provider Responsibility - says,
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.
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.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.
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 :
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.
Regards.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.553 :
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:
As I checked on the API at http://docs.oracle.com/javase/7/docs/ap ... .Object%29,
It says, the rebind method throws NamingException.
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();
}
It says, the rebind method throws NamingException.
Who is online
Users browsing this forum: No registered users and 7 guests