GWT context.xml in shell mode - java

I'm trying to get the GWTShell mode to load my context.xml file in which my database is described.
The only usable info can be found here, but this doesn't seem to work for the context.xml part.

I'm using Eclipse with Cypal Studio (previously called Googlipse).
If there is any other better plugin for Eclipse please recommend it.
As the Shell mode uses a Tomcat instance, which is the same target server we are using in the final deployment, it should be possible to achieve (or fake) a similar behaviour.

As of version 1.4, I have been running all my server side code, in my container of choice (Glassfish) and hooking up the GWTShell to that. Are you using Netbeans, Eclipse or something else? The Netbeans plugin gwt4nb does this for you out of the box, you just have to start your web project in debug mode. I'm sure the GWT plugin for Eclipse does the same thing.
I realise this doesn't directly answer your question -> but my question is, is there a reason you're trying to get GWT to pick up your database settings and not just running your project as normal instead. I find this much better and robust way of running the GWTShell.
Edit: Sorry I don't really use Eclipse, so I can't help you with plugins for it. I find Netbeans far superior for J2EE/web type projects. It's a bit slower, but far more functional. The plugin for that is called 'GWT4NB', it's free and it will set up your ant script in such a way that you just have to right-click on your web project and choose debug. I can understand if you don't want to switch IDEs though.

Related

How do I get Netbeans to use the specified Gradle version?

I've come back to project after a long diversion, and upgraded tooling. This means Netbeans 12.5, Java 17, Gradle 7.3… at least allegedly. For some reason, despite setting the Gradle version to 7.3, it appears to build with 7.0.
Per the image below, setting the Gradle version to 7.3 doesn't seem to be picked up. (That is immediately after hitting Apply.) It still tries to build with 7.0. And – for some indeterminate reason – it can't.
Restarts don't help; I can't get the configuration to be picked up. (Searches for reference to similar issues provide 5-year-old answers that are no longer relevant.) I've even tried deleting the 7.0 distribution; to no avail, it comes right back.
Can anyone provide guidance on getting this to work properly?
Netbeans 12.6 fully supports Java 17 and Gradle 7.3. Gonfiguring the Gradle wrapper for 7.3 gets picked up correctly, eliminating all errors I was experiencing.
Don't bother with gradle in Netbeans. It's a horrible, buggy disaster and 12.6 just seems to want to up the ante.
Netbeans does NOT support gradle in a meaningful way for normal users.
You now get complex multi-projects whether you want them or not.
When creating a Java Application you don't get a choice at what the Main class is called. It will be App with app.java and you will like it.
If you try to rename app.java to something useful. It will not change "Class App" to "Class Useful" it will instead change it to "ClassUsefulp". It will not rename the test file and you will be left with several syntax errors that you can have fun cleaning up.
No, you cannot rename the subproject itself. That will continue to be the extremely descriptive and useful "app" subproject. The IDE will not provide you a way to rename that.
There is no meaningful, intuitive way to create/delete/modify subprojects.
If your gradle version is somehow out of sync there is still no useful way to reset/recreate the gradle wrapper other than creating a whole new project and moving your source code over to the new project.
Oh, so you gave in and accepted the multi-project structure. You noticed that if you go through the multi-project creator GUI then you can create multiple subprojects. Yeah, good luck with that. They won't have gradle build.scripts or wrappers. You won't be able to build your awesome creation.
Want to use command line arguments? Forget it. There is no "run" element in the project properties. You cannot create different run configurations.
Want dependencies? Or any other project configuration? It's all manual editing of gradle files. There's no GUI to assist non-gradle-wizards.
Yeah. you can probably work around a lot of this by dropping to a command line shell and editing the gradle scripts/files manually and running gradle commands manually. A) you're going to need to be a gradle wizard, and B) why are you using an IDE in the first place? you've got gradle, you've got vi available. Bathe in the nostalgia because you'll have to anyways.
Do you like the idea of gradle? Do you use Netbeans? Stick with Ant, or Maven if you need external dependencies; you'll thank me later.

How to manually test compiled GWT project?

I am brand new to GWT. I followed the official tutorials, but on the Compilation section, I am getting completely confused by this:
Tip: If you launched the development mode server, you can run your application in production mode (after compiling it) by removing the gwt.codesvr parameter from the URL before loading the application.
I don't see this gwt.codesvr parameter anywhere, either in build.xml or in the devmode UI. What is meant by this? How can I test the compiled version of the application locally?
I don't know that parameter either.
I think the best way to start with GWT using Eclipse is by using the Eclipse plugin from branflake.
https://github.com/gwt-plugins/gwt-eclipse-plugin
On this github page a link is presented "GWT Eclipse Plugin Youtube Playlist". Follow that link and watch the videos. You will probably learn a lot from them.
When you run devmode, by default the codeserver will be on port 9997. You don't need the gwt.codesvr=... parameter in the URL unless you are doing something special.
When you start devmode, either from the command line, or in an IDE (eclipse), the launch URL that is given does not have this parameter in it. The documentation you refer to would relate to an earlier version of GWT I assume, and is a little out of date.

How do I get IntelliJ to load my .rvmrc for a non-ruby based project?

I have a Grails project that depends on a couple of ruby gems being installed. All of our developers have RVM installed and thus we have an .rvmrc file in our project directory to switch to the appropriate ruby and gemset.
Is there a way to have IntelliJ automatically read the .rvmrc even though the project needs the SDK to be set to a JDK?
Note: I've looked at the IntelliJ ruby plugin and couldn't see a way to get it to load the .rvmrc but not be the only SDK.
It's not possible, please submit a detailed request with the use case.

How do you use a Java project in your Android project in Eclipse?

I'm writing an Android application and there's some Java code in it that's somewhat sophisticated and therefore hard to verify the correctness of in the Android environment. I would like to run this code in a desktop environment where I have more tools with which to examine the output of this code while still using it in my Android application.
My attempted solution is to have three different projects in Eclipse. My Android project and two plain (non-Android) Java projects. One Java project has the sophisticated code that I want to use in Android and the other is a test program that verifies the correctness of the former project. The latter project has already been useful in debugging the former.
However, so far, my attempts to use the Java project in my Android project appears to work in the IDE but when I actually run the Android application, the NoClassDefFoundError exception is thrown whenever I try to access any of the classes. Obviously, that code is not being recompiled into the .dex file but why not?
I could go into detail about what I've done so far but I can't help but think that what I'm doing is a pretty standard and simple thing and there's a plain way of doing it, even though I can't find anyone doing quite what I'm trying. Can someone describe to me how this is done?
Luckily, I found the answer to my own question and I thought I'd share it here to help others in the same situation. It turned out to be very simple...
What I was already doing would have normally worked, which should have been a big clue to me since I have actually done this before, successfully. All you have to do is, under your Android project's Properties > Java Build Path > Projects, add the plain Java project to your "Required projects on the build path" and then under Properties > Java Build Path > Order and Export, check the checkbox of that same project in the "Build class path order and exported entries" list and everything should just work.
From within Eclipse, there's nothing else you need to do to get this setup to work. It's only when you're compiling from the command line that you need to build Java Jars and import them as libraries but I'm not doing that (yet).
Finally, this wasn't working for me because I just happened to be compiling my plain Java project under JDK 1.7 compliance, while my Android project was compiled under JDK 1.6. This is verified by the output on the Console pane, reporting "Dx bad class file magic (cafebabe) or version." This error message goes away when both projects are compiled under the same compliance level and, not coincidentally, the Android program runs properly.
Thank you to everyone who tried to help and I hope this answer is helpful to someone out there!
Would it not work if you made your other plain java project into an Android project and use it to monitor the output on the device?

first servlet/jsp application, just need some clarifications

I first tried the spring mvc tutorial using eclipse, but got a bit frustration and just did the first few steps using netbeans.
Netbeans, using a java web template, creates folders like:
/webpages
/webpages/meta-inf/
/webpages/web-inf/
/webpages/*.jsp
/source packages
/source packages/xxxx/xxx.java
/test packages/
/libraries
/configuration files
/configuration files/manifest.mf, context.xml, web.xml
The spring tutorial suggests to create:
/appname/
/appname/src
/appname/war (jsp's go here)
/appname/war/web.xml
/appname/build.xml
/appname/build.properties
/appname/war/WEB-INF/appname-servlet.xml
/appname/src/appname/web/HelloController.java
Now my question is, if I modified my netbeans project to mirror this structure, will it break the automatic build that netbeans gives me?
I downloaded the full version of netbeans, so I'm not sure if Ant comes with it or not?
When using the IDE's build/run, I guess I am using the IDE's build engine, can I force it to use Ant somehow or its better just to use Ant at the command line?
Here's the Spring tutorial reworked for NetBeans.
One option, becaue you have Netbeans, is to do this using Maven. Maven is an external build system (and much more) that netbeans can use. Create a new project and select a Maven project. Then create a simple Java web application (or a spring application if you want to dive right in). The directory structure that is set up will be correct.
As an Eclipse user, I'm not really good with NetBeans. But I do know that the "internal build system" is based on Ant and a pretty elaborate project framework Ant file.
You could dig your way through the maze of files and targets and fix the problem manually, but my suggestion would be to adapt the Spring tutorial's names to the directory structure NetBeans gave you.

Categories