facebook

Resources not being included in the classpath

💡
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 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #230737 Reply

    mpilquist
    Member

    I have a project structure like this:
    src
    –main
    —-java
    —-resources
    —-webapp
    ——–WEB-INF

    I have my web root set to the src/main/webapp directory. The problem I’m running into is that any resources in src/main/java or src/main/resources are not getting deployed to WEB-INF/classes like I’d expect. Both src/main/java and src/main/resources are configured as source folders in the project.

    As an example, consider log4j.properties. This should be stored under src/main/resources. This project structure is the “best practice” project structure according to the Maven folks.

    I am using the Eclipse M7 release, BTW. Any ideas?

    #230750

    Riyad Kalla
    Member

    Pop open your project properties, go to Java Build Path and make sure you don’t have “use multiple output dirs” Selected AND that you have “/src/webapp/WEB-INF/classes” set as your output dir. Also check your Project menu and make sure “Build Automatically” is selected.

    The behavior you expect to happen is the correct behavior, so there has to be some flaky setting somewhere.

    #230765

    mpilquist
    Member

    Thanks for responding so quickly.

    The output directory was set to target/projectname/classes instead of src/main/webapp/WEB-INF/classes. I modified my maven configuration and everything is working great now.

    One side question: Is there any way to have MyEclipse deploy in a different directory? Basically, I want to do all editing in src/main/* but on an Eclipse build, things should get moved to a separate directory. The Eclipse WebTools Project does this in the .deployables directory. Is there any way to configure MyEclipse to do something similary?

    #230769

    Riyad Kalla
    Member

    Is there any way to have MyEclipse deploy in a different directory?

    When creating a deployment, hit the dropdown and select “Custom Location”.

    Basically, I want to do all editing in src/main/* but on an Eclipse build, things should get moved to a separate directory.

    I don’t follow…

    #230779

    mpilquist
    Member

    What I was trying to get at is the following:

    If the Eclipse output directory is set to src/main/webapp/WEB-INF/classes, developers might accidentally check in the contents of that directory when adding a project to source control.

    I was hoping there was a way to merge src/main/webapp with the built artifacts from src/main/java and src/main/resources…

    So the flow of the build might look something like this:

    1) Copy src/main/webapp to target/webapp
    2) Build from each source directory and store build artifacts (.class and resource files) in target/webapp/WEB-INF/classes
    3) Copy dependent libraries into target/webapp/WEB-INF/lib
    4) Deploy target/webapp to each configured deployment

    As an alternative, I guess I could set up the CM tool to ignore the WEB-INF/classes directory.

    #230782

    Riyad Kalla
    Member

    Ahh, no there is no fine grained control of building projects *yet*, for the time being please ignore the classes dir from your SCM.

    #230787

    mpilquist
    Member

    Will do. Thanks again for the help.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Resources not being included in the classpath

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