Single ear file for multi projects

ZeroTurnaround Homepage Forums JRebel Support Single ear file for multi projects

This topic contains 12 replies, has 3 voices, and was last updated by  Amar A 4 months, 1 week ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #14674

    khushwinder
    Participant

    Hi there,

    I am planning to introduce the JRebel in my company. So i am preparing the POC for that to present it to my mgt.

    However, i stuck with a problem.

    In our product, we have multiple java projects with one web project. I created rebel.xml file in each of these projects(with the option of create rebel.xml in source in some projects while generate rebel.xml directly in some projects if they don’t have specific src directory(<classpathentry kind=”src” path=””/>)).

    But all of these projects are deployed in a single .ear file. In that .ear file all the source classes from all the projects are compiled into classes folder.

    My question is, how the how single ear file will accommodate the rebel.xml from all the projects? They will be overwrite or how jrebel will handle them?

    Thanks.

    #20970

    Anton Arhipov
    Rebel Staff

    Could you please sketch the structure of the project and the structure of the final EAR?

    #20971

    khushwinder
    Participant

    The ear file structure is same as of a normal ear file. It contains a war file and war file contains the directory structure of a web app application.

    Ear file contains dependency of web project and web project further has dependency of a main java project and this main java project has further dependency on two other java projects. In this way, ear file contains class files from all the projects as they are inter dependent on each other. Please let me know if any other thing required.

    I do have a picture for this but not able to attach that…

    #20972

    Anton Arhipov
    Rebel Staff

    So, if deploy the packaged archive, the package looks like this:


    my.ear
    |- my.war
    | |- classes/
    | | `- rebel.xml //points to the resources in web project
    | `- lib/
    | |- lib1.jar
    | | `- rebel.xml //points to the resources in lib1 project
    | |- lib2.jar
    | `- rebel.xml //points to the resources in lib2 project
    `- ejb-jar.jar
    `- rebel.xml //points to the resources in EJB project

    The problem is that if you have the Eclipse project, and deploy the app from WTP, for instance, in exploded mode, then it will copy all the classes are resources to a single directory and overwrite the rebel.xml files from different modules so only one gets deployed and that is what may cause some problems with loading the classes from the mapped locations.

    I’ve described this problem in case of multi-module project setup in IntelliJ, but it actually works in the same way in eclipse also.

    Other option is if you have a maven project, then the deployed artifact is always packaged and you do not have a problem at all.

    #20973

    khushwinder
    Participant

    Hi Anton,

    After going though the link , I am modifying my rebel.xml in the web project like following:

    <?xml version=”1.0″ encoding=”UTF-8″?>

    <application xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns=”http://www.zeroturnaround.com” xsi:schemaLocation=”http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd“>

    <classpath>

    <dir name=”D:workspace-WAS77.3.1jspsWeb ContentWEB-INFclasses”>

    </dir>

    <dir name=”D:/workspace-WAS7/7.3.1/Domain/bin”>

    </dir>

    <dir name=”D:/workspace-WAS7/7.3.1/Manager/bin”>

    </dir>

    <dir name=”D:/workspace-WAS7/7.3.1/depedent/bin”>

    </dir>

    </classpath>

    </application>

    Now after deploying, in my ear file this rebel.xml comes and has the reference to all the projects. Please verify if i am doing it correctly ?

    Thanks

    #20974

    Anton Arhipov
    Rebel Staff

    It doesn’t seem to be correct. Most likely, “Domain”, “Manager” and “dependent” are the different modules in your app which are packages as JARs, right?

    In that case, the jars should have their own dedicated rebel.xml configs as described in the example above.

    But in case all the classes are in the same package, well, then it is fine to have a configuration like yours.

    #20975

    khushwinder
    Participant

    No Anton, we don’t have jars of the different modules , their classes directly go to the ear file.

    In this case, will my configuration work?

    Can i also manage my jsps/xsl(use for UI purpose) files through jrebel?

    #20976

    Anton Arhipov
    Rebel Staff

    If all your classes end up in WEB-INF/classes of the WAR that is packaged into EAR, then it is fine to use rebel.xml like yours.

    For static resources you need <web/> element in rebel.xml, as described in docs: http://manuals.zeroturnaround.com/jrebel-reference-manual/app.html#app-3.1

    #20977

    khushwinder
    Participant

    Actually in our project we are using XSL/XML for UI purpose. Is there any way we can also change at run time using the jrebel? If yes could you please provide any example.

    Thanks.

    #20978

    Anton Arhipov
    Rebel Staff

    The static resources are automatically served from the correct location. So you only need to map the directory with rebel.xml pointing to the location where the XML/XSL resources are.

    If you do now cache the files in your application, then it should just work out of the box. If you do cache the files, then you probably just need to disable the caches for development time.

    #20979

    khushwinder
    Participant

    As per your reply

    “So you only need to map the directory with rebel.xml pointing to the location where the XML/XSL resources are.”

    could u plz elaborate it how can i map the directory in rebel.xml? if u can write a line or two it will be very beneficial.

    #20980

    Anton Arhipov
    Rebel Staff

    Here’s the example (see “Configuring WARs”): http://manuals.zeroturnaround.com/jrebel-reference-manual/app.html#app-3.1

    <classpath>
    <dir name="/where/your/compiled/classes/are"/>
    </classpath>

    <web>
    <link target="/">
    <dir name="/where/your/xml/files/are"/>
    </link>
    </web>

    So in the _web_ element you define the url path via _link_ element, and inside _link_ youspecify the _dir_ element that points to the directory where the resources are.

    if you have a web project, and generate the configuration file using IDE plugin (or maven plugin), then this part should pretty much be generated automatically for the web content folder.

    #64052

    Amar A
    Member

    Hi Anton,

    I have a similar situation but my project is containing a ear with multiple jars and war. for war jrebel is working good. but I have some XSL and properties files in a jar file. I am having trouble when changing xsl files or properties files in jar, jrebel doesnt pick up the changed files but java file change is working. please help.
    JRebel version: 7.0.5 and using JBossDeveloperStudio.

    your solution is much appreciated, Thanks!

    my rebel.xml for the jar is as below:

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <application xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns=”http://www.zeroturnaround.com” xsi:schemaLocation=”http://www.zeroturnaround.com http://www.zeroturnaround.com/alderaan/rebel-2_0.xsd“>

    <classpath>
    <dir name=”workspacepath/classes”>
    </dir>
    </classpath>

    </application>

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.