PDA

View Full Version : Migration issues



Feltros
29 Jul 2009, 12:17 PM
Basically, I have a simple page with a drop down box. I have a listener attached to check when it changes and some changes to the page happen from there:
Basically



typeOfPolicy = new ComboBox<PolicyType>();
typeOfPolicy.setFieldLabel("Type of Policy required");
typeOfPolicy.setDisplayField("PolicyType");

typeOfPolicy.addSelectionChangedListener(new SelectionChangedListener(){


@Override

publicvoid selectionChanged(SelectionChangedEvent se) {
}


publicvoid handleEvent(BaseEvent be) {
handlePolicyTypeChange(typeOfPolicy.getValue().policyType);
}

});
typeOfPolicy.setStore(policyStore);


This works fine when I run it in the gwt shell (which i'm still running via com.google.gwt.dev.GWTShell despite the warnings it gives since I assume its legacy supporting for the time being and i'll change when its required of me :P) but when I click the compile button, everything loads fine but the listener won't do anything. Even if I set the method to just do Info.display("blah","blah"), it fails. No errors, just nothing.

I'm guessing i've misconfigured something somewhere (or running it via com.google.gwt.dev.GWTShell won't let me compile properly?) so has anyone come across this or have any clue where I could even begin looking for the issue? There used to be logs in the Tomcat directory when running a compiled version but I can't even find these anymore.

My migration was from gwt1.5.3 to gwt1.6.4, gxt1.2.3 to gxt2.0

(I would provide working code, but it'd work for you and thus not help in replicating my issue at all :P)

Feltros
3 Aug 2009, 10:00 AM
*Bump* Anyone even an idea of where I can look for what is causing this error?

micgala
4 Aug 2009, 12:50 AM
You could, as yourself suggested, try not using GWTShell for compiling.

Just compile externally and see if you still have the problem.

Colin Alworth
6 Aug 2009, 3:02 AM
If you are using GXT 2.0, you need GWT 1.6, and I believe that using the GWTShell is deprecated in favor of the 1.6 class HostedMode (and likewise GWTCompiler to Compiler). There are breaking changes between 1.5 and 1.6, and using the wrong compiler may demonstrate them...

If memory serves, one of the big changes was how events were handled, suggesting that switching to completely using gwt 1.6 might fix this...

Feltros
28 Aug 2009, 11:13 AM
Where I am now with this issue:

I am now utilising com.google.gwt.dev.HostedMode with parameter -startupUrl com.TravelInsure.main.Root/Root.html com.TravelInsure.main.Root

When I click compile it doesn't bother to create a WEB-INF directory or place my compiled classes in it. I believe this is the stem of the issue really and why the page will load but with no functionality.

When running in hosted mode it returns the error:
[WARN] Module declares 1 <servlet> declaration(s), but a valid 'web.xml' was not found at 'C:\somedirectories\workspace\TravelInsure\war\WEB-INF\web.xml'

If I manually create a WEB-INF directory and a web.xml for it (along with the lib directory) it destroys it upon compiling (and running normally) and returns the same error.

I'm assuming if I compiled and created the WAR manually it'd all work, but this is getting a bit annoying when attempting to test various deployment versions.

My directory structure is in the old style: (hence the long winded parameter I pass to hostedmode)
src/com/TravelInsure/main -
client - Model, MVC, widget, SQLenums folders, Root.java is in here
public - gxt, images folders, Root.html is here
server - ServerImpl.java etc here.
Root.gwt.xml

I don't really want to change the structure of this, but are there any parameters I can pass onto HostedMode to make it work properly when compiling? It seems bizarre it'd run fine but fails to find the class files when compiling. (which are located in the bin folder next door to the src folder at the top level of the project).

Colin Alworth
28 Aug 2009, 11:13 PM
When I click compile it doesn't bother to create a WEB-INF directory or place my compiled classes in it. I believe this is the stem of the issue really and why the page will load but with no functionality.

When running in hosted mode it returns the error:
[WARN] Module declares 1 <servlet> declaration(s), but a valid 'web.xml' was not found at 'C:\somedirectories\workspace\TravelInsure\war\WEB-INF\web.xml'

There has to be another error here, because this log message is a warning, not an error - at least one my my modules also exhibits this message, and yet it still compiles and runs properly. Please check your compile logs or gwt console logs again, and see if perhaps there is another error?

Feltros
29 Aug 2009, 8:31 AM
No, sorry I think you misunderstand.

In hosted mode it displays that warning, and runs fine.

In compiled mode it displays no errors (or in the logs) but fails to put the classes in with web-inf, so the project displays the 1st page in a browser fine but it has no functionality. (Or errors in any log)

Colin Alworth
29 Aug 2009, 8:57 AM
A lack of build errors suggests that something else is wrong - GWT is pretty good about being clear about the issues - are you seeing the .nocache.js and .cache.html files generated as they ought to be?

If so, the build is going off properly, and something in either your server (or other build pieces) or your browser is killing it. Do you have firebug, and can you check that the files I mentioned are properly downloaded by the browser? We use a custom server that we can't test with the GWT hosted jetty instance, and every once in a while the build messes somehow and forgets to copy the module javascript...

Hope this helps.

Feltros
29 Aug 2009, 8:06 PM
A lack of build errors suggests that something else is wrong - GWT is pretty good about being clear about the issues - are you seeing the .nocache.js and .cache.html files generated as they ought to be?

If so, the build is going off properly, and something in either your server (or other build pieces) or your browser is killing it. Do you have firebug, and can you check that the files I mentioned are properly downloaded by the browser? We use a custom server that we can't test with the GWT hosted jetty instance, and every once in a while the build messes somehow and forgets to copy the module javascript...

Hope this helps.

Just did a compile, and yes the .cache.html and .nocache.js are being generated correctly. Inside the war folder however theres still no web-inf directory, or .class files. Have tried deleting the whole war folder and allowing it to be completely re-generated in case its some kind of write issue.

GWT reports:
compiling module com.Blah.main.Root
- Compiling 5 permutation (succeeded)
- Linking into war (succeeded)
- Compilation succeeded 80.047s

I don't have firebug but I would assume since the page loads properly the correct permutation is being loaded fully.

Am I supposed to be compiling directly into web-inf/classes via eclipse? As I believe this could sort the issue potentially but it doesn't really feel like the right way to fix this (And I don't want even more issues when I migrate up to the next version again).

Can I just confirm the correct structure of the war file should be:
war/com.Blah.main.Root/ (containing .nocache.html, Root.html, .nocache.js etc)
- gxt (containing gxt gifs and js files)
- images (which is a folder located in my src/public/ directory containing all my images obviously)
- web-inf (containing web.xml and folders mentioned below)
- - classes (inside of which is com/Blah/main/etcetc compiled .class files)
- - lib (containing .jar libraries)

And GWT 'should' be moving my class files from where they are compiled by eclipse in a seperate bin folder into the war file on hitting compile right?

Colin Alworth
30 Aug 2009, 5:35 AM
I can't speak to much of the build process, as I use maven for all of my building work, and I get all of my class files generated properly using that... But generation of class files shouldn't affect testing the web mode - in fact, if hosted mode works (and you have any server components at all) then your class files are properly generated, else the server wouldnt be able to find the classes it is supposed to work with...

For what little work I used to do before we picked up the gwt-maven plugin, I would highly recommend using the google plugin for eclipse. And try out firebug - nothing happening in web mode either indicates complete lack of error handing (you do have an exception handler registered, right? and you don't silently catch exceptions?) or that the browser never even found the javascript it is supposed to work with. In my experience, it is always the latter.


And GWT 'should' be moving my class files from where they are compiled by eclipse in a seperate bin folder into the war file on hitting compile right?
No. GWT works only with the raw .java source files, and completly ignores the .class files. It only assumes that your build process is configured to produce classes as needed (and for many projects, the same source is used for client and server, so the same src/ is compiled once for both sets). Again, you are responsible for your own java compilation, as your server code is the only thing that will use it. Take the case where people are using python based servers with their GWT client code - they don't care about .class files, so generating them is a waste of time.

Check that your browser can even find the js files (and perhaps check your own RPC server logs) and check how you are building your client/server classes.

Feltros
31 Aug 2009, 9:12 AM
Thanks massively to everyone who was helping me with this issue, I have now solved it amazingly!

It was a combination of about 30 things going mental and not a single error from GWT showing anything.

The largest part of the error turned out to be my unparameterised selectionChangedListener's which were working in hosted mode (legacy support? hmmmm) but actually don't work at all when compiled. I had all my buttons and scrollers on page 1 of my site set up with unparameterised listeners and not a single one worked (leading me to believe none of the .class files were being loaded - in reality they actually were but never being run because none of the listeners were correct - hence no errors :S)

My only final issue is the correct parametarisation for:


Slider slider = new Slider();

slider

.addListener(Events.Change, new SelectionChangedListener(){


@Override
publicvoid selectionChanged(SelectionChangedEvent se) {
// TODO Auto-generated method stub


}


publicvoid handleEvent(BaseEvent be) {
handleSliderChange(slider.getValue());
}

});


Now it should be new SelectionChangedListener<D>(){ public void selectionChanged(SelectionChangedEvent se) {} } and handleEvent shouldn't even be there, but what should the D be?

Will leave the question here for a day or two then make its own topic if no answers since its so far detached from the issues raised here :) Thanks everyone! (Firebug helped a fair bit in tracking down the error to line 385 of a minimified .js script lol, made me start thinking about things at least)

Colin Alworth
31 Aug 2009, 9:22 AM
Now it should be new SelectionChangedListener<D>(){ public void selectionChanged(SelectionChangedEvent se) {} } and handleEvent shouldn't even be there, but what should the D be?


Will leave the question here for a day or two then make its own topic if no answers since its so far detached from the issues raised here :) Thanks everyone! (Firebug helped a fair bit in tracking down the error to line 385 of a minimified .js script lol, made me start thinking about things at least)


385 lines? bah, just a small start.... ;)

The problem is that you are using a SelectionChangedListener - the event being fired is not about selection, but about data changing, so it should be something like Listener<FieldEvent> or some superclass of FieldEvent. Though I am amazed that somehow hosted mode didnt trip over a bad cast like that...

Feltros
31 Aug 2009, 1:46 PM
I just chose what eclipse recommended me, and the methods it autoimplemented, and hostedmode likes it fine and works with it but compiled certainly doesn't and doesn't return error either. Will have a go with that tomorrow, thanks.

Colin Alworth
31 Aug 2009, 9:14 PM
Eclipse can be a little stupid sometimes - the method signature for addListener is

public void addListener(EventType eventType, Listener<? extends BaseEvent> listener)
meaning it will take any object that implememnts Listener (and note that Listener itself is already typed on BaseEvent)

public interface Listener<E extends BaseEvent> extends EventListener

So Eclipse will just grab anything that you have used recently that it can find that fulfills the method signature correctly. I have a field listener that I use to trim whitespace that eclipse tries to force in when I add a listener for bind events - the signatures are close enough to cause problems. It is also worth looking at the class that is sending the events - GXT has good javadoc that describe the events that can be sent and what type of BaseEvent subclass they might send as data.

And I'd be curious if anyone else has any ideas as to why hosted mode didnt break but web mode did, but here's mine - hosted mode runs off of the JVM, where the generic params are all erased, and so all instances are treated like BaseEvent. Once compiled, maybe the javascript version does a little more work to cast the objects to what they are treated as, and so it fails on the cast?