5

I have a bizarre behavior with Eclipse when I try to import an existing maven project, it's a multi-module JEE maven project with a parent and sub-modules. The structure svn looks like this:

  • parent
    • ear
    • webapp1
    • webapp2
    • shared-library

When I import the project into Eclipse, it automatically create a "shared-libraryEAR" in the same directory of the "parent" project. It looks something like this after the import:

  • shared-libraryEAR
  • parent
    • ear
    • webapp1
    • webapp2
    • shared-library

It does this for every "jar" maven projects in the workspace. It's something normal ? I use Eclipse Oxygen.2 and Eclipse Neon.3 with WebSphere plugins and the default embedded maven.

I can reproduce the same behavior using the demo project in this Stackoverflow answer: Maven2: Best practice for Enterprise Project (EAR file)

After importing the project into Eclipse Oxygen, I have two new EAR project that did not exist in the original project structure. The structure in Eclipse Enterprise Explorer looks like this after the import:

  • myproject-application (original ear) ¸
  • myproject-business (original ejb)
  • myproject-common (original jar lib)
  • myproject-commonEAR (new EAR)
  • myproject-persistence (original jar lib)
  • myproject-persistenceEAR (new EAR)
  • myproject-web (original web module)
  • parent (original parent project)

Result in eclipse: Image capture of Eclipse Enterprise Explorer

After importing the projects, I usually just delete the unnecessary EAR projects, but it's kind of annoying, is there a solution?

Thanks.

Draconian
  • 53
  • 4

4 Answers4

0

Trying a fresh copy of eclipse (the same version) solved my problem regarding to this case. I guess, it happened because of a plugin on eclipse.

Murat
  • 370
  • 4
  • 3
  • Yeah, this is what I find out, it's the Websphere 7 plugin who does this. On a fresh eclipse install with only the Websphere 8 plugins installed, I don't have this behavior. – Draconian Dec 14 '18 at 13:52
0

I had a similar experience and ran across https://wiki.eclipse.org/M2E-WTP/New_and_Noteworthy/1.1.0 .

m2e-wtp can also be disabled via the m2e.wtp.activation>false in the Maven section of your project pom;xml.

I create a new workspace and cloned a fresh copy of my code in a temp directory. I then updated the parent pom.xml with the following:

    <properties>
        <m2e.wtp.activation>false</m2e.wtp.activation>
        <m2e.jaxrs.activation>false</m2e.jaxrs.activation>
        <m2e.jpa.activation>false</m2e.jpa.activation>
        <m2e.jsf.activation>false</m2e.jsf.activation>
        <m2e.cdi.activation>true</m2e.cdi.activation>
    </properties>

I then imported Existing Maven Projects and no extra EAR projects.

Paul Bastide
  • 1,505
  • 4
  • 17
  • 22
  • 1
    Unfortunately, this prevents m2e from turning the project into a faceted web project (WTP) and then it doesn't work well with Eclipse JEE tooling. – lmsurprenant Oct 02 '19 at 18:09
0

This ill behaviour is the result of having IBM's WebSphere plugins for Eclipse.

Removing these plugins from Eclipse, or starting with a fresh Eclipse install (like the accepted answer suggests), is not sufficient.

You will also need to create a new Eclipse workspace.

I haven't got the time yet to figure out why, but that's the only thing that worked for me.

Isaac
  • 16,458
  • 5
  • 57
  • 81
0

Preferences>Java EE>Project>Enterprise Application Membership>Add project to an EAR

uncheck that checkbox to avoid the creation of EAR projects.

Alejandro
  • 21
  • 3