Maven, eclispse and wtp broke for no reason: he stopped putting mvn decentent jars in WEB-INF / lib

I have been running eclipse (Helios Build id: 20100617-1415), sonotype maven for eclipse version 2 (0.1.0.20100xxx) for many months without any problems.

I can do "mvn install" on the command line and get a great war, and I could run webapp in local tomcat eclipse without any problems.

Then this morning I began to stomp in the eclipse, got into the servlet and got many classes that were not found. Looking where eclipse puts libs in webapp.metadata.plugins \ org.eclipse.wst.server.core \ tmp1 \ wtpwebapps \ ge-api \ WEB-INF \ lib, I don't see any of the standard dependent libraries (e.g. log4j )

I did my usual mvn mantra :

  • close elcipse
  • go to the root of the parent project
  • mvn clean
  • mvn install
  • mvn elcipse: eclipse
  • restart eclipse
  • update all projects starting with the parent.

It did not help.

I tried using every available m2eclipse parameter - nothing helped.

So, I tried tomcat mantra :

  • open eclipse
  • go to server tab
  • remove webapp
  • window-> preferences-> server-> runtime
  • remove tomcat 6
  • restart eclipse
  • add tomcat 6 again.
  • add webapp again.
  • restart tomcat server in eclipse

This led to the same problem: maven and elcipse hate each other and refuse to speak. And I have not changed a single thing, not even the comment line, between which it works, and it does not work.

- . . - - maven.

look, all the jars are put in the class path by maven

" ", , :

alt text

, ( - ). ok, :

alt text

tomcat , . Webapp, , , .

10 - :

pathpath M2_REPO/aopalliance/aopalliance/1.0/aopalliance-1.0.jar . Runtime ClassNotFoundExceptions . ge-api P/ge-api Pathpath

?

, , ,

" J2EE" ( JAR WEB-INF/lib, EAR, Manifest, "

" J2EE" .

/:

alt text

, J2EE .

, " " .

" /".

, ? Anway, 10 4- , , pom (, 40 ), 2) :

  • ​​ "publish/export dependecy" "" Java Build:

alt text

, .

  1. :

" path M2_REPO/log4j/log4j/1.2.15/log4j-1.2.15.jar /, . Classpath Eclipse . ge-core P/ge-core "

maven ?

, , - , , : maven, pom , , . .

pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.skillkash.ge</groupId>
<artifactId>ge-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>ge-parent</name>
<modules>
 <module>ge-api</module>
 <module>ge-core</module>
 <module>ibo-core</module>
</modules>
<build>
<plugins>
  <plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <configuration>
    <source>1.6</source>
    <target>1.6</target>
   </configuration>
  </plugin>
 </plugins>
</build>
<dependencies>
<dependency>
 <groupId>log4j</groupId>
 <artifactId>log4j</artifactId>
 <version>1.2.15</version>
 <exclusions>
  <exclusion>
   <groupId>javax.jms</groupId>
   <artifactId>jms</artifactId>
  </exclusion>
  <exclusion>
   <groupId>com.sun.jdmk</groupId>
   <artifactId>jmxtools</artifactId>
  </exclusion>
  <exclusion>
   <groupId>com.sun.jmx</groupId>
   <artifactId>jmxri</artifactId>
   </exclusion>
  </exclusions>
 </dependency>
 <dependency>
  <groupId>org.testng</groupId>
  <artifactId>testng</artifactId>
  <version>5.12.1</version>
 </dependency>
</dependencies>
</project>

webapp pom:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
    <artifactId>ge-parent</artifactId>
    <groupId>com.skillkash.ge</groupId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.skillkash.ge</groupId>
<artifactId>ge-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>ge-api Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.4</version>
    <scope>provided</scope>
  </dependency>    
  <dependency>
   <groupId>com.skillkash.ge</groupId>
   <artifactId>ibo-core</artifactId>
    <version>0.0.1-SNAPSHOT</version>
   <scope>compile</scope>
  </dependency>
  <dependency>
   <groupId>com.skillkash.ge</groupId>
   <artifactId>ge-core</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   </dependency>
   </dependencies>
 <build>
    <finalName>ge-api</finalName>
</build>
</project>

heres eclipse:

alt text

- , , ?

+3
4

:

1) Eclipse: Eclipse. "" → " ". Eclipse.

2) , : Eclipse. Tomcat. . Eclipse ( Eclipse , , ( )). Tomcat: Tomcat / Eclipse, Tomcat. ; , , .

+1

:

  • eclipse:eclipse m2eclipse ( )
  • .eclipse, .classpath, .settings
  • reimport ... > Maven
  • -

, WTP Tomcat ( ).

+3

Whenever I find some problems with libraries, this is what I do and it works: (note: I don't use the maven eclipse plugin, which almost never works for me)

  • mvn dependency: allow
  • mvn eclipse: eclipse
  • Update the eclipse project.

    • Regards, Shoubhik
0
source

For me, this usually works if the Maven project is broken in Eclipse:

  • Right click on the project
  • → "Maven"
  • → "Refresh project ..."
  • → "Ok"
0
source

Source: https://habr.com/ru/post/1770430/


All Articles