Eclipse Maven web application - can not run on server anymore - eclipse
I have an maven eclipse webapp project that I was able to right click and 'Run on server' and it would deploy on tomcat. I recently did a 'maven -> Update project conifgurations' and I now can NOT deploy and run the project as a webapp. Has anyone seen this before? The only output from tomcat is as follows - it doesnt even look like its trying to deploy the application.
Apr 14, 2010 3:58:54 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
Apr 14, 2010 3:58:54 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:taac-web' did not find a matching property.
Apr 14, 2010 3:58:54 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Apr 14, 2010 3:58:54 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 402 ms
Apr 14, 2010 3:58:54 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Apr 14, 2010 3:58:54 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.24
Apr 14, 2010 3:58:54 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Apr 14, 2010 3:58:54 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Apr 14, 2010 3:58:54 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/14 config=null
Apr 14, 2010 3:58:54 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 247 ms
The POM is still set to WAR, but after cleaning the project I am now getting ClassNotFoundExceptions for libraries that are being included as Maven Dependencies:
SEVERE: Error configuring application listener of class org.springframework.security.web.session.HttpSessionEventPublisher
java.lang.ClassNotFoundException: org.springframework.security.web.session.HttpSessionEventPublisher
Here is my 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cable.wuntee.neto.nse</groupId>
<artifactId>taac-web</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>taac-web JEE5 Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>3.0.1.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.16</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.0.2.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-acl</artifactId>
<version>3.0.2.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.0.2.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.0.2.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>1.3.0.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap</artifactId>
<version>1.3.0.RELEASE</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
<version>3.0.2.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.cable.wuntee.neto.nse</groupId>
<artifactId>wuntee.neto.nse-ldap</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.cable.wuntee.neto.nse</groupId>
<artifactId>wuntee.neto.nse-cada</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.cable.wuntee.neto.nse</groupId>
<artifactId>wuntee.neto.nse-sams</artifactId>
<version>2.0-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.1.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.1.RELEASE</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
<finalName>taac-web</finalName>
</build>
</project>
I found the answer on
Tomcat & Spring Web - Class Not Found Exception org.springframework.web.context.ContextLoaderListener
you need to push Maven dependencies to the server when the project is published to it.
Right Click on your web project in Project Explorer -> select 'Properties'. Under project properties, select 'Deployment Assembly'.
The Deployment Assembly property page shows the content that will be published as a assembled artifact by Eclipse to the server. You need to tell Eclipse that you want all your Maven dependencies to be published too.
To do that, click 'Add' button, then select 'Java Build Path Entries'. Click Next and select Maven Dependencies. This will publish the Maven dependency JAR files to the lib folder when Eclipse publishes your project to WST server
Three possible solutions. I've used all three depending on how it went wrong.
I resolved this by removing the spring security dependencies from my POM (I only have spring-security-taglibs and spring-security-config which pull in everything else I need), saved the POM, let Maven do it's stuff and then added them back in again, let Maven get the dependencies again and restarted the server in Eclipse. When the problem is happening, the Maven dependencies directory in the Eclipse project seems to be missing the spring-security-web artifact (which holds org.springframework.security.web.session.HttpSessionEventPublisher). For me, it only happens when I start Eclipse after rebooting my PC so I'm assuming it's Windows (Vista) and the Eclipse M2Eclipse plugin not playing nicely on file locking or something.
Alternative solution (the problem happened again and previous solutions wouldn't work). This time, I deleted the org/springframework directory from my local maven repository (the one in Eclipse Window->Preferences->Maven->User Settings). Then, update Maven dependencies and wahey here we go again.
If you've done "Maven->Update Project Configuration" and this happens it may well be because your "Deployment Assembly" settings aren't including the Maven dependencies. Go to project->properties->deployment assembly. Check that Maven Dependencies is in there and haas a deploy path of /WEB-INF/lib. If not, click on add and find it under the Java build path option. If it's not there, your build path is probably corrupted too (although that's never happened to me).
Maybe you changed the <packaging> from war to something else per accident. Can you show your POM?
Can you also confirm that you have the Maven WTP Integration for WTP installed (this is improbable but maybe you installed the latest version of M2Eclipse without this extra and somehow, things were working until you updated the project configuration )?
I had that weird compilation errors you had on the WAR project. From some reason the classpath was changed somehow and it ignored other projects in my workspace which the WAR was dependent upon.
The only solution which eventually worked was to erase my workspace, and on each project delete .classpath, .project and .settings. Starting from a new workspace solved it.
I did find a bug mentioning something similar to this in Maven WTP bug tracker, but I didn't get enough votes to get fixed I guess.
Under project properties, go to "facets", press convert to something something, enable dynamic web module and press apply.
None of these helped - I ended up just disabling workspace resolution, and dealing with installing the workspace dependancies when they were out of date.
Alternative solution (the problem happened again and previous solutions wouldn't work).
This time, I deleted the org/springframework directory from my local maven repository (the one in Eclipse Window->Preferences->Maven->User Settings). Then, update Maven dependencies and wahey here we go again.
I had the same problem today, for me it helps to reinstall apache in eclipse an rebuilding/refreshing the project afterwards
Okay, I've struggled with this a bit as well. I don't think there's much of a definitive answer and for a while I would just delete the project and re-import it since that would work every time.
Today I found that it started to work again after running a maven clean on the project (mvn clean from the command line, for example). Give that a try to see if that will work for you.
This is NOT equivalent to the eclipse clean as it only deletes a selected few folders from the target directory, not the whole thing.
I've run into this issue every so often, quick fixes are:
Right click project -> Maven -> Update Project...
Eclipse Servers tab: stop server, Right click Tomcat v# -> Clean... -> OK
Here are the troubleshooting steps I use to see what Eclipse is actually deploying when it runs tomcat. This is current as of Mars and Neon. (these steps assume you have run your project at least once using "Run on server...")
Pull up the settings for running your project on tomcat:
Right click project -> Run As -> Run Configurations...
Go to the arguments tab and look in VM arguments, you will see something like this:
Look for the value of -Dwtp.deploy. For me it was
D:\code\workspaceNeon\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
That directory contains the standard webapp deployment structure. Open that directory in your OS file explorer and examine the contents. When I looked in my WEB-INF/lib, I saw most of my dependencies were missing
Be sure to exit out of that directory when you are done, otherwise eclipse will get errors trying to modify/update it
Now it's time to fix the problem. Let's see what Eclipse is supposed to be deploying:
Open the Deployment Assembly settings for your project:
Right click project -> Properties -> Deployment Assembly
Maven Dependencies is the critical item above.
If this is missing, close out of the dialog and do a maven update:
Right click project -> Maven -> Update Project...
Now that we've made updates, let's clear out the server working directory manually and republish. This may not always be necessary, but is a good way to ensure everything is in sync between what's shown in Deployment Assembly and what is actually deployed:
In eclipse go to the Servers tab. If you don't see it in your current eclipse layout, do
Window menu -> Show View -> Other.. -> search for "Servers"
Right click Tomcat v#... and select "Clean...". Click OK in the confirmation dialog
Right click Tomcat v#... and select "Publish"
Start the server and test. If still have problems, go back to the wtp.deploy directory and inspect to see what's wrong
Good luck!
Related
JDK 11 with JAXB and JAXWS works with Eclipse but not IntelliJ
I am converting an application that uses JAXB and JAX-WS from JDK 8 to JDK 11. The code runs when I use Eclipse IDE but exactly the same code fails with IntelliJ IDEA I have created a Maven project using both Eclipse and IntelliJ IDEA. The problems of finding a working combination of Maven resources has been described in another question. JDK 11 with JAXB and JAXWS problems The code builds without error in both environments. I have tried creating the IntelliJ IDEA project as a Maven project as well as a standard IDEA project part of pom.xl <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-controls</artifactId> <version>11.0.2</version> </dependency> <dependency> <groupId>org.openjfx</groupId> <artifactId>javafx-fxml</artifactId> <version>11.0.2</version> </dependency> <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> <version>2.3.0</version> </dependency> <!-- JAXWS for Java 11 --> <dependency> <groupId>com.sun.xml.ws</groupId> <artifactId>rt</artifactId> <version>2.3.1</version> </dependency> module-info.java module org.openfx.gustfx { requires javafx.controls; requires javafx.fxml; requires transitive javafx.graphics; requires java.xml.bind; requires java.xml.ws; requires javax.jws; opens com.agile.ws.schema.common.v1.jaxws to javafx.fxml; opens org.openfx.gustfx to javafx.fxml; exports org.openfx.gustfx; } When the code is run from Eclipse, there are no errors. Running the same code from IntelliJ IDE results in this error java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl Searching through the jar files confirms that ProviderImpl.class is now located in com.sun.ws.spi not in com.sun.xml.internal.ws.spi This does not cause a problem with eclipse but IDEA reports the ClassNotFoundException Therefore, my question "How does eclipse resolve this problem while IntelliJ does not ?"
With help from Roman Shevchenko at IntelliJ, I have solved this problem using the following pom.xml <dependency> <groupId>com.sun.xml.ws</groupId> <artifactId>jaxws-rt</artifactId> <version>2.3.2</version> </dependency> <dependency> <groupId>javax.jws</groupId> <artifactId>javax.jws-api</artifactId> <version>1.1</version> </dependency> and module-info.java requires java.xml.ws; requires java.xml.bind; requires javax.jws;
Error deploying Spring project to Weblogic [duplicate]
i am using spring 3.1.0.RELEASE, and my servlet container is tomcat 7 and my IDE is eclipse indigo and the jar spring-webmvc-3.1.0.RELEASE.jar which contains the DispatcherServlet exists in the lib folder, and yet when running the application, i am getting the exception: java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:126) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1043) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957) at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284) at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) please advise why i am getting this exception, and how to fix it. EDIT: following are my configuration files: 1- .springBeans: <?xml version="1.0" encoding="UTF-8"?> <beansProjectDescription> <version>1</version> <pluginVersion><![CDATA[2.9.0.201203011806-RELEASE]]></pluginVersion> <configSuffixes> <configSuffix><![CDATA[xml]]></configSuffix> </configSuffixes> <enableImports><![CDATA[false]]></enableImports> <configs> <config>src/main/webapp/WEB-INF/checkout-servlet.xml</config> </configs> <configSets> </configSets> </beansProjectDescription> 2- web.xml: <web-app> <display-name>Checkout</display-name> <servlet> <servlet-name>checkout</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>checkout</servlet-name> <url-pattern>*.action</url-pattern> </servlet-mapping> </web-app> 3- checkout-servlet.xml: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"> <context:component-scan base-package="com.myapp"/> <bean id="myService" class="com.myapp.MyService"/> </beans> also when trying to access any page in the application, i get the exception: HTTP Status 404 - Servlet checkout is not available type Status report message Servlet checkout is not available description The requested resource (Servlet checkout is not available) is not available. Apache Tomcat/7.0.22
You need to add the "Maven Dependency" in the Deployment Assembly right click on your project and choose properties. click on Deployment Assembly. click add click on "Java Build Path Entries" select Maven Dependencies" click Finish. Rebuild and deploy again Note: This is also applicable for non maven project.
Two possible answers: 1- You did not include spring-beans and spring-context jars in your lib. If you are using maven (which will help a lot) those two lines will be enough <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.1.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>3.1.0.RELEASE</version> </dependency> 2- The necessary jars are in your classpath but are not deployed on tomcat.
I had the same problem with Idea Intellij and Spring 4. I fixed the problem and I wanted to share the answer with you. I use tomcat 7 / idea intellij 13 / spring 4. pom.xml dependencies: <properties> <spring.version>4.0.5.RELEASE</spring.version> </properties> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version> </dependency> <dependency> enter code here <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>1.7.2</version> </dependency> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> </dependencies> In idea Intellij, you need to go to File -> Project Settings -> Artifacts. Then clean -> rebuild the project -> build the artifact, and everything will be ok.
This solves the problem for me. It's easy and pretty simply explained. Step 1 Right click on project Click on Properties Step 2 Click on Deployment Assembly Tab in the Click Add... Step 3 Click on Java Build Path Entries Step 4 Click on Maven Dependencies Click Finish button Step 5 Redeploy Spring MVC application to Tomcat again Restart Tomcat List item classnotfoundexception
i found that in the deployment assembly, there was the entry: [persisted container] org.maven.ide.eclipse.maven2_classpath_container i removed it, and added the maven dependencies entry, and it works fine now.
If all of these advice doesn't work, you should re-create your Server (Tomcat or like that). That solved my problem.
Include below dependency in your pom.xml <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>{spring-version}</version> </dependency>
I was facing the same Issue. When I saw into maven repository .m2 folder(....m2\repository\org\springframework\spring-webmvc) in my local I found two 3.2.0.RELEASE folders. SO I removed one. Then I went to project, right click->properties->deployment essembly-> add maven dependencies. clean build and then restart the server. Then the DispatcherServlet got loaded.
Go to properties of Project which your working Choose the Deployment Assembly menu and Click on add button opt the Java Build Path Entries and Click on Maven Dependencies Build the project and run
In my case I get this trouble after using the maven's update project utility. I tried all the workarounds you suggested but nothing seemed to work. At the end the solution was simply to remove the project from the server to ensure that it was clean, and add it again. Then it works, I hope this solution could help any of you.
You can use GlassFish server and the error will be resolved. I tried with tomcat7 and tomcat8 but this error was coming continuously but resolved with GlassFish. I think it's a problem with server. These are the results with tomcat7: Here are the results with GlassFish:
right click on your project and choose properties. click on Deployement Assembly. click add click on "Java Build Path Entries" select Maven Dependencies" click Finish.
It may be useful for someone, so I'll post it here. I was missing this dependency on my pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency>
I solved by following these steps: Right click in the project > Configure > Convert to Maven project After the conversion, right click in the project > Maven > Update project This fixes the "Deployment Assembly" settings of the project.
Move the jar files from your classpath to web-inf/lib, and run a new tomcat server.
I found a simple solution, Simply add your jars inside WEB-INF-->lib folder..
I had this same issue in WebSphere, but couldn't find a solution even though I verified the Spring dependencies were there and it ran in tomcat just fine. I ended up uninstalling the application and was still getting the error so I think WebSphere was hanging onto some corrupt instance. To fix the issue I had to reinstall the application, stop it, uninstall it and then reinstall it.
For me it was a mistake in the pom.xml - I'd set <scope>provided<scope> on my dependencies, and this was making them not get copied during the mvn package stage. My symptoms were the error message the OP posted, and that the jars were not included in the WEB-INF/lib path inside the .war after package was run. When I removed the scope, the jars appeared in the output, and all loads up fine now.
The maven project generated by gwt-maven-plugin can't be imported into eclipse via import existing maven project
I firstly generated a gwt maven project by executing -- mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.7.0 After that, the pom.xml is as follows: <?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.boye.games</groupId> <artifactId>games-gwt</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>GWT Maven Archetype</name> <properties> <!-- Convenience property to set the GWT version --> <gwtVersion>2.7.0</gwtVersion> <!-- GWT needs at least java 1.6 --> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt</artifactId> <version>${gwtVersion}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-servlet</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-dev</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> </dependencies> <build> <!-- Output classes directly into the webapp, so that IDEs and "mvn process-classes" update them in DevMode --> <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory> <plugins> <!-- GWT Maven Plugin --> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <version>2.7.0</version> <executions> <execution> <goals> <goal>compile</goal> <goal>test</goal> <goal>generateAsync</goal> </goals> </execution> </executions> <!-- Plugin configuration. There are many available options, see gwt-maven-plugin documentation at codehaus.org --> <configuration> <runTarget>LineThree.html</runTarget> <modules> <module>com.boye.games.linethree.LineThree</module> </modules> </configuration> </plugin> </plugins> </build> </project> Then I imported this project into eclipse via built-in eclipse function -- import existing Maven project. However, the process failed due to several reasons: GreetingServiceAsync cannot be resolved to a type Execution default of goal org.codehaus.mojo:gwt-maven-plugin:2.7.0:generateAsync failed: Plugin org.codehaus.mojo:gwt-maven-plugin:2.7.0 or one of its dependencies could not be resolved: Failed to collect dependencies for org.codehaus.mojo:gwt-maven-plugin:jar:2.7.0 () (org.codehaus.mojo:gwt-maven-plugin:2.7.0:generateAsync:default:generate-sources) google plugin can't identify this project as gwt web application automatically. My environment as follows: java version 1.7.0_03 eclipse version Kepler Service Release 2 gwt version 2.7.0 Please advice, thanks a lot!
I did another attempt to try in a win32 computer, the problem re-appeared even if I set up the environment as aforementioned working in my win64 computer. So I really got confused, like Klarki said, I have to do some tweaks to get it work. I generated GreetingServiceAsync via mvn gwt:generateAsync then manually copy GreetingServiceAsync to source folder, then I remove <goal>generateAsync</goal> in pom.xml, then import project via eclipse's existing maven project. It works again! Sadly see it not working intelligently.
The problem was with generateAsync, which in your case generates GreetingServiceAsync on execution. Eclipse probably wasn't configured to handle it properly and this class was not generated and eclipse reported the missing class warning. Another thing that could be done to get the project to work was to run mvn package from command line and add the generated dir in target dir as source dir in eclipse (vie right clicking the project and selecting New -> source folder > browsing folder name > target > generated-sources > the right folder) Also you may run into same issue after you do mvn clean - the generated GreetingServiceAsync will be deleted and the problem may come back. The problem exists because eclipse isn't tightly integrated with maven and uses its own build system ignoring maven targets that you don't have plugins for. What you could do is to open eclipse preferences > maven > lifecycle mappings and there you can enable generateAsync to execute. If you copy the generated class manually you have to keep in mind that you need to update it when needed, where as it is intended to generate automatically. So you loose this convenience.
This work for me: I deleted the local maven gwt repository, in windows 7 it's in C:\Users\.m2\repository\com\google\gwt, and then make a mvn clean complile so maven re-import al dependencys.
After I changed my environment as follows: java version "1.8.0_05" eclipse Version: Luna Release (4.4.0) Google plugin for Eclipse 4.4 I works like a charm. Probably, it's a version incompatibility issue.
Maven generates old and unwanted RichFaces jars
I have a JSF 2.0 project and when I run 'mvn package' from eclipse (right click on the pom file and run) I get the war file with older versions of the richfaces jars along with the latest jars as shown in the image below. pom.xml: <properties> <org.richfaces.bom.version>4.3.4.Final</org.richfaces.bom.version> </properties> <dependencies> <!-- Mojarra implementation of JSF spec 2.2 --> <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.faces</artifactId> <version>2.1.6</version> </dependency> <dependency> <groupId>org.richfaces</groupId> <artifactId>richfaces-bom</artifactId> <version>${org.richfaces.bom.version}</version> <scope>import</scope> <type>pom</type> </dependency> <dependency> <groupId>org.richfaces.ui</groupId> <artifactId>richfaces-components-ui</artifactId> <version>${org.richfaces.bom.version}</version> </dependency> <dependency> <groupId>org.richfaces.core</groupId> <artifactId>richfaces-core-impl</artifactId> <version>${org.richfaces.bom.version}</version> </dependency> </dependencies> How can I fix this? Any help would be appreciated.
Suggest you to install maven outside of eclipse and try to run 'mvn package' from command line and see if you encounter the same problem in this way as well. You may also create a 'New Launch Configuration' in eclipse for running mvn package from inside eclipse. To do this, right click on the pom.xml file > Run as > Run configuration ... Hit 'New launch configuration'. This will take care of any mis-configuration you might have done inadvertently in your earlier launch configuration.
Maven does not automatically download dependencies
I'm a starter for Maven. I pulled a java maven project from Bitbucket. When compiling the prject Eclipse said "8/6/12 1:39:05 PM EST: Missing artifact com.tinkerpop.blueprints:blueprints-core:jar:1.0:compile": Maven console: 8/6/12 1:39:03 PM EST: Missing artifact com.tinkerpop.blueprints:blueprints-core:jar:1.0:compile 8/6/12 1:39:05 PM EST: Missing artifact com.tinkerpop.blueprints:blueprints-core:jar:1.0:compile but when I check the pom.xml file, it is already there in the dependency list, only the Type and Scope fields are empty. Seeing the errors, I try to add this dependency by myself. And it showed like this: The #1 question is, Why for 1.0 version, blueprints-core only have a .pom file not a .jar file? Does this mean in the remote repository they don't provide the 1.0 version any more? (I found the codes in the project reply on 1.0 version instead of 2.0 version of this Blueprint framework) The #2 questions is, under what circumstances Maven will not automatically download the jar files for the dependencies added? This is the original 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/xsd/maven-4.0.0.xsd"> <parent> <groupId>edu.qut.cs</groupId> <artifactId>qut-recommender</artifactId> <version>1.0-SNAPSHOT</version> <relativePath>../qut-recommender/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>rcmd-common</artifactId> <packaging>jar</packaging> <name>QUT Recommender Common Library and Utilty</name> <dependencies> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>11.0.1</version> </dependency> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>2.7.2</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.mahout</groupId> <artifactId>mahout-ext</artifactId> <version>1.0-SNAPSHOT</version> <scope>compile</scope> </dependency> <dependency> <groupId>jgrapht</groupId> <artifactId>jgrapht</artifactId> <version>0.7.3</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.tinkerpop.blueprints</groupId> <artifactId>blueprints-core</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version> </dependency> </dependencies> </project> The POM and Jar files of 1.0 version exist. The following picture is the directories and files in the folder of "C:\Users\n8275441.m2\repository\com\tinkerpop\blueprints". BTW, I pulled this project from Bitbucket repository. Is it possible that those 1.0 version files came along with the project in Bitbuckdet?
Based on your information and after checking maven central the problem is based on the version you have selected. Maven Central contains only a version 1.2, 2.0.0 and 2.1.0 but not a version 1.0. Furthermore if a dependency is given without scope like in your pom: <dependency> <groupId>com.tinkerpop.blueprints</groupId> <artifactId>blueprints-core</artifactId> <version>1.0</version> </dependency> this means default scope which is "compile" (as in the sense of convention over configuration). I would simply suggest to change the version to 2.0.0 or 2.1.0 which should solve the problem. If you check compiling such project i would suggest to do the first try on command line and not in Eclipse.
If you're wondering what Maven Central offers, mvnrepository.com is your friend. In this case, there is no 1.0 version: http://mvnrepository.com/artifact/com.tinkerpop.blueprints/blueprints-core Which leads to the interesting question why m2e reports a POM file for it. I suggest to have a look on your hard disk if the POM file really exists. You can find it (or not) in C:\Users\n8275441\.m2\repository\com\tinkerpop\blueprints\1.0\blueprints-core\ As for question #2: Maven (and m2e as well), will try to download a release (i.e. something that doesn't have SNAPSHOT in the version) only once. If the download fails, Maven will note that and never try again since it assumes that the upstream repositories (Maven Central, for example) heed the Maven rules (so if a repo doesn't have something, it won't have it tomorrow). For snapshots, Maven will try to download them once per day to get a good balance between keeping you up to date and not wasting your time waiting for some download.