jakarta.servlet with Tomcat 9 - Not Found Issue - eclipse

I have a application which I am running using eclipse and tomcat 9 server.
When I run the application, its opens then index.html page in browser, but the API's called inside index page are erroring with 404 status.
I tried multiple things from various stackoverflow page but nothing seems to work.
I have a Httpservlet with following declaration
#WebServlet("/api/modules")
public class ModuleController extends HttpServlet {
#Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
// logic
}
}
Even if I directly try to hit localhost:8080/application-context/api/modules
I get the same 404 error.
Also my application doesn't have a web.xml.
Note: The application is working fine on other people's system.
Following is the pom.xml for reference.
<?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>ch.bfh.ti</groupId>
<artifactId>academia-02</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<!-- General properties -->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Version properties -->
<servlet.version>5.0.0</servlet.version>
<jackson.version>2.13.1</jackson.version>
<postgresql.version>42.3.2</postgresql.version>
<jetty.version>11.0.8</jetty.version>
<h2.version>2.1.210</h2.version>
<junit.version>5.8.2</junit.version>
<rest-assured.version>4.5.0</rest-assured.version>
<!-- Checkstyle properties -->
<checkstyle.config.location>src/etc/checkstyle.xml</checkstyle.config.location>
<checkstyle.header.file>src/etc/checkstyle-header.txt</checkstyle.header.file>
</properties>
<dependencies>
<!-- Servlet dependencies -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- Database dependency -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.10</artifactId>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-annotations</artifactId>
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.11.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>site</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/target/site/images</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/site/markdown/images</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>
404 error reference:
HTTP Status 404 – Not Found
Type Status Report
Message The requested resource [/academia-02/api/modules] is not available
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Also I have already tried the following:
Changing tomcat version
adding a web.xml
clean build the application and then run on tomcat
checked that generated classes contains the Servlet class in proper location
Update tomcat properties -> Switch location
Update tomcat properties -> user tomcat installation in server location
Can you please let me know what can be done here ?

You're declaring a dependency on Servlet Spec 5.0 (and explicitly state that you're using a Jakarta servlet).
Thus, it's mandatory that you're using Tomcat 10. Works as declared/designed. Not an issue.

Related

Unable to generate session beans for entity classes because EJB Lite classes are not available on project classpath

The image shows the persistence.xml configuration and
the popup window where I try to create the new session beans.
My setup is
Netbeans 12.6
Jakarta ee9
JDK 17
Glassfish 6.2.1
I have tried to reinstall netbeans, reinstall the server tried to create a new project using ant build script adding the persitence libs manually but I am still getting the same error.
The pom.xml
<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.techbay</groupId>
<artifactId>Techbay</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Techbay-1.0-SNAPSHOT</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<jakartaee>9.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.1.0-RC2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I was finally able to solve this problem by adding to my POM
<dependency>
<groupId>org.glassfish.main.packager</groupId>
<artifactId>glassfish-ejb-lite</artifactId>
<version>5.0</version>
</dependency>
Then I realized that glassfish-ejb-lite-5.0.jar is not available in maven repository so I manually downloaded the source jar glassfish-ejb-lite-5.0-sources.jar from the net and manually added it to my local repository.
This solved the problem for now till the glassfish-ejb-lite.5.0 is officially available in maven central.
I hope this helps somebody with a similar problem.

Jersey REST API returning 404 not found deployed in tomcat

I have developed REST API through JAX-RS Jersey in Eclipse.
In Eclipse,i have configured Tomcat 8.0.21 server.
In Eclipse, i do Run As -> Run on Server, Tomcat Server runs successfully, and i able to hit the end points and getting proper response.
So far so good.
Next step,
Using Eclipse, i did export the project as WAR File.
Unzipped the Tomcat server to a directory in windows
Copied the WAR file in webapps directory
Copied the necessary jars to lib folder
Below are jars i copied to lib folder
jersey-container-servlet-core-2.23.1.
jar jersey-server-2.23.1.jar
java-client-2.3.1.jar
jersey-media-moxy-2.23.1.jar
gson-2.7.jar
Clicked on startup.bat in bin.
I can see - my war is deployed successfully and
server is running successfully.
However, when i try hit the same endpoint, i get 404 not found.
Please help, What Am i missing
This is how my pom.xml looks
<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>ecom.subhash</groupId>
<artifactId>couchdb</artifactId>
<packaging>war</packaging>
<version>0.0.2-SNAPSHOT</version>
<name>couchdb</name>
<build>
<finalName>couchdb</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>ecom.subhash.couchdb.resource.App</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>java-client</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.2.3.v20140905</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.2.3.v20140905</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.23.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-http</artifactId>
</dependency>
</dependencies>
<properties>
<jersey.version>2.23.1</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Maven does not include the web content anymore after converting Dynamic Web Project

I created a dynamic web application then converted it to maven project.
When I try to deploy it using with maven build, It creates the war file and others(META-INF, WEB-INF) but Maven doesn't deploy the xhtml files and the web.xml file which are under the WEB-INF folder.
I can manually copy the xhtml files to target(tomcat/webapps) and it works.. but when i copy the web.xml file manually, the web application crashes.
this is 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>my_group_ıd</groupId>
<artifactId>my_artifact_id</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>My_Webapp_name</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<!-- Faces Implementation -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.4</version>
</dependency>
<!-- Faces Library -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.4</version>
</dependency>
<!-- Primefaces Version 5 -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.1</version>
</dependency>
<!-- JSP Library -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- JSTL Library -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.23</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
<version>7.0.63</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>8.0.24</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<build>
<finalName>my_final_name</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>TomcatServer</server>
<username>username</username>
<password>password</password>
<path>/my_path</path>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>webapp</warSourceDirectory>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I have tried many things to deploy them automatically with maven. I couldn't be successful, so far..
I removed this plugin and changed various things in web.xml.. it works
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>webapp</warSourceDirectory>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
thanks everyone
I have converted web application to maven and added your plugin but jars are added into target folders web-inf/jars folder not in web-content folder.

GWTP Boilerplate Generation with Maven - build success inconsistency

I'm fairly new to Maven, but I'm using it because that's what the GWTP plugin gives when you create a new project. I have a few DTOs I'm creating using the #GenDto annotation. The following is my pom.xml file:
<?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.test</groupId>
<artifactId>MyProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>MyProject</name>
<properties>
<!-- client -->
<gwt.version>2.7.0</gwt.version>
<gwtp.version>1.5</gwtp.version>
<gin.version>2.1.2</gin.version>
<!-- server -->
<guice.version>3.0</guice.version>
<resteasy.version>3.0.13.Final</resteasy.version>
<jbcrypt.version>0.3m</jbcrypt.version>
<jax-rs.version>1.1.1</jax-rs.version>
<arcbees.version>1.2</arcbees.version>
<!-- testing -->
<junit.version>4.12</junit.version>
<jukito.version>1.4.1</jukito.version>
<!-- maven -->
<gwt-maven-plugin.version>2.7.0</gwt-maven-plugin.version>
<maven-surefire-plugin.version>2.17</maven-surefire-plugin.version>
<maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
<maven-war-plugin.version>2.5</maven-war-plugin.version>
<maven-resources-plugin.version>2.5</maven-resources-plugin.version>
<maven-processor-plugin.version>2.0.5</maven-processor-plugin.version>
<maven-build-helper-plugin.version>1.7</maven-build-helper-plugin.version>
<target.jdk>1.7</target.jdk>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
</properties>
<build>
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-processors</artifactId>
<version>${gwtp.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${target.jdk}</source>
<target>${target.jdk}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
<!-- JUnit Testing - skip *.GwtTest cases -->
<!-- 'mvn test' - runs the Jukito tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/*GwtTest.java</exclude>
</excludes>
</configuration>
</plugin>
<!-- GWT -->
<!-- 'mvn gwt:run' - runs development mode -->
<!-- 'mvn gwt:debug' - runs debug mode -->
<!-- 'mvn gwt:compile' - compiles gwt -->
<!-- 'mvn integration-test' - runs the gwt tests (*GwtTest.java) -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt-maven-plugin.version}</version>
<configuration>
<!-- With multiple tests use GwtTestSuite.java for speed -->
<includes>**/*GwtTest.java</includes>
<bindAddress>0.0.0.0</bindAddress>
<extraJvmArgs>-Xss1024K -Xmx1024M -XX:MaxPermSize=256M</extraJvmArgs>
<logLevel>TRACE</logLevel>
<copyWebapp>true</copyWebapp>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<runTarget>MyProject.jsp</runTarget>
<modules>
<module>com.test.MyProject</module>
</modules>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<!-- Google Web Toolkit -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
</dependency>
<!-- GWT-Platform -->
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-mvp-client</artifactId>
<version>${gwtp.version}</version>
</dependency>
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-dispatch-rpc-client</artifactId>
<version>${gwtp.version}</version>
</dependency>
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-dispatch-rpc-server-guice</artifactId>
<version>${gwtp.version}</version>
</dependency>
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-dispatch-rpc-shared</artifactId>
<version>${gwtp.version}</version>
</dependency>
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-dispatch-rest</artifactId>
<version>${gwtp.version}</version>
</dependency>
<dependency>
<groupId>com.gwtplatform.extensions</groupId>
<artifactId>dispatch-rest-delegates</artifactId>
<version>${gwtp.version}</version>
</dependency>
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-dispatch-rest-shared</artifactId>
<version>${gwtp.version}</version>
</dependency>
<dependency>
<groupId>com.gwtplatform</groupId>
<artifactId>gwtp-processors</artifactId>
<version>${gwtp.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.12.1.1</version>
</dependency>
<!-- DI -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${guice.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>${guice.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assistedinject</artifactId>
<version>${guice.version}</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-persist</artifactId>
<version>${guice.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt.inject</groupId>
<artifactId>gin</artifactId>
<version>${gin.version}</version>
</dependency>
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>${jbcrypt.version}</version>
</dependency>
<dependency>
<groupId>com.arcbees</groupId>
<artifactId>guicy-resteasy</artifactId>
<version>${arcbees.version}</version>
</dependency>
<!-- REST -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>${resteasy.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>${resteasy.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-guice</artifactId>
<version>${resteasy.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>${jax-rs.version}</version>
<!-- Provided because RestEasy has its own implementation -->
<scope>provided</scope>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jukito</groupId>
<artifactId>jukito</artifactId>
<version>${jukito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
It works just fine if I do a Maven build with the goals clean gwt:run, but then any subsequent builds with only the goal gwt:run will error, saying duplicate class: com.test.shared.dto.LoginDto.
If I follow the suggestion here to add <compilerArgument>-proc:none</compilerArgument>, then the subsequent builds work. However, with the original clean gwt:run goals, it'll fail, saying cannot find symbol: class LoginDto.
Is there any way to make it so that the two builds are consistent?
This is a bug of the maven-compiler-plugin 3.2 (and 3.1 IIRC). Downgrade to 3.0, and add the build-helper-maven-compiler to add the generated source folder as a source folder in the process-classes phase (important is "after compile phase").

Generate WSDL and Copy in Maven Projects

I can generate WSDL directly from service GUI as picture below.
But In the Maven project I don't see such "Generate and Copy WSDL...". My question is How to enable it in Maven Project ?
Is there anything that I am missing. I am also attaching my pom.xml.
Thank you.
pom.xml
<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.avalant</groupId>
<artifactId>OTPMaven</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>OTPMaven</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
<showDeprecation>false</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
As I have not got answer to this question. I have found temporary solution.
I am using command line. JDK's wsgen command to generate required output.
#echo off
set WSGEN="C:\Java\jdk1.6.0_39\bin\wsgen.exe"
set J1="C:\Java\jdk1.6.0_39\lib\tools.jar"
set J2="C:\Java\glassfish-3.1.2.2\glassfish\modules\webservices-osgi.jar"
set J3="C:\Java\glassfish-3.1.2.2\glassfish\modules\endorsed\webservices-api-osgi.jar"
set J4="C:\Java\glassfish-3.1.2.2\glassfish\modules\jaxb-osgi.jar"
set J5="C:\Java\glassfish-3.1.2.2\glassfish\modules\endorsed\jaxb-api-osgi.jar"
set J6="C:\Java\glassfish-3.1.2.2\glassfish\modules\javax.ejb.jar"
set J7="D:\NetBeansProjects\OTP\target\OTP-1.0\WEB-INF\lib\commons-lang3-3.1.jar"
set J8="D:\NetBeansProjects\OTP\target\OTP-1.0\WEB-INF\lib\commons-codec-1.8.jar"
set OUTPUT_DIR="D:\NetBeansProjects\OTP"
#echo on
%WSGEN% -classpath %J1%;%OUTPUT_DIR%\target\classes;%J2%;%J3%;%J4%;%J5%;%J6%;%J7%;%J8%; -d %OUTPUT_DIR%\jax-ws -Xendorsed -keep -wsdl -r %OUTPUT_DIR%\jax-ws -s %OUTPUT_DIR%\jax-ws -verbose com.avalant.ws.GenerateOTPWS