GWT Error Message “Asked for attribute parser of no type”

Example:

public boolean isCollapsed() {
	return panel.isVisible();
}

public void setCollapsed() {
	panel.setVisible(false);
}

Seen it? Despite the complicated and cryptic error message, the mistake is rather simple: the setter method is missing a parameter, i.e. “public void setCollapsed(boolean collapsed) {“.

Testing GWT Application in Virtual Machine

I am developing on a Mac, but to test my GWT applications for cross-browser compatibility in Internet Explorer I need to use Windows, thus I got Windows 7 installed using Parallels. Just by the way, to be able to test in different Internet Explorer version, I am using a pretty handy application called IETester.
But trying to access localhost with IE in the virtual machine did not work. I got a “404 page not found” error instead of seeing my app running on the local App Engine instance. Obviously, Parallels does not automatically forward localhost requests to OSX and maybe that is actually a good idea security-wise.
To fix the issue, you need to run Google App Engine on a public network interface, or in other words, bind the App Engine server to all available IP addresses. The down side: everybody knowing your IP address can see the GWT app now, but otherwise you are not allowed to access it in the virutal machine as from your OSX’s point of view, that Windows machine is “some other guy accessing from the outside”, too. To make GAE accessible from the outside, add the parameter “-bindAddress 0.0.0.0” when launching you local GAE. Using Eclipse you can achieve that by right clicking your project -> Run As -> Run Configurations -> Choose “(x)= Arguments” tab; add the option to the top most box titled “Program arguments” in the options area (e.g. before “-port 8888”).

The first part of the list of arguments should look something like that:

-remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -startupUrl GlocalUiPg2.html -logLevel INFO -codeServerPort 9997 -bindAddress 0.0.0.0 -port 8888 ...

Now, you can access you app using the OSX’s public IP address. (You can get to know your IP by having a look at the network preferences panel.) Launching GAE from Eclipse, you will see a different link (URL) in the “Development Mode” tab now, containing the public IP already. Using that one in, say, your Firefox on Mac, it will ask you now whether you want to allow the debugger access. That is also due to the fact, that you are now using a public address, so it is not clear to your local debug server, whether that request came from the same computer or someone else in the network.

Using the XML Parser in GWT

I tried using the XML parsing features of the GWT like that:

form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
	@Override
	public void onSubmitComplete(SubmitCompleteEvent event) {
		// One time upload only, to upload again, user needs to start the upload process from scatch – keeping it simple for now
		panel.clear();
		Window.alert(event.getResults());
		Document result = XMLParser.parse(event.getResults());
		...
});

But GWT kept telling me “No source code is available for type com.google.gwt.xml.client.Document; did you forget to inherit a required module?”. It turns out, you are required to explicitly add the XML functionalities to your project by adding following line to your ….gwt.xml file:

<inherits name='com.google.gwt.xml.XML'/>

Raises a question: What’s the point of AJAX (Asynchronous JavaScript and XML) without XML? Or in other words there is no AJAX without XML! So it’s up to you to add the AX part to GWT manually. What’s next?

GWT FileUpload: Adding Widgets to a FormPanel

If you build your first GWT form, for example something like that:

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel>
<g:FormPanel ui:field="form"> 
<g:FileUpload ui:field="uploadField" name="file"/>
<g:SubmitButton ui:field="submitButton">Upload</g:SubmitButton>
</g:FormPanel>
</g:HTMLPanel>
</ui:UiBinder>

And your console keeps telling you during runtime something like this: “java.lang.IllegalStateException: SimplePanel can only contain one child widget”. Instead of writing a long page of explanations and complaints like I did before, it’s simply like that:

“Just put all your widgets in a panel (like HorizontalPanel) and add that panel to the FormPanel.” (Jake − cf. comment below)

Thanks Jake! 🙂

GWT Does Not Load Module in Local AppEngine

The issue arose after I renamed the module file (ending with .gwt.xml) to better represent the module functionality. I also updated all relevant files in the project (search for files containing the old name to find them) accordingly.

Starting the application after that modifications ended up in an error (“[ERROR] Unable to find ‘<old module name>.gwt.xml’ on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?”) as the AppEngine tried loading the module by its old name.

Solution: Delete the launch profile for the project (by choosing “Run As…” -> “Run Configurations…” from the context menu).

Obviously the GWT does not check nor update the automatically generated launch profile thus you need to delete it to force the GWT to create a new profile from scratch taking the project changes into account. You might also adjust the profile according to the changes made, but deleting it is the safe and easy way.

First GWT Steps

Just started to work with GWT – a pretty interesting approach for web development compared to PHP or JSF. The whole Application engine is quite impressive especially allowing you to quickly test your applications locally by supporting automatic hot deployment after each code update.
One thing that took me a while was one of that “[ERROR] Unable to find ‘[some-file].xml’ on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?” errors. If you are sure the file is in place, I realized restarting the App Engine or Eclipse mostly solves that problem.

Getting Drupal’s Access Control Module to Work Properly

After setting up some content types — some public, some internal. I installed the Access Control module, set up internal content not to be visible to anonymous users — but without any effect.

After some research, but without success, I realized the *Advanced* section at the bottom of the Access Control tab for each content type. And now the magic trick: Increase the weight and you are done. So I guess the build in access management was fighting the Access Control module, so it is up to you to make your favorite module stronger by giving it more weight. — I doubt this is intuitive. Additionally, it is for sure difficult to simply find the tiny little select box down there in a section, which is by default folded.

How to Make Jquerymenu for Drupal Keep its State on Page Reload

While setting up the website for my new project “Glocal” www.glocal-project.eu), I came across the problem of finding a proper menu module. Something easy to use, stable and efficient in the same time for the complex intranet structure (therefore, sorry, but you will not be able to see my solution there unless you are a project member). Something with a high usability in the end. Activemenu is still quite buggy and DHTML Menue requires a double click to actually open a page — unbearable in a non-doulbe-click environment like the Internet — who is supposed to guess, that this menu requires a double click?? Leaving me with JQuerymenu.

First impression: perfect! Open and close branches by clicking (+) or (-) — view page by clicking menu item label. Even the few styling issues could be fixed easily by using CSS. But as soon, as someone clicks a label, the menu collapses to its default status. It does not remember its last status after loading a different page with the same menu.

Is this it? All module have critical downsides like this? I was quite disappointed! 🙁

But I taught JQuerymenu to remember!

As it is quite some code, I will not post it here directly, but added it to the tracker page for this “feature request” or you can download the two updated files (jquerymenu.js and jquerymenu.module) here and replace the once in your /sites/all/modules/jquerymenu folder.

But please be careful, it should be considered an alpha version, there are quite some weaknesses (see tracker page). Any feedback or suggestions are very welcome!

fixing flex VideoDisplay CuePointManager

I was creating a Flex application to show slides and a presentation video of previously recorded presentations. Accordingly, each slide should appear at a certain point of time in the video – calls for cue points!

As all slides and there appearance are stored in a text file in my case, I started adding cue points with ActionScript. But as soon as the video can be controlled with a slider, allowing to shift for- and backwards, the event handler “cuePoint” was not triggered any more. Thus, the slides where not changed correctly as the user jumps ahead, as the cue points between the previous and the new position did not cause and cue point event.

Finally I wrote AdvCuePointManager, inheriting from CuePointManager, but which can deal with jumping back- and forward.

Copy it to “<your source folder>/net/svenbuschbeck/flex/video” and use it as follows:

<mx:VideoDisplay cuePointManagerClass="net.svenbuschbeck.flex.video.AdvCuePointManager" />

how to install memchached 1.2.2 from source

I have installed an instance of memchached version 1.2.2 on one of our servers (Debian etch) today and to keep you from spending a whole afternoon, see my everything-step-by-step instruction below.

Memchached is a distributed hash map, which can be used for example to speed up any kind of web application, see website for details. In our case, we want to use it as temporary data store. I will report about the experiences in a latter post.

introduction

Always refer to this page for details, but I created a version with less text but including steps to really start from scratch.

All lines starting with # are command lines, i.e. you need to type into a linux shell.
Output of any kind is always surrounded by ” even if it is multiline output.

content

a. get libevent (needed to install memcached)
b. get memcached and verify installation
c. use and test memcached within Java with junit/ant

a. installing libevent 1.3

a.1. check for current version of libevent

a.1a.

Log in as root or get super user rights by calling su

# updatedb
# locate libevent

If there is output including “libevent1” and/or “libevent-1” (ignore package files like *.deb) -> a.1b, otherwise a.2

a.1b. removing old libevent version

# apt-get remove –purge libevent1
# Y

# updatedb
# locate libevent
Should now return nothing or package files only, i.e. you are ready for installation

a.2. installing libevent 1.3

a.2a downloading and unpacking

# cd /usr/local/src
# wget http://monkey.org/~provos/libevent-1.3b.tar.gz
# tar zxvf libevent-1.3b.tar.gz
# cd libevent-1.3b

a.2b. configuring

# ./configure
check the output, if it contains something like “configure: error: no acceptable C compiler found in $PATH” -> a.2c. otherwise a.2d.

a.2c. compiling

# apt-get install gcc

Redo a.2b.
I got output like “C compiler cannot create executables”, reading file ‘config.log’ did not help me at all. Googling finally did, as I found a forum entry, pointing out a missing lib.
So try this:

# apt-get install libc-dev

Redo a.2b.
If that did  not solve it… sorry … google on, there is no sense in going on without solving this issue. :-/

a.2d. make it!

# make && make install

If you get something like “-bash: make: command not found” -> A.2e, otherwise A.3.

a.2e.

# apt-get install make

Redo a.2d.

a.3. configuration

Press the Esc key as you read [esc] in the commands below.

# vim /etc/ld.so.conf.d/libevent-i386.conf
# i/usr/local/lib/[esc]:wq
# ldconfig

b. install memchached and verify installation

b.1. download, unpack and install memchached

# cd /usr/local/src
# wget http://danga.com/memcached/dist/memcached-1.2.2.tar.gz
# tar zxvf memcached-1.2.2.tar.gz
# cd memcached-1.2.2
# ./configure
# make && make install

After installing gcc and libc-dev in section a, this one went easily for me – if you skipped section a and run in problems here, please install gcc and libc-dev (see a.2c).

b.2. verify installation of memchached

b.2a. start memchached server

# memcached -u www-data -vv

Output should end with line “<3 server listening”. Perfect! 🙂

b.2b test server

I will refer to this shell in front of you as server shell below. Now, open another shell on the same machine, I will refer to it a client shell.

# telnet localhost 11211

You should see something like “<7 new client connection” on the server shell, switch back to client shell.

# set test1 1 10000 1
# a

You should see “STORED” on client shell and the two following lines on server shell
“<7 set test1 1 10000 1
>7 STORED”

Perfect!
You did it, your memcached is up and running 🙂

c. memcached and Java

I wrote a little test package using a Java client library for memcached from here, together with junit and ant. You can download it to have a look how simple using memcache is and to verify your installation with an included  junit test, automated with an ant build file.