Libgdx GWT No index.html file in war folder - eclipse

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.

Related

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

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.

Maven/Eclipse - Quick iteration acceptance Testing a project packaged as a WAR file

Eclipse makes working with multi module maven projects easy because you don't have to re-build and re-install a module before dependent modules will see changes to it. So you just change the code and eclipse updates the dependencies magically in the background.
I want to achieve this behaviour for acceptance testing as well.
I have
storage-service
storage-service-war
storage-service-acceptance-tests
If I use embedded jetty or tomcat to test inside the storage-service-war project then obviously code changes are immediately viewable in the tests, but I cannot see any way to achieve the same quick iteration of testing when testing from storage-service-acceptance-tests.
Every way I look at it it seems that I have to build storage-service-war and then use the artefact generated from that, but it seems like overkill when you only want to change one line.
Does anyone have a good method for doing this?
Cheers
Piers
So answering my own question :D The solution I came up with will not work on CI it will likely only work when doing a local build as it makes use of the relative paths of the projects. At the bottom I outline a more robust but more complex approach that should satisfy eclipse and CI.
I was looking at setting attachClasses to true for the war plugin configuration of the war project.
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<attachClasses>true</attachClasses>
</configuration>
</plugin>
</plugins>
You can then reference the jar in the dependent project as follows
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>storage-service-war</artifactId>
<version>${project.version}</version>
<classifier>classes</classifier>
</dependency>
Then I was thinking I could run my tests from within the acceptance test module using embedded jetty or tomcat and pointing them to the web.xml defined in the war project using a relative path.
This works fine with maven via the commandline but fails in eclipse :(
The problem with this is that the jar produced by attach classes is not picked up by the eclipse m2e integration see -https://bugs.eclipse.org/bugs/show_bug.cgi?id=365419 unfortunately it wont be fixed.
So My solution for the moment is to manually add the storage-service-war project to my acceptance test project build path in eclipse. Its not great but it works
The above solution is a bit hacky but the alternative outlined is a bit more involved.
By splitting the project into the following I think it would be possible to have correct eclipse integration and projects that work on CI
storage-service
storage-service-core
storage-service-war
storage-service-acceptance-tests
storage-service-config
The core project contains the logic and source of the webapp and is of type jar, the config contains the web.xml and any other config files and is also of type jar. Then the acceptance-tests and war project are both of type war and serve merely to package the core project into a war and extract the config to the webapp/WEB-INF dir so that they may share a common setup.

GlassFish (real) hot deployment of JSF pages and resources (CSS etc.) in Eclipse

We are wondering how to setup GlassFish 3.1.2 real hot deployment, that is not just the usual setting
How can I hot deploy using the glassfish adapter in Eclipse
but how to make it possible that the Eclipse GlassFish plugin will silently push changed XHTML, CSS, etc. files to the server as you save the file in Eclipse.
How is it officially setup?
Again, I tested this several times now, hot-deploying just-changed XHTML(/JSF), CSS files on save just doesn't work.
When setting to Never publish automatically nothing happens when saving a JSF file.
When setting to Automatically publish when resources change the whole webapp redeployment process is triggered (taking 30+ seconds!).
Q:
How is JSF, CSS hot deployment on save setup using Eclipse and the official GlassFish plugins pointed to a local, non-internal GlassFish 3.1.2?
Where do you have to look? Into the plugin or the local GF?
What makes the whole topic even more confusing is that some people get this to work easily, see http://www.java.net/forum/topic/glassfish/glassfish-plugins/glasfish-plugin#comment-819774
"just about any save of a non-java file will be visible 'immeditaely' when publish on save is active."
Not here!
It's odd... and important!
There is 'hack' that I use and works fine with maven, eclipse & GF4 hot deployment. Navigate inside your workspace where you have you xhtml project.
open .project file
edit
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments></arguments>
</buildCommand>
Modify to:
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<triggers>incremental,</triggers>
<arguments></arguments>
</buildCommand>
It works just fine for, but it might cause weird build issues (haven't tried for a long time so can't really say so use with case.)
============== Another workaround that I tried but run into eclipse/maven bugs==========
I managed to get this to work with eclipse. The steps were the following:
Double-click on glassfish->expand Publishing and make sure that you set Automatically publish when resources changes
Right-click on the server ->Glassfish and make sure User Jar Archives fro Deployement is unchecked
Then make sure you have Project-Build automatically deselected
From what I can tell maven is touching resources on save, so Glassfish restarts.
Hope it helps
If you have installed "Maven Integration for WTP" in your Eclipse, uninstall it (use m2e instead). Doing this, the hot-deployment of WebContent resources such as .xhtml and .css -files was reenabled to me. Unfortunately I don't know the reason for this workaround working.
Anyhow, I am also interested in your question of real hot-deployment (particularly of .java-files).

How do you import a Java Class Library into a Java Web project (using NetBeans)?

I've already tried the options "Add folder...", "Add Library...", and "Add JAR/Folder...", but it's not working this time -- I've done this several times before without any problems.
I've also tried to add the folder / JAR file (.war-file) manually to the projects properties in every thinkable way, but still no success.
And so far, Google hasn't helped either..
Any help would really be appreciated.
(This is for a Java Web project with JavaServer Faces, using NetBeans 7.1)
Solved: I never found out what caused the problem. I ended up re-installing entire NetBeans, and re-created (a thousand times) the project I was trying to import. And in the end, I got it working.
Put the JAR file in the WEB-INF/lib directory of your web project. All JARs in the WEB-INF/lib and all packages in WEB-INF/classes are automatically in the CLASSPATH.
Can you make "Hello, servlet" work? If not, why bother with JSF? Do a simple web app successfully and build up from there.
I had this problem with netbeans, but it seems like all the answers I found are for Eclipse (I guess am wrong) as I dont see any WEB-INF/lib directoryin NetBeans, though I have a WEB-INF directory.
so here what I did.
I remove the tomcat server on NetBeans, go to C:\apache-tomcat-7.0.30\lib , put the jstl-1.2.jar file their, restart NetBeans and add a new (Tomcat) server, create a new web app, and their, I could find the jstl-1.2.jar file in the Libraries > Apache tomcat.
and for unknown reason, it worked.!

Eclipse - Wicket - HTML files from dependent projects not being found

I want to build a reusable Wicket component in Eclipse. I have one project "components" which have files such as MyComponent.java and MyComponent.html. Then I have a project "application" which contains my application code, from which I wish to use a MyComponent.
However, Wicket cannot find the MyComponent.html. If I copy this file from "components" to "application", and use exactly the same path, then Wicket finds it no problem.
I therefore summize that Eclipse is not copying the HTML file from the dependent project "components" and making it available to the web application. I cannot really confirm that as I don't know where the JAR is being generated from the "components" project, nor do I know where/if the WAR is being generated from the "application" project.
I have looked at the project settings in "components" and cannot find any option to explicitly publish HTML (non-Java) files when the project is being built; but I cannot find any option which is explicitly forbidding this either. In the "application" project I find no option to include HTML files from the other project (there is only the option to include the JAR - which potentially should be enough?)
Update: I am not using Maven, just using the default build process of Eclipse.
Update: I am using Tomcat within Eclipse (but without any Eclipse plug-in for Tomcat; it seems to work fine without it - only obviously that's not quite true hence my question...)
Check Eclipse's source folders inclusion/exclusion filters. Project -> right button -> Properties -> Java Build path -> tab Source -> select Source Folder -> button Edit.
I'm assuming you're using Tomcat - during testing I normally use a Tomcat context to reference my Eclipse project workspace.
The workspace contains a context/WEB-INF directory structure, into which all my compiled classes, properties, HTML and other resources are copied.
The Tomcat context file lives in the directory (Tomcat)/conf/Catalina/localhost and contains an entry of the following format:
<Context path="/mywebapp" docBase="C:/eclipse/workspace/myapp/context" reloadable="true">
OK - Classic Eclipse action - for other reasons (restarting the project always resulted in a 404 for no apparent reason: I checked all the config files and everything seemed fine..), I deleted the "application" project from Eclipse and re-created it. Now everything works fine (HTML files are available...)
I had the same problem! After some time doing research I had a solution!
You need to specify to maven that it needs to include all the files, the way how maven understand this is by adding the next command.
<build>
<resources>
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
</resource>
<resource>
<filtering>false</filtering>
<directory>src/main/java</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>
It worked for me, I hope it works for any of you that have the same problem!
I guess for the person that posted this query its too late, but not for you that have this problem!