Maven does not include resources files - eclipse

Maven does not include resources files in the generated war file (I went inside webapps in tomcat, WEB-INB/classes/... that I have in /src/main/resources/ I generate the war using Eclipse neon, The application is an Spring application 3.0.5.RELEASE. I deploy the app in a tomcat server version 7
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.codenvy.examples</groupId>
<artifactId>BikesApp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>SpringDemo</name>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

Related

Error opening a class in Eclipse Version: 2018-09 (4.9.0) inside a maven module

I have a maven project containing several modules. This is part of the pom.xml file:
<?xml version="1.0"?>
<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">
<parent>
<groupId>com.tdk.booking.codemap</groupId>
<artifactId>tdkmap-maven-parent</artifactId>
<version>3.2.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.tdk.booking.tdk</groupId>
<artifactId>tdks</artifactId>
<version>3.6.0-RC1</version>
<packaging>pom</packaging>
<name>tdk Services</name>
<description>Document, File and Meeting Services</description>
<modules>
<module>tdk-services</module>
<module>tdk-audit</module>
<module>tdk-procedure</module>
<module>tdk-persistence-model</module>
<module>tdk-common</module>
<module>tdk-war</module>
</modules>
<dependencyManagement>
<dependencies>
<!-- Spring BOM -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>${spring.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- Quartz framework -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>${quartz.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- LOG4J2 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.7</version>
</dependency>
.....
</dependencies>
</project>
When I am on Eclipse and I try to open a class using F3 that is inside of one of the modules, like tdk-services, I got the error
Problems opening an editor.
Reason:
tdk-services does not exist
Import all the modules as independent projects: File - Import - Existing Project into Workspace and select the child project. Navigate using F3 or Ctrl - click.

Maven run tests specified in my Eclipse Folder(Path- src/test/java/pakage) but Test Results are not shown correctly

I have a Maven Project in eclipse. On running pom.xml file it runs my 2 tests mentioned on path- src/test/java/pakage.
But,When I check the test results in index.html file in the test-output folder - it shows only 1 test that too method name and class name is not correct.
Also in the info section of htlml file, location is little weird- shows like this -C:\Users..\AppData\Local\Temp\testng-eclipse--1598554117\testng-customsuite.xml (I am expecting my Project location which is- d drive).
Not sure what is going wrong.can somebody plz help.
My pom.xml is like this-
<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>Maven_demo</groupId>
<artifactId>Maven_Project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<name>Maven_Project</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
my Project structure is like this- img attached --https://i.stack.imgur.com/1FqDe.jpg

My Maven Dependencies are ClassNotFound Exception or NoClassDefFoundError

Here again (I had to rewrite it to make it more comprehensive i guess):
I got project X and project Y. They are independant from each other. While project X is working with all hibernate dependencies, I get ClassNotFound Exceptions and NoClassDefFoundErrors on project Y with the same dependencies. The errors occur, because the hibernate jars seem not to be deployed on project Y. I have to put them jar by jar in the WEB-INF/lib folder that they get deployed for runtime, while in project X they are already deployed via dependencies. The difference: Project Y has a parent project.
Here the pom.xml s:
Working Project X:
<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>org.hibernate.tutorials</groupId>
<artifactId>hibernate-tutorial</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>First Hibernate Tutorial</name>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.3.Final</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>6.0.35</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</project>
Project Y:
<?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>com-project</artifactId>
<groupId>com.project</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.project.core</groupId>
<artifactId>com-project-core</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>com-project-core Jersey Webapp</name>
<dependencies>
<dependency>
<groupId>com.project.facade</groupId>
<artifactId>com-project-facade</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.3.Final</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>6.0.35</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
</dependencies>
</project>
Project Y parent pom:
<?xml version="1.0" encoding="UTF-8"?>
<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.project</groupId>
<artifactId>com-project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>com-project</name>
<url>http://maven.apache.org</url>
<modules>
<module>com-project-core</module>
<module>com-project-client</module>
<module>com-project-facade</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
I already tried this attempt, but its all set.

Building maven project in Bamboo gives me an empty jar

I'm working with Eclipse, Maven 2.0 and Bamboo. I checked out a project from GitHub and debugged it in Eclipse. I had it ready and when I exported the JAR from Eclipse I got a 76KB JAR (which is correct), but when I make Bamboo use a plan to build the same JAR using a maven pom.xml file, Bamboo gives me a 1KB JAR saying there's nothing to compile.
What am I missing? Here's my pom.xml file:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Lib</groupId>
<artifactId>Lib</artifactId>
<name>Lib</name>
<version>1.0.0-SNAPSHOT</version>
<description>Lib</description>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0-beta2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-email</groupId>
<artifactId>commons-email</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
</project>

gwt-servlet.jar missing in the WEB-INF/lib on compiling GWT with maven

In my pom file, I have included the dependency of gwt-servlet but if i run mvn clean install and mvn eclipse:eclipse and open the project in eclipse, I get the following error
GWT SDK JAR gwt-servlet.jar is missing in the WEB-INF/lib directory
EDIT :
Here is my dependency (we use a custom maven repository):
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smart-gwt</artifactId>
<version>2.5</version>
</dependency>
EDIT 2 (main pom):
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
....
There are two things I noticed.
1) The smartgw dependency you specified cannot be resolved from the maven central repository
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smart-gwt</artifactId>
<version>2.5</version>
</dependency>
It only has the 2.4 version of smartgw (see here http://search.maven.org/#search%7Cga%7C1%7Csmartgwt) Instead I had to use this
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>2.4</version>
</dependency>
notice that the artifact ID is different too. (If you have a custom repository containing this then please update your question)
2) You dont need to do eclipse:eclipse instead you can issue the
File > Import > Existing Maven projects
this will auto generate the eclipse project from your pom.xml
UPDATE
I tested with the following :
Parent pom in gwttest2 folder
<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.test</groupId>
<artifactId>gwttest2-main</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>gwttest2-module1</module>
</modules>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
</build>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
child pom in gwttest2/gwttest2-module1 folder
<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.test</groupId>
<artifactId>gwttest2-module1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<artifactId>gwttest2-main</artifactId>
<groupId>com.test</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
</extension>
</extensions>
</build>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
</project>
Tell Eclipse to use Maven dependencies by right-clicking on your Project folder and selecting
Configure > Convert to Maven Project.
It seems that even after running mvn eclipse:eclipse, you must do this manually to get Eclipse to actually let Maven take care of your dependencies.
If you don't see this option you may not have the M2Eclipse plugin installed in your Eclipse...