Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Query regarding @Local

 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an EJB which has following annotation.

@Remote(SomeInterface.class)

Now, even if I dont implement all the methods of this interface, compiler does not complain.

When I refer this EJB from a servlet and try to call this unimplemented method, it gives some exception as:
Invocation cannot proceed (end of interceptor chain has been hit)


My question is, why is this allowed at first place? Why doesnt compiler complain?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prajakta Acharya wrote:

When I refer this EJB from a servlet and try to call this unimplemented method, it gives some exception as:
Invocation cannot proceed (end of interceptor chain has been hit)

Please post the entire exception stacktrace and the relevant code from the Servlet. Also, which server are you using?

Prajakta Acharya wrote:
My question is, why is this allowed at first place? Why doesnt compiler complain?


The Java compiler knows nothing about EJBs other than the fact that @Remote is a annotation supported by the Java language. Unless there's a specific "implements" keyword, the compiler does no checks on the implemented methods in the class. It's the EJB container which uses the @Remote information to create the relevant proxies. That's the whole reason why you need a container/server to run the EJBs.
 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaikiran,

Thank you very much for your valuable inputs. I am using JBOSS 7.

Now i am facing another issue in my set-up.
@EJB is unable to inject an EJB implementing local interface.

The exception is:
java.lang.IllegalStateException: JBAS011048: Failed to construct component instance
java.lang.IllegalArgumentException: Can not set ejb.EchoBeanLocalInterface field servlet.WebServlet.localEcho to ejb.EchoBeanLocalInterface$$$view17

WebServlet code:



Local Interface:


Bean class:


Packaging of the application:
EAR contents:
1) EJBClient.jar (EJB interfaces)
2) EJBApp.jar (EJB implementation)
3) Webapp.war




 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Resolved.

There were two JARs having that interface class so something related to classpath issues.

Removed one and placed dependencies in MANIFEST.MF and the look up was successful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic