Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB to WAR Dependencies  RSS feed

 
James Gordon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I got 2 question regarding EJB:

1) Is it correct for EJB jars to have dependencies on the WAR (WEB-
INF/lib)? Reason I asked is because I encountered some app server
which support it but some don't. And I also read that J2EE spec
doesn't specify much about the classloading mechanism.

2) I have some POJO DAOs. Should I park it under the EJB, WAR or
another separate java module?

Please comment.


Thanks in advance.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,
Why do you need to have the EJB refer to the WAR? I can't think of any scenarios where this is necessary. It is also likely to involve a circular dependency.

I would favor putting the DTOs in a separate Java project since it is easier to reuse them. If you know they will not be reused, it is fine to put them in the EJB project. If they go in the Web project, you will likely have the circular dependency problem.
 
James Gordon
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've 2 separate 'tightly' link projects meant to be deployed together.
One is running on EJB and the other POJO based.
So, for the first project, the business logic is in
the EJB, the second in the WAR.

Due to this, the EJB might need to re-use some classes
in the WAR.

Actually the cause of this issue is that the original app server
that we had used supported EJB -> WAR dependencies. Meaning it allow
the EJB to access the WAR classes.

But when we try to run on other app server, it doesn't seem to
allow this.


Thanks.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36406
454
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Gordon:
the business logic is ... in the WAR.

I think this is a code/design smell. I WAR is supposed to be a web project. In a small project, it isn't a big deal to have everything in there. But when you get to reuse, you encounter problems (as you've noticed.)

Logically, there isn't realy a dependency from the EJB to the WAR. There is a dependency from the EJB to code that happens to reside in the WAR. This code could easily be moved to a Java utility project and there would be no dependency on the WAR. I think this is your best bet in the long run. It's also common practice.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!