GWT Maven - webapp files getting deleted when running in dev mode - eclipse

As specified in the gwt maven mojo plugin documentation, I have selected src/main/webapp folder as my war directory in eclipse->project properties->Google->Web application. Then, when I tried to run my gwt project in dev mode from eclipse, the html files in webapp folder was getting deleted. After some investigation, I was able to fix this by modifiying -war value in run configuration to the target folder of the project. But the problem I am facing now is that, after running the project in dev mode, I have to manually copy the html files to the target directory each time for the dev mode to work. Can anyone please help me to identify what I am missing here. How can I set the webapp folder as war directory and prevent the files from getting deleted? Please help.

The correct way to configure the Google Plugin for Eclipse (using M2Eclipse) and run DevMode is explained in the FAQ: http://web.archive.org/web/20130619170526/https://developers.google.com/eclipse/docs/faq#gwt_with_maven

May be you have to set the copyWebapp parameter to true?
<configuration>
<style>PRETTY</style>
<strict>true</strict>
<runTarget>index.html</runTarget>
...
<copyWebapp>true</copyWebapp>
</configuration>

Our .pom uses this:
<properties>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<gwt.war.directory>${project.build.directory}/war</gwt.war.directory>
</properties>
In the Arguments tab of the debug configuration we use:
-remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -startupUrl appname.jsp -logLevel INFO -port 8888 -codeServerPort 9997 -war
"${workspace_loc:appname/target/war}" com.yourcompany.app
Seems to work without the problem you are having.

I am not sure if this is a problem faced only by me, but even after following the steps specified in the maven plugin configuration the issue had occurred to me randomly. But nowadays its not happening and this is what I did differently.
Use the gwt only in eclipse java perspective, not in j2ee perspective.
In eclipse->project properties->Google->Web application, check the Launch and deploy from this directory option.

I was caught out by this too. If you put your static files for the webapp into the "src/main/webapp" folder, they will be copied over to the target folder if the tickbox in Settings->Web Application is unchecked (as it would be by default if it's an M2eclipse project).
I set my target folder to be the "war" folder on the project and ignored it in version control.

Related

Wildfly in Eclipse is adding the Maven SNAPSHOT to the web context

I'm having a new problem when we moved to a Wildfly 8.x server in eclipse.
My project is called PayloadSvc. The first part of the pom.xml looks like this:
<modelVersion>4.0.0</modelVersion>
<groupId>PayloadSvc</groupId>
<artifactId>PayloadSvc</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
Later in the pom I have this:
<build>
<finalName>PayloadSvc</finalName>
In eclipse I also have my context root in the Web Project Settings set to PayloadSvc
However, when it deploys into Wildfly it deploys this way:
Registered web context: /PayloadSvc-0.0.1-SNAPSHOT
I can't seem to get it to remove the "-0.0.1-SNAPSHOT" part of the web context.
Oddly enough, other projects in the same workplace work correctly even with the same pom data (with appropriate context, groupId, artifact Id, and the same version attribute of course).
I'm using the STS version of Eclipse Neon.
Thank you for any advice you may have.
Just had the same problem solved.
If you don't have it already, create a WEB-INF\jboss-web.xml file, with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>PayloadSvc</context-root>
</jboss-web>
Republish the resource and you're done.
Not sure why the file is not created automatically though.
Edit the file \[root-of-your-project]\.settings\org.eclipse.wst.common.component, changing the deploy-name attribute and context-root value.
Show the server tab by: Window > Show View > Server
Right click on your server then Add and Remove.... Remove all projects from server.
Right click on your server and clean.
Just to be sure, go to the directory where WildFly is installed and delete the content of the directory [wildfly-path]\[standalone-path]\deployments, if it exits.
Add again the projects into your server and run.
Have you tried adding the <name>PayloadSvc</name> element in the root of the pom (same spot as your group,artifact,version elements)?
If that doesn't help, what does the artifact look like when you build it with mvn install? Does it include the version number in the war filename?
For Eclipse Neon:
1 Did a Eclipse Neon 'Check for updates' and updated it.
2 I editted file org.eclipse.wst.common.component adding a blank line and saved (check if deploy-name is suffixed with SNAPSHOT).
3 After that the suffix '0.0.1-SNAPSHOT' disappear from the war name when adding it to Wildfly server.

Libgdx GWT No index.html file in war folder

So for the past few hours I have been trying to launch my libgdx game in html. I have gwt installed, and I tried following the instructions on the libgdx wiki, but nothing's working. I've tried GWT compile, and I've launched it in all the dev modes. I tried to launch it from a brand new project all the same ways but still nothing. I also tried setting the the WAR directory to webapp and war. When I use webapp I get a link in the eclipse Development Mode tab and when I open it I get a 404 index.html not found, but when I use war its blank. When I check the war folder there is not an index.html no matter how many times I compile the project (although it does have my assets, WEB-INF, and a html folder). There is one in webapp so I tried moving it to the war folder. I get a link but again I get a 404 index.html not found. I have no idea what's going on. I've been searching around on google and nothing seems to be working. I'm not sure what I should upload to help, so I'll upload any information you think might help.
I get this same issue when using the mojo maven gwt plugin when running on macos. This doesn't seems to have issues on Windows.
The fix is to add the flag copyWebapp=true to the pom.xml, so it looks like this:
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<configuration>
<strict>true</strict>
<testTimeOut>180</testTimeOut>
<mode>htmlunit</mode>
<includes>**/*GwtTest.java</includes>
<logLevel>INFO</logLevel>
<runTarget>index.html</runTarget>
<module>com.kiwlm.pykdo.GwtMaterialBasic</module>
<copyWebapp>true</copyWebapp>
</configuration>
I am not that familiar with how libgdx runs GWT but I think this is most likely it.

ext plugin not working in liferay 6.1.2 jboss7

I created an ext-plugin for extending Liferay LDAP DefaultPortalToLDAPConverter. I created an ext plugin in eclipse. In the ext-impl/src/main/java/com/liferay/portal/security/ldap/CustomPortalToLDAPConverter i extended DefaultPortalToLDAPConverter and kept only the changed methods in my class. Also I added in ext-spring.xml
<bean id="portalToLDAPConverter" class="com.liferay.portal.security.ldap.CustomPortalToLDAPConverter" />
and then deployed the ext. The deployment went well without any errors. But the changes did not take place. Is there anything wrong in what I am doing? I use jboss7.1.1-final bundled Liferay6.1.2. I build using maven and then deploy by placing the war file in liferay-home/deploy. Then I tried restarting the server. Now I could see that my ext-spring.xml is missing in the jar file. Is there any specific reason for this? Please help.
Most of the tutorials say that the META-INF should be placed in the ext-impl/src or ext-impl/src/main folder. Doing so was not placing my ext-spring.xml in the jar build. Shifting the jar to ext-impl/src/main/resources helped and the META-INF was detected. Upon restarting, the changes took effect.
Not compiled files that are meant to be put inside of class-path of resulting artifact should be placed in main/resources path: http://maven.apache.org/guides/getting-started/index.html#How_do_I_add_resources_to_my_JAR

Failed to resolve version for org.apache.maven.archetypes

I have configured maven3.0.3 in my local machine. Have installed m2e eclipse plugin.
But when i try to create a new maven project using maven-archetype-webapp, i get the following exception.
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:RELEASE from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype- webapp:pom:RELEASE
Failed to resolve version for org.apache.maven.archetypes:maven-archetype- webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype- webapp/maven-metadata.xml in local ([HOME]/.m2/repository)
Failed to resolve version for org.apache.maven.archetypes:maven-archetype- webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype- webapp/maven-metadata.xml in local ([HOME]/.m2/repository)
I do some processing behind a proxy and the proxy configurations are updated in {HOME}/.m2/settings.xml and M2_HOME/conf/settings.xml.
The archetype generate command works fine in command line. It downloaded the dependencies through proxy.
Any help is greatly appreciated.
Edit 05-10-2012
While creating a new Maven Web project in eclipse, the archetype "maven-archetype-webapp" version is displayed as RELEASE. Is this in anyway linked?
I had the same problem. I fixed it by adding the maven archetype catalog to eclipse. Steps are provided below:
Open Window > Preferences
Open Maven > Archetypes
Click 'Add Remote Catalog' and add the following:
Catalog File: https://repo1.maven.org/maven2/archetype-catalog.xml
Description: maven catalog
I found the following tutorial very useful.
Step1: The maven command used to create the web app:
mvn archetype:generate -DgroupId=test.aasweb -DartifactId=TestWebApp -DarchetypeArtifactId=maven-archetype-webapp
Step2: The following entry was added onto the project's pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>1.5</wtpversion>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<classpathContainers>
<classpathContainer>
org.eclipse.jst.j2ee.internal.web.container
</classpathContainer>
<classpathContainer>
org.eclipse.jst.j2ee.internal.module.container
</classpathContainer>
/classpathContainers>
<additionalProjectFacets>
<jst.web>2.5</jst.web>
<jst.jsf>1.2</jst.jsf>
</additionalProjectFacets>
</configuration>
</plugin>
Step3: Run the maven command to convert into eclipse project format.
mvn eclipse:clean eclipse:eclipse
Step4: Import the project onto eclipse as Existing Maven project.
If you are using eclipse, you can follow the steps here (maven in 5 min not working) for getting your proxy information. Once done follow the steps below:
Go to Maven installation folder C:\apache-maven-3.1.0\conf\
Copy settings.xml to C:\Users\[UserFolder]\.m2
Modify the proxy in settings.xml based on the info that you get from the above link.
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>your proxy</host>
<port>your port</port>
</proxy>
Open eclipse
Go to: Windows > Preferences > Maven > User Settings
Browse the settings.xml from .m2 folder
Click Update Settings
Click Reindex
Apply the changes and Click OK
You can now try to create Maven Project in Eclipse
Read carefully about the reason.
"Failed to resolve version for org.apache.maven.archetypes:maven-archetype- webapp:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype- webapp/maven-metadata.xml in local"
So all you need to do is download the maven-metadata.xml
to your {HOME}.m2\repository
That's it.
You do need to have a settings.xml linked under user settings (Located in preferences under maven)
But, if that doesn't fix it, like it didn't for many of you. You also have to delete the directory:
.m2/repository/org/apache/maven/archetypes/maven-archetype-quickstart
then quit eclipse and try again.
This is what solved my problem.
Go to Windows-> Preference-> Maven -> User settings
Select settings.xml of Maven
Restart Eclipse
I had a similar problem building from just command line Maven. I eventually got past that error by adding -U to the maven arguments.
Depending on how you have your source repository configuration set up in your settings.xml, sometimes Maven fails to download a particular artifact, so it assumes that the artifact can't be downloaded, even if you change some settings that would give Maven visibility to the artifact if it just tried. -U forces Maven to look again.
Now you need to make sure that the artifact Maven is looking for is in at least one of the repositories that is referenced by your settings.xml. To know for sure, run
mvn help:effective-settings
from the directory of the module you are trying to build. That should give you, among other things, a complete list of the repositories you Maven is using to look for the artifact.
I too had same problem but after searching solved this. go to menu --> window-->preferences-->maven-->Installations-->add--> in place of installation home add path to the directory in which you installed maven-->finish-->check the box of newly added content-->apply-->ok. now create new maven project but remember try with different group id and artifact id.
The right way to solve my problem are as followed. Hope to be helpful to others.
the errors informations.
Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:1.0 from any of the configured repositories. Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0
Delete the maven-archetype-webapp:1.0 in the directory ~/.m2/repository/org/Apache/maven/archetypes
Download the maven-archetype-webapp:1.0 and the maven-archetype-webapp-1.0.pom from
http://maven.ibiblio.org/maven2/org/apache/maven/archetypes/maven-archetype-webapp/1.0/
execute mvn install:install-file -DgroupId=org.apache.maven.archetypes -DartifactId=maven-archetype-quickstart -Dversion=1.1 -Dpackaging=jar -Dfile=此处填maven-archetype-webapp-1.0的路径.
try to establish a maven project of webapp to test whether the problem has solved.
Create New User Environment Variables:
MAVEN_HOME=D:\apache-maven-3.5.3
MAVEN=D:\apache-maven-3.5.3\bin
MAVEN_OPTS=-Xms256m -Xmx512m
Appened below in Path variable (System Variable):
;D:\apache-maven-3.5.3\bin;
This worked for me:- navigate to windows-> preferences-> maven
and check the "download artifacts sources" and click apply.
No need to do all above lengthy steps.
Simply delete c:\Users\.m2\Repository\org folder
Maven will automatically downloads what it needs
I simple use below steps:
Create Maven project -> check checkobox -> "Create a simple project (skip archetype selection)"
It works for me
I downloaded the jar and pom from:
here
and put them here:
\.m2\repository\org\apache\maven\archetypes\maven-archetype-quickstart\1.1\
I also got same error ....And i found that my internet connection is closed so eclipse is unable to download repositories for webapps archetypes and when i got internet connection i just created again maven project with webapps archetypes and my eclipse downloaded repositories and its done...
This is 100% working:
Delete the .m2 folder which is present in your Desktop>User
connect your pc to the Internet
Create your maven project again
Thats it, hope it helps
Try , It worked for = I just removed "archetypes" folder from below location
C:\Users\Lenovo.m2\repository\org\apache\maven
But you may change following for experiment - download latest binary zip of Maven, add to you C:\ drive and change following....
Change Proxy
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username></username>
<password></password>
<host>10.23.73.253</host>
<port>8080</port>
<nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
I had the same problem i solved it by only adding remote catalog
in eclipse go to Window -> Preferences ->Maven ->Archetypes ->click on add remote Catalog then a window will open in that paste
http://repo.maven.apache.org/maven2/archetype-catalog.xml
in that catalog file then hit ok restart eclipse now all working fine
The problem may also come from that you haven't set MAVEN_HOME environment variable. So the Maven embedded in Eclipse can't do its job to download the archetype.Check if that variable is set upfront.

Eclipse Galileo does not deploy external jars into WEB-INF/lib directory

I created new web project testweb.
By default default output folder is testweb\build\classes.
Added some jars to build path.
Then selected these jars in "Java EE Module Dependencies" in order to Eclipse put this jars into WEB-INF/lib during deploying on some server.
Then I deployed this web application from Eclipse on server(JBoss).
All is ok - there are jars in WEB-INF/lib directory.
But if I change default output folder from testweb\build\classes to testweb\web\WEB-INF\classes Eclipse stops to deploy external jars to WEB-INF/lib directory.
This directory is empty!
Why?
What is wrong?
Looks like bug 266268 , also described in this thread.
Notes:
this was for eclipse3.4, do you still have this issue with the latest eclipse3.5.1 (since "Galileo" could be just 3.5)?
there is a debug procedure.
Thanks to Larry and his hints for debugging I found the source cause of this:
don't use WEB-INF/classes as the default output folder. There is a bug (probably), that makes eclipse to calculate project contents differently in this case.
So the workaround solution is to change the default output folder.
The bug is a duplicate of bug 249044, reported fixed in WTP3.0.5: what version of WTP do you have with your Galileo eclipse?