facebook

EJB and JARs

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #208240 Reply

    pumaxx
    Member

    Hi,
    I’ve four projects: EAR, EJB, WEB, Commons.
    Commons project include classes shared between EJB and WEB tier.
    When I deploy the overall EAR I got ClassNotFoundException.
    I see that Web WAR contains Commons classes as a jar into \lib folder.
    How can I do the same thing with EJB ?
    This is needed because I have to deploy EJB and WEB on different machine in production environment.
    Should I manually package commons classes into a Common.jar and then manually copy it into a lib directory into the EJB project?

    #208255 Reply

    Scott Anderson
    Participant

    Should I manually package commons classes into a Common.jar and then manually copy it into a lib directory into the EJB project?

    The web project’s dependent project inclusion mechanism is really intended to automatically package libraries that are only needed by the web project. For EAR deployment for libraries that are used by both the EJB and Web tiers we recommend that you jar your common project(s) and them to the root level of your EAR project. They’ll be automatically packaged by doing this. Next, you need to tell your EJB jar and WAR where to look for the common jar and this is done by modifying the Class-Path entry in each project’s MANIFEST.MF file to point to the library’s deployment-time location.

    #208280 Reply

    pumaxx
    Member

    @support-scott wrote:

    Should I manually package commons classes into a Common.jar and then manually copy it into a lib directory into the EJB project?

    The web project’s dependent project inclusion mechanism is really intended to automatically package libraries that are only needed by the web project. For EAR deployment for libraries that are used by both the EJB and Web tiers we recommend that you jar your common project(s) and them to the root level of your EAR project. They’ll be automatically packaged by doing this.

    I tried but it doesn’t work! What do you mean with “root level of EAR”?
    I put my common.jar at level before META-INF directory

    #208284 Reply

    pumaxx
    Member

    I manually edit .mymetadata and application.xml files to “see” common.jar…i think this is a bug, don’t you?

    #208292 Reply

    Scott Anderson
    Participant

    I tried but it doesn’t work! What do you mean with “root level of EAR”?
    I put my common.jar at level before META-INF directory

    That’s what I mean. When you do this, you should notice that the jar file now gets deployed when the EAR is deployed. Are you saying that this isn’t the case? I’ve just retested it here and when I use the Navigator view to copy a jar from another project and paste it into my EAR project, that library then becomes part of each deployment when they redeployed.

    #208318 Reply

    pumaxx
    Member

    @support-scott wrote:

    I tried but it doesn’t work! What do you mean with “root level of EAR”?
    I put my common.jar at level before META-INF directory

    That’s what I mean. When you do this, you should notice that the jar file now gets deployed when the EAR is deployed. Are you saying that this isn’t the case? I’ve just retested it here and when I use the Navigator view to copy a jar from another project and paste it into my EAR project, that library then becomes part of each deployment when they redeployed.

    Ok I tried to create before a Project structure with common.jar and then when I create a J2EE EAR project it see the included Jar.
    Now I want to reproduce the same behaviour with EJB building.
    If I want to deploy EJB and WAR separately, and EJB uses common.jar, where I have to put this jar in order to see it in final ejb.jar file?

    #208324 Reply

    Scott Anderson
    Participant

    If I want to deploy EJB and WAR separately, and EJB uses common.jar, where I have to put this jar in order to see it in final ejb.jar file?

    You need to place it somewhere under your source folder. For example, placing it at the top level of your source folder and will be placed at the top level of the resulting ejb jar file.

    #208352 Reply

    pumaxx
    Member

    @support-scott wrote:

    If I want to deploy EJB and WAR separately, and EJB uses common.jar, where I have to put this jar in order to see it in final ejb.jar file?

    You need to place it somewhere under your source folder. For example, placing it at the top level of your source folder and will be placed at the top level of the resulting ejb jar file.

    I tried this way…but it still doesn’t work!
    Finally, I built an EAR (EJB + common.jar) and a WAR…
    In WAR properties I choose to build all dependent projects into jars and include them into WEB-INF/lib folder: this works fine with Common project, not with EJB project (I need to manually JAR EJB and copy into WAR’s WEB-INF/lib before deploy…)
    Is there a way to copy automatically the EJB.jar into WEB-INF/lib folder of WAR?

    thanx

    #208401 Reply

    Scott Anderson
    Participant

    I tried this way…but it still doesn’t work!

    I take that to mean that it doesn’t do what you want, rather than it doesn’t deploy as I said it would since you then say:

    Finally, I built an EAR (EJB + common.jar) and a WAR…

    Is there a way to copy automatically the EJB.jar into WEB-INF/lib folder of WAR?

    There shouldn’t be any need to do this since you’re using an EAR. The WAR’s classloader will have access to all the classes within the EJB jar because that’s the hierarchy that the EAR classloader sets up. What exactly does your deployment (not project structure) look like now and what are you trying to do, specifically, that doesn’t work? Since you’re using a common jar file, I have a feeling it comes down to not having proper Class-Path entries in your MANIFEST.MF files.

Viewing 9 posts - 1 through 9 (of 9 total)
Reply To: EJB and JARs

You must be logged in to post in the forum log in