• Post Reply Bookmark Topic Watch Topic
  • New Topic

annotations loading in VM

 
tovi sofer
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've defined interfaces in server API with EJB annotation- like Remote,ApplicationException, SecurityDomain.
The client depends on the server API projet and uses the interfaces and classes with those annotations. But- the client does not have the ejb annotations jars in its classpath.
It seems like this should cause a ClassNotFound exception on runtime in the client side, when the annotated classes are loaded, but it doesn't.
All of these annotations are of Runtime type.

Why is exception not thrown? Is it valid to leave the client classpath without these annotation classes?

thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35744
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tovi,
Some annotations are used at compile time rather than runtime. I know remote is one of them. I'm not sure about the two others.

If an annotation is only used at compile time, it is not represented in the .class file which is what the client VM sees.
 
tovi sofer
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the annotations I'm using are Rutime, as I wrote.
I've exported the client to external location to check it does not have the jars in the classpath, and it does not cause exception when it uses the annotated classes. So this situation is not possible?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35744
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
I know remote is one of them. I'm not sure about the two others.

I retract this statement. You are correct. It wouldn't make any sense for it to be a compile time annotation as it is needed at deploy time.

I'm thinking it only matters if an annotation jar is found when the annotation is references. This is how it works for normal classes as far as I know. In the following example, calling method print will work even if the jar B relies on isn't present.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!