facebook

[Closed] Setup for complex EAR deployment

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #260045 Reply

    David
    Member

    I have inherited a J2EE project that uses EJB, JSP and Struts. I would like to import it into MyEclipse, but there are four issues:

    1> The project appears to be based upon JBoss 3.x and I would rather use JDK1.5, JBoss 4.0.2. I don’t forsee any unsurmountable issues here, but if anyone has any gotcha’s I would appreciate any warning you can offer.

    2> The directory structure is:
    project
    \ src
    \ lib
    \ webapps\App1 (one project that is customer facing)
    \ webapps \App2 ( the admin piece of the application)

    It looks like MyEclipse wants me to have all webapps under WebRoot. If so, is that going to work?

    3> Since the project has a couple of EJB’s, I take it that I should use the “EJB Project” wizard? I looked at the online documentation and unfortunately it doesn’t really say what the differences is between EJB Project/ Enterprise Application Project | Web Projects (which I would think would be a struts/jsf approach?)

    4> If I have Tomcat on the front end handling the JSP/Struts and Tomcat handling the EJB – can MyEclipse support this?

    I know this is a lot, but Ihave been trying to put all these pieces together and could really use any advice you can offer.

    #260168

    Riyad Kalla
    Member

    1) Can’t think of any off the top of my head.

    2) MyEclipse actually wants each app to be a project. So if App1 and App2 are completely stand alone web applications that use common code and classes from /src and /lib, your setup should look like:
    App1 (Web Project, has ref to Common)
    App2 (Web Project, has ref to Common)
    Common (Java Project, contains /src and /lib, exports all of /lib)

    3) It’s confusing, here’s the layout:

    
    + Enterprise Application Project (EAR - It's a sort of Meta-project that acts like an umbrella over it's modules)
      + EJB Project (Standalone or module of an EAR, contains 1 or more EJBs)
      + Web Project (Standalone or module of an EAR, contains 1 web application)
        + Java Project (Standalone or dependency of EAR/EJB/Web, contains common files and libraries)
    

    4) Tomcat cannot host EJBs, it’s only a servlet container (unless you mis-typed something and meant JBoss?). In which case yes you can just deploy each individual project all over the place. The normal way to do this is to create a single EAR and deploy that to JBoss, but if you really want to manually deploy them all separately that’s fine.

    Let me know if things are still fuzzy, it’s a lot to digest I know.

    #260207

    David
    Member

    Thank you for the explanation. They do have a common source code base but because one is for one set of users (customers) and the other is for another (admin) they have different contexts. Because they are one base, I thought I would keep them in a single Ear file. It does appear that JBoss 4.02 bundles with Tomcat 5.5, so I could put them all in the server/deploy directory right? then it is a matter of configuring the internal Webserver to pass the requests within JBoss (is that the right way to say that). If I use the single EAR, will that contain all the jsp’s under each WEB-INF and related classes?

    In that case, do I still need a “common” Enterprise Application, a EJB project, and a Web Project that all reference each other as dependencies? Perhaps it would be better if I could find an example of how to create a struts project that uses EJBs with JBoss 4.0.2.

    Sorry, I feel like I am not explaining it very well.

    #260211

    Riyad Kalla
    Member

    Hmm… I’ll be honest I’m a little confused. JBoss is an full J2EE compliant app server. So typically you just deploy an EAR to a JEE server like that and are done with it (your ear contains everything, all web ‘modules’ (actually applies), all EJB modules and all common libraries. So what’s confusing me is the whole breaking-the-app-into-pieces-and-deploying-it question… it could be a valid point, I just don’t know why you are doing it.

    I don’t think I’m helping much… maybe if you explain your use-case, leaving out all the technical stuff, we can figure out a good setup/deployment routine that makes sense for what you guys are trying to tackle.

    #260230

    David
    Member

    I actually feel like we are making progress – so you must be helping out! My original question was because I didn’t know how to break a single project into projects that would get deployed into Tomcat AND JBoss from a single codebase. But now that I know I can build my project and deploy it to only JBoss that makes things much simpler (assuming I can actually figure out how to configure JBoss to do this).

    That leaves me with the basic question – do I use MyEclipse to do a Web Project or an EJBProject? Here is my source tree:

    Project
    – src
    – properties
    – webapps

      AppOne
      —-css
      —- jsp’s (index.jsp etc)
      —- WEB-INF
      ——struts-config.xml
      AppTwo
      —-css
      —- jsp’s (index.jsp etc)
      —- WEB-INF
      ——struts-config.xml

    I think that this means I can deploy all to JBoss and just use two contexts right? Both AppOne and AppTwo have their own JSP’ struts-config. If all these are built and deployed via a single EAR file, will JBoss be able to use seperate context to show both apps?

    #260243

    Riyad Kalla
    Member

    Good deal, I like progress.

    So the setup you’ll want in MyEclipse is:

    
    + Enterprise Application Project (Deploying this creates an EAR)
       - Under project properties, have it reference your Common project
       - Setup deployment rules for your Common project to place it in the root of the EAR
    
       + AppOne (Web Project, Module of Enterprise Application Project)
          - Don't forget to add Struts capabilities to this
    
       + AppTwo (Web Project, Module of Enterprise Application Project)
          - Don't forget to add Struts capabilities to this
    
    
       + EJB Project (EJB Project, Module of Enterprise Application Project, contains your EJBs)
    
       + Common (Java Project, Referenced by other projects, deployed to root of EAR)
          - Contains common classes everyone needs
    

    Then you just deploy the top level umbrella Enterprise Project to JBoss and bamo, a huge “EAR” file gets written out, JBoss says “thanks” and loads the entire thing up. Then you can access localhost:8080/AppOne, /AppTwo and what not. No need to setup anything (unless you are using Data sources, then you need to set that and other app-server specific stuff up).

    Honestly I would suggest that you take maybe 15mins and run through our enterprise tutorial here just to get a feel for where stuff falls:
    http://www.myeclipseide.com/images/tutorials/quickstarts/earprojects/

    UPDATE
    Ok so this is actually a pretty complex setup as far as setups go, so I created an example configuration of exactly this setup here for you to download. You can go ahead and download it and import all the projects into MyEclipse. You’ll notice that one of the more subtle parts here is that I setup each project (EJB, Web1 and Web2) to all use the Common Java project *BUT* you need to tell each of them to “ignore” it when deploying themselves, otherwise each one will try and package it up. Then at the top level, in the EAR, you tell the EAR to package it up and deploy it.

    The project I provided is meant as a guide, notice that I added Struts 1.1 capabilities to the two web projects just to make it more realistic. I hope that helps.

    #260306

    David
    Member

    Thank you – that was far too generous of you! I am importing it now and will start messing around to see how it works. I think the Struts1.1 addition is perfect, since my app uses that as well.

    #260824

    David
    Member

    Do I need to put the EJB code under the EJB project? Currently it is just under /src and I wasn’t sure if I had to seperate it from the common code.

    Also, if I am developing on my Mac laptop, and want to deploy this to my Linux server, is that something that myEclipse will handle? Or, will I have to duplicate the project on that box and then copy the source code, build and deploy there as well?

    #260829

    David
    Member

    Quick update, I got all the code broken into seperate projects (webapp’s, ejb, common) and I think they are correct. I have almost all the code in the common project, except for the EJB’s where are in the ejb project. Unfortunately, the only errors left are the circular dependencies where the EJB reference the common and vice versa. It looks like they all need each other to build, and this is causing problems.

    When this sucker does build, I am taking it that I will select the default (originally ExampleEAR) and it will build an EAR file to be deployed to jboss/server/default?

    #260857

    David
    Member

    Another quick question – my EJB’s do NOT use XDoclet and it appears the EJB in your example does. Since I already have a deployment descriptor – do I need to change my EJB’s to use XDoclet?

    #260858

    Riyad Kalla
    Member

    Hmm you shouldn’t have circular dependencies from your Common project to your EJB project, if you do, those classes should find their way into your EJB project. The only reaso to break out the common project is incase other projects need that code as well (like a web project). Then you have a water-fall style of dependencies.

    And yes, to build the EAR, you simply deploy the top level EAR project, it will package everything up nicely and neatly.

    #260859

    David
    Member

    Hmm, last message didn’t post – sorry if this duplicates.

    -> If I have code used by both EJB and common (struts) then it should be in the EJB project?
    -> Are there major changes for deployment descriptors, server.xml, both struts-config.xml files between previous JBoss versions and this? I am wondering if it used to get deployed to JBoss AND Tomcat, will just deploying to JBoss now still work as defined? I guess I can worry about that once this thing gets deployed and running

    #260863

    Riyad Kalla
    Member

    -> If I have code used by both EJB and common (struts) then it should be in the EJB project?

    If the EJB uses common, and common uses EJB, I believe whatever portion of Common that is using the EJB, should just be moved up into the EJB. So EJB uses common, and then there are nor circual references back up from common to EJB.

    Do you have a situation where common uses EJB and Web or something like that? You might consider re-architecting some of those connections… I can’t tell from the information given if this is just organizational (fixed by moving classes into other projcets) or if this is part of the design (actual implementation).

    -> Are there major changes for deployment descriptors, server.xml, both struts-config.xml files between previous JBoss versions and this? I am wondering if it used to get deployed to JBoss AND Tomcat, will just deploying to JBoss now still work as defined? I guess I can worry about that once this thing gets deployed and running

    No you shouldn’t need to change these. Newer versions of app servers are always backward compatible.

    #260873

    David
    Member

    Here is an example of what I am talking about:

    in common there is a class that is used by the Struts application (in WebApp1) that references an EJB. So I need that class in common so the struts can get to it. But I have several files that are

    So, I have:
    action -> common -> ejb -> common (constants and such)

    So, does that mean I should have all the files in common and no source code in the ejb project? I don’t see a way to refactor so that there is a constant.java used across all projects and not have circular references.

    #260875

    David
    Member

    Ok, so I cheated and allowed the compiler to just ignore circular dependencies. After all the libraries were added, I was able to create a deploy and launch JBoss. I am getting lots of errors like it can’t find files such as the struts.tld etc. I changed the application.xml to create the war and jar files I want them, but it keeps creating them as the project name:

    <application xmlns=”http://java.sun.com/xml/ns/j2ee&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; version=”1.4″ xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd”&gt;
    <display-name>cyob</display-name>
    <module id=”myeclipse.1160575771265″>
    <web>
    <web-uri>web.war</web-uri> < — this becomes cyob_web.war
    <context-root>/</context-root>
    </web>
    </module>
    <module id=”myeclipse.1160575787953″>
    <web>
    <web-uri>admin.war</web-uri> <– this becomes cyob_admin.war
    <context-root>/admin</context-root>
    </web>
    </module>
    <module id=”myeclipse.1160575771312″>
    <ejb>cyob_ejb.jar</ejb> <– this actually gets created
    </module>
    </application>

    So, perhaps if I can get these war files created properly that will be a good step. Where is that set at?

Viewing 15 posts - 1 through 15 (of 16 total)
Reply To: [Closed] Setup for complex EAR deployment

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