• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OperationNotSupportedException vs NamingException

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to p.434 of JSR 318,
The container must ensure that the EJB instance 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.


However, when I read the API , the InitialContext and Context's rebind (String name, Object obj) throws NamingException instead.

I tried:


The output is :

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)
at com.ivan.scbcd6.FirstBean.rebinding(FirstBean.java:45) ....



I think we need to know this for the exam since the Enthuware asks a similar question.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2533
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting difference between the specifications and the API ! Well spotted. Note that an OperationNotSupportedException is a NamingException, but the specification is explicit about the OperationNotSupportedException...

I would also go for the API in this case, but just start a discussion about this question on the Enthuware forums.
 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I posted this question on Enthuware's forum and waiting for their authors' replies . OperationNotSupportedException is a child class of NamingException.
Enthuware explains that the rebind method will throw OperationNotSupportedException while the API says NamingException.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic