This week's book giveaway is in the Python forum.
We're giving away four copies of Python Continuous Integration and Delivery and have Moritz Lenz on-line!
See this thread for details.
Win a copy of Python Continuous Integration and Delivery this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

Getting javax.Naming.NameNotFoundException when calling WebMethod in JEE 5  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone!

I'm using JEE version 5.0.2. I'm calling a WebMethod in a @WebService annotated class. This annotated class calls a Stateless @EJB that contains the business logic (the implementation) of the WebMethod I'm calling.

My WebService class is defined as follows:



My EJB is defined as follows:



I'm getting the following error:



The WebService class and the EJB are exactly in the same module in the same WAR. This WAR is being deployed in a Glassfish Server version 2.1.1. I only get this warning in the deploy log (server.log):



I'm following the Java EE 5 specification to implement all of this, so I'm trying to do my architecture "by the book".

I already tried to implement an interface as explained in here https://docs.oracle.com/javaee/5/tutorial/doc/bnbmg.html but with no avail, the error persisted.

I have no xml configuration concerning the beans. I was expecting all to work via the annotations but I'm getting the javax.Naming.NameNotFoundException explained above.

Am I missing something? I'm available to give more details if needed.

Thank you!
 
Creator of Enthuware JWS+ V6
Posts: 3246
287
Android Chrome Eclipse IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Am I missing something? I'm available to give more details if needed.  


Please remove the mappedName attribute (2 times) from the EJB as it is an not portable propriety attribute.

Apart from that I would make the WebService an EJB (add @Stateless on top of it) as you are calling it in a EE-environment. You might have a look at my notes, chapter 7 (OCEEJBD-Links)
 
Manuel Moura
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

First of all thanks for the notes. I already read Chapter 7.

I removed the mappedName from the WebService class and the Bean itself as you said. Still got the same error.

I also tried to add @Stateless to the @WebService class. It didn't deploy well and gave me the following problem in the deployment log:



I also tried to apply a solution such as you have in Chapter 7 of your notes but I still get the same error everytime (NameNotFoundException). I already verified that the 'beanName' being used in the @WebService class and the 'name' being used in the EJB itself are exactly the same.

What do you think that may be the problem?

Thank you.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3246
287
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, the problem now is that you can't package an EJB inside a WAR in EE5. That feature is introduced in EE6.

Are you stuck on EE5?

The Webservice class is now handled as a POJO (or did you add some configuration to treat it as a Servlet?). Injecting an EJB inside a POJO doesn't work.
 
Manuel Moura
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed the POM of my WAR to use version 6.0 instead of 5.0.2 of javaee-api. I also verified inside my domain in Glassfish that the Java version being used in the server is -> Java(TM) SE Runtime Environment (build 1.6.0_24-b07).

I found it strange that is Java Standard Edition (SE) instead of Java Enterprise Edition (EE). The problem may be here? What do you think? EJB only have support in Java EE 6 I guess.

However, even after changing the POM to version 6.0 and having Java version 6 running into the server, I tried to deploy a new version of my WAR in the Glassfish server and got exactly the same error:



What do you think?

Thank you!



 
Manuel Moura
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also another thing that I would like to ask: Is it really needed to transform my @WebService annotated class in an EJB using the @Stateless annotation? It seems to me that it should work even without having the @Stateless tag.
The container should just inject the EJB in the @WebService class, since the tag @EJB is there.

To answer your question: no, I don't have any configuration to treat the @WebService annotated class as a servlet.

But once again, if I remove the @Stateless tag from the @WebService class, I have the NameNotFoundException again as I explained above, since the lookup in the context can't find the bean, even if I specify the name and beanName with the same values.

I'm trying to find the logic behind all of these behaviours. Thanks for your help.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Posts: 3246
287
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Also another thing that I would like to ask: Is it really needed to transform my @WebService annotated class in an EJB using the @Stateless annotation?


No, in EE6 it isn't needed. A Webservice class is by default wrapped into a Servlet. In EE5, as far as I remember, you needed to add some configuration otherwise the Webservice class was just a POJO.

I just did a small test on Glassfish v3.1.2 and it worked without any problems. (in Eclipse I created a Dynamic Web Project with Target Runtime pointing to Glassfish).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!