GWT compilation issues / Intellij IDEA - java

I have a question regarding GWT compilation. There is a project built on GWT/GXT 2.x which is run under Tomcat on Intellij Idea 14.x. There are a couple of problems I face from time to time and which hard to handle. The first one is that the compilation process doesn't start sometimes and there are no obvious reason for that. For instance, there is a code which is compiled. Then I do slight correctings in the code that can't involved anything. Then I run / debug application under Tomcat-configuration but .nocashe.js- file is not created (Failed to load resource: com.gxtapp.GXTApp/com.gxtapp.GXTApp.nocache.js the server responded with a status of 404 (Not Found) - browser's console output). But even if I revert changes it most likely that I will have the same result.
The second issue is that gwt-module is not compiled when I run it under GWT configuration. As a result I have blank page in browser with gwt-logo in right lower corner. Clicking on this logo makes the module to be compiled.
I tried to add gwt-maven-plugin, but when I compiled project through gwt:compile the list of errors was arrised (just for example):
Unable to read: jar:file:/C:/Users/Alex/.m2/repository/com/google/gwt/gwt-user/2.5.1/gwt-user-2.5.1.jar!/com/google/gwt/core/Core.gwtar
Resolving com.extjs.gxt.ui.client.dnd.DND.Feedback
[INFO] Found type 'com.extjs.gxt.ui.client.dnd.DND.Feedback'
[INFO] [ERROR] Unable to find class java/lang/Enum
etc.
So could you give me a pieces of advice how to adjust Idea / Tomcat / GWT configuration to make compilation process work properly. Thank you in advance.
PS Please find below screenshots with Tomcat and GWT configuration

Related

Eclipse 2020-12 - I can't create or edit groovy classes (was OK in 2020-09)

Recently Eclipse 2020-09 updated itself to 20200-12. My Java development has been OK. However, this evening, I needed to create a new Groovy class. The editor failed to open - I got an error 'window' (tltle = 'New') that said:
Creation of element failed. org/codehaus/groovy/eclipse/refactoring/core/utils/GroovyTypeBuilder
Opening an existing Groovy file results in the editor area being all grey and open editors have lost focus.
I've spent ages trying to find a solution - and failed.
If someone can help me with this, I'll be immensely grateful as work on my product has ground to a halt!
BACKGROUND
The new-class action creates a .log file. At the end of the log the entry is
Root exception:
java.lang.NoClassDefFoundError: org/codehaus/groovy/eclipse/refactoring/core/utils/GroovyTypeBuilder
Further up the log, I've seen other 'no class def found' entries for:
"org/codehaus/jdt/groovy/integration/LanguageSupport"
"org/codehaus/jdt/groovy/integration/LanguageSupportFactory"
"org/codehaus/groovy/eclipse/refactoring/formatter/GroovyIndentationService"
This is a Maven+Git project that produces a jar file.
Groovy complierversion is 2.5.14.
Maven dependency is groovy-xml-2.5.6,jar, which pulls in groovy-2.5.6,jar
I spent a long time at the start of 2020 working out the pom.xml so that the App's jar file and related folders+files all end up correctly. (I'm a Sunday-driver Maven guy, so once it worked, I was happy to leave it alone).
I really don't want to change versions of Groovy or anything - I don't think it's good practice to change 'infrasucture' in the middle of project.
As I don't know what other information will be helpful, I will provide it on request.

Maven fail deploy war - Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/]

I just finished my Java app and I'm trying to deploy it to Tomcat 7.
The problem is that starting run war file causes errors:
FAIL - Application at context path /tradesystem-0.0.1-SNAPSHOT could not be started
FAIL - Encountered exception org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/tradesystem-0.0.1-SNAPSHOT]]
I have read many articles and I still didn't solve that.
when I'm write in console 'java -version' it shows v11, which fits with version of compiler (settings > compiler > java compiler > target byte code of project
I've read also, that errors can be caused of bad structure of target folder (someone wrote, that folder 'classes' in target/classes should be deletted but it didn't help.
My sugestion is that I missing some obvious configuration in pom.xml or something like that, but I really don't want to mess up my project, so I've decided to ask you guys.
The screenshot shows structure of my project.
Please keep in mind that's my first deploy ever and the bug for most could be obvious.
Solved by following that article:
https://dzone.com/articles/deploy-spring-boot-apps-from-jar-to-war
I just skip section 2. Update your Main class to extends SpringBootServletInitializer
Topic can be closed.

LibGDX and GWT - Error 404

We've recently been trying to use LibGDX to convert our LibGDX app into a web app. However, whenever we try to run the application we just get a HTML Error 404 and this error code in Eclipse:
[WARN] Server class 'org.eclipse.jetty.servlet.listener.ELContextCleaner'
could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/C:/Users/Steve/Desktop/adt-bundle
windows-x86_64
20140702/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.6.0/gwt-
2.6.0/gwt-dev.jar' to the web app classpath for this session
Despite seeing this a lot on various websites, there have been no useful answers yet.
PS - Please answer in plain English - we're pretty new to this!
Fixed it - turns out our installation of GWT was a bit broken. We found that following the steps here worked better!

List all Java errors in JSP files

I used old Eclipse (Helios) and old Tomcat (5.5) for a large web project. After updating to Tomcat 6, this code stopped working:
short foo = 3;
Integer bar = foo;
Apparently, this is invalid code according to the Java language specification[1], and there was a bug in the old Eclipse compiler so it didn't report it. New Eclipse (Kepler) reports it as an error.
I'm not quite sure why it stopped working with new Tomcat since it is using the same Java compiler as the old Tomcat, but the code is invalid and I want to fix it throughout the project.
First I tried validating the entire project in new Eclipse so it would list all .jsp files with this error. However, this validation in Eclipse doesn't seem to work very well since sometimes it detects several (existing) errors in a file and sometimes reports no errors in the same file (without changes, 10 seconds later).
Next thing I tried was to import project to NetBeans (7.4) and try to list those errors here. When I open a file with error, it detects it: "incompatible types: short cannot be converted to Integer". However, when I list all errors in the "Action Items" list, I can't find those errors (although I set the filter to include compiler errors).
I thought that listing all Java errors in all JSP files in a project would be easy, but turned out that it wasn't. How can I do it?
[1] Widening and boxing with java
The solution to this problem is to compile all JSP files in the project (i.e. generate Java files for them) and then inspect errors for generated files.
NetBeans has option to pre-compile all JSP files, but this didn't work for me because it stops after it hits first Java file with errors (maybe there is a way to circumvent this?).
Another solution might be to configure Apache Maven to build entire project, but I didn't try this, because a co-worker came up with a nice quick-n-dirty solution:
Generate a wget request for every JSP file in project and run all these requests. It doesn't matter that wget can't really access the pages since it isn't logged in, it just 'touches' them and forces the Tomcat to generate Java files.
Something like this (linux/cygwin):
find jsp -name '*.jsp' -printf 'http://localhost:8080/App/%p\n' > tmp/urls
wget -q --proxy=off --spider -i tmp/urls

Eclipse ClassNotFoundException

Everything works fined, but suddenly eclipse stopped execute and junit tests or even main method, when i run them using run as - > Java application, run as -> junit test
It simply throws error
Caused by: java.lang.ClassNotFoundException: package.ClassName
whene ClassName - is class from where i trying to run method main.
It affect only one of my projects ... Different workspaces works fine, other project in same workspace works fine as well.
I'm sure if i recreate current project, error will gone. But the adjustments of this project in eclipse is really hard, so i want to avoid it.
Any clue?
The ClassName is not in the Class Path, if you start from console you should use -cp parameter , if from eclipse, please add ClassName to the sources of current(start) project.
Thanks to adarshr, I was able to look at the Problems window and determine that the build was failing because it could not find a class I had written.
I had used the MS TFS plugin to create a "shelveset" and it was supposed to have removed my pending changes in the process. However, this integration with the TFS snapin and Eclipse is obviously not well implemented, since the Eclipse project still thought the file existed and was complaining that it could not be compiled.
I went and manually deleted those "files" or "non-existing files" from the Eclipse project (that I thought I had removed with the shelveset action) and the problem was solved.
Also....
Another annoying things is that the Tomcat error I was getting by trying to debug within Eclipse was like this:
SEVERE: Error configuring application listener of class
com.CompanyName.ProjectName.servlet.StartupConfigListener
java.lang.ClassNotFoundException:
com.CompanyName.ProjectName.servlet.StartupConfigListener at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1643)
In reality, there was no problem at all with StartupConfigListener.java!! The build failed due to the OTHER problems I mentioned above, and therefore I guess this was the first class it attempted to load and failed.... because the entire project hadn't been able to compile perhaps?
(Here's to hoping my next project is using Visual Studio instead of Eclipse!)
Ok, I finally figured it out. The problem was with installed JRE in eclipse setting. I was playing around with this setting and changed installed JRE to JDK, and for some reason it broke the eclipse project.
You can also try going back to the basics. Check your command line and VM args. I've had this situation where a VM arg I was passing in was a path to a file that had a space in the path, and I had forgotten to include the full path in quotes. So e.g., if my arg looked something like
-DFILE=C:\Documents and Settings\myfile
...I'd get a java.lang.NoClassDefFoundError caused by a java.lang.ClassNotFoundException.

Categories