Dec 09 12
I just invested 30min to find tools/libraries which allow me to use PHP scripts instead of Java on the server when the front end is GWT. There are various potential channels through which GWT and PHP can talk to each other. GWT RPC, ideally native or over JSON/XML would certainly be the most obvious choice.
My Internet search didn’t turn up a whole lot of useful stuff…
http://code.google.com/p/gwtphp/
http://code.google.com/p/gwtamp/
http://code.google.com/p/lacertae/
http://download.boulder.ibm.com/ibmdl/pub/software/dw/xml/x-gwtphp/x-gwtphp-pdf.pdf
http://angel.hurtado.googlepages.com/tutorialgwt2
Sep 09 22
In most programming languages the regular expression pattern to find the digit ’1′ surrounded by ‘;’ and other digits would be something like
[;\d]*1[;\d]*
So, the pseudo character class “; or digit” is matched zero or more times, then the digit 1 is matched followed by zero or more “; or digit”s. A few examples:
<property id="foo" value=";1;;;"/>
yet another regexp test with 1;;;;3xxyyzz...
well I think you get the picture with this ;;;;1 shizzle even if it's ;1;2;3; or 123
With Oracle SQL, however, it’s a slightly different story. \d is not supported i.e. not properly recognized as being the character class for digits. However, the character class 0-9 which generally is the equivalent to \d seems to be supported. In Oracle you could therefore use
[;0-9]*1[;0-9]*
As far as I can tell this is an undocumented feature. The official Oracle regexp documentation only mentions that it supports the regular POSIX character class [:digit:]. Watch out, the equivalent to \d is the whole expression [:digit:] and not just :digit:. I was first fooled by the extra [] around the character class designator… So, according to the documentation you’d have to use
[;[:digit:]]*1[;[:digit:]]*
Sep 09 19
Finally, the first version of the iCalendar factory is here!
It generates iCalendar objects and streams them as .ics attachments to your browser. URL parameters define all the attributes of the iCalendar. This allows to generate calendar entries from virtually everywhere.
Sep 09 11
Yet another software configuration issue that I wasted a few hours at today.
Environment
Apache 2.2.13 connect to Tomcat 5.5 with mod_jk (ajp13). Apache requires basic-auth for “/” i.e. for all URLs it serves. Just to be 100% precise, Tomcat runs as a WTP server “inside” Eclipse. However, the fact that it’s not a standalone instance has no effect to either the problem or the solution.
Problem
I noticed that request.getUserPrincipal() returned null in my Servlet filter although basic-auth in Apache was successful. By raising the mod_jk log level to debug (JkLogLevel debug) and looking at the mod_jk.log I could confirm, however, that mod_jk at least passed the remote user along in the request.
Solution
Set tomcatAuthentication=”false” for the AJP/1.3 connector in server.xml. The parameter is explained in the Tomcat connector documentation: “If set to true, the authentication will be done in Tomcat. Otherwise, the authenticated principal will be propagated from the native webserver and used for authorization in Tomcat. The default value is true.”
A thread from the tomcat-users mailing list archive helped a lot: http://www.mail-archive.com/users@tomcat.apache.org/msg55080.html. I didn’t initially find that through a web search because I kept looking for something like “principal null Tomcat Apache mod_jk” instead of “REMOTE_USER null”.
Aug 09 16
On some of my Eclipse workspaces to Galileo update failed in the SVN department (Subversive). Activating anything remotely related to Team/SVN features triggered an error. The workspace log contained:
!MESSAGE An error occurred while automatically activating bundle org.eclipse.team.svn.core (512).
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.team.svn.core.SVNTeamPlugin.start() of bundle org.eclipse.team.svn.core.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:805)
...
Caused by: java.io.StreamCorruptedException: invalid type code: 00
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at org.eclipse.team.svn.core.svnstorage.AbstractSVNStorage.loadLocationsFromFile(AbstractSVNStorage.java:551)
I tried to start Eclipse with the -clean option – didn’t help. Then I updated the Subversive SVN plugin and all connectors – didn’t help.
What eventually did help was to remove all org.eclipse.team.* folders in the workspace’s .metadata\.plugins folder.
May 09 20
Reading a book on the Sun Certified Java Programmer (SCJP) test is interesting and worthwhile, but the test itself is bogus.
Says who? I do…
I took the SCJP for Java 2 many many years ago and subsequently also passed the SCJD and SCWCD tests. Recently, I took the SCJP 6 upgrade exam. So, I feel I experienced a fair share of the Sun certification universe.
SCJP is known as the “API test” and its successful completion is the basis for all other Sun Java certificates. You’re expected to be familiar with many of the basic Java/OO concepts and APIs – sometimes down to the method signature. As such, passing the test shouldn’t require at lot of studying for any serious Java engineer since this is our daily bread and butter.
So, going through a certification prep book should hopefully not teach you a lot of new stuff (i.e. things you weren’t previously familiar with) but rather fill your know-how gaps. And that’s the interesting part. You might uncover surprising aspects of the JLS (Java Language Specification) which can be valuable.
However, it’s the way questions and code samples are formulated in the test that hamper the significance of its results. The time limit for the full Java 6 test is 210min (yes, that’s 3.5h!) and it consists of 72 questions. While you may finish a lot quicker it certainly is a primary test for your ability to concentrate in a test center. Furthermore, the majority of the questions contain code samples that are outright silly. You’ll see code that no sensible programmer would ever craft like that – even if the JLS allowed it.
You job would then be to find the missing ‘;’, the missing ‘static’ modifier, the illegal [] in an array declaration, the overridden instead of overloaded method, the illegal auto-boxing, the… you name it i.e. mainly stuff the compiler would report anyway. Finding the correct answer has become harder over the years because for most questions two of the possible answers nowadays are “Doesn’t compile” or “Fails at runtime”.
So, practicing for the test is not so much about learning Java as it is about getting accustomed to this type of questions and finding a (personal) strategy to tackle them.
All in all, I don’t think a Java test which a good Java developer might still flunk has a lot of significance. And passing this test doesn’t necessarily mean that you’re a good developer, either. Pity.
May 09 02
It was only recently after many years of Java programming that I found out that there’s no such thing as a “static inner class”. Such classes are called static nested classes.
-> http://www.coderanch.com/t/442837/Programmer-Certification-SCJP/certification/Members-inner-classes
Jan 09 25
After many hours searching the Internet for GWT widget libraries, analyzing them, and taking notes I thought I might as well publish my findings here. Feel free to comment and point out inconsistencies.
At the moment the market seems to be split into two segements:
- a few small or medium-size, low-key libraries with little activity
- the whole “Ext” gang
However things change very quickly, in a matter of months, and the end of 2008 saw the advent of a new-kid-on-the-block: SmartGWT.
Small, or medium-sized libraries
- GWT-SL/WL, a collection of server- and client-side tools. No real show case that demonstrates the power of the library is available. Last minor release in December 2008. Little SVN activity over the entire course of 2008.
- GWT Tatami, based on the DOJO JS framework. Show case isn’t impressive, but project is active. Continuous SVN activity. Road map for first half of 2009 available.
- GWTLib, continuous but little SVN activity. Offers hardly anything else but but table-centric widgets.
- GWT Tk, tbd
- Rocket GWT, tbd
- “vanilla” GWT, Google’s on-board GWT widgets. Nothing fancy, but clean and slick.
The “Ext” corner
A long time ago (think Internet time
) a guy called Jack Slocum built an extension to Yahoo’s YUI widget library named YUI-Ext. It evolved and became independent, Ext JS was born and with it a new company: http://extjs.com. The library quickly became very popular.
Once GWT was released people started writing widget libraries for it. Boston-based Sanjiv Jivan started GWT-Ext and based in on Ext JS. Darrell Meyer wrote MyGWT, a pure GWT widget library which shared the Ext JS l&f. It was voted #1 widget library one year ago.
In April 2008 things became very nasty an confusing when Jack Slocum changed the Ext JS license from LGPL to GPL thereby forcing GWT-Ext to stick with Ext JS 2.0.2 which was the last version available under LGPL. Furthermore, he hired Darrell Meyer who brought his MyGWT as a dower into the relationship. As a result, Ext JS published its own GWT widget library called Ext GWT. Now developers had the choice between GWT-Ext (full OSS with LGPL) and Ext GWT with a dual-licensing model. The GWT widget “war” (see references 1-5 below) turned many away from Jack Slocum’s Ext JS because they disliked the way the company treated the GWT community.
On November 26th, 2008, the game changed again when the GWT-Ext crew announced that they would no longer build major new features but instead be migrating to SmartGWT, a library created by GWT-Ext developer Sanjiv Jivan . SmartGWT 1.0 had been announced only two weeks earlier.
[1]http://www.jroller.com/sjivan/entry/my_response_to_jack_slocum
[2]http://pablotron.org/?cid=1556
[3]http://www.gwtsite.com/ext-gwt-gwt-ext-what-now/
[4]http://ajaxian.com/archives/to-gwt-ext-or-to-ext-gwt
[5]http://gwt-ext.com/license/
Sep 08 06
I struggled to update the content of a LONG column in an Oracle database with Spring JDBC. However, (in retrospective) this is more of a general JDBC problem than a Spring problem.
The problem first occured when I tried to use a regular SQL update statement to save a few thousand characters in that LONG field.
simpleJdbcTemplate.update("update mytable set content = ? where id = ?",
new Object[] { o.toString(), o.getId() });
Hence, I tried to execute the same statement in a SQL editor, Oracle’s SQL Developer in my case, and got “ORA-1704: string literal too long” as a feedback from the database. Further analysis revealed that the LONG datatype has been deprecated in Oracle ever since 9i. It can hold 2GB max. but you’re encouraged to use CLOB instead. Some poking around the JDBC pages at oracle.com revealed sample code that describes how to manipulate LONG fields: http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/basic/LongSample/Readme.html.
Now, whether the below code is optimized or not is yet to be seen. It solves my problem, though.
final LobHandler lobHandler = new DefaultLobHandler();
final byte[] contentBytes = o.toString().getBytes();
final InputStreamReader clobReader = new InputStreamReader(new ByteArrayInputStream(contentBytes));
simpleJdbcTemplate.getJdbcOperations().execute("update mytable set content = ? where id = ?",
new AbstractLobCreatingPreparedStatementCallback(lobHandler) {
protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
lobCreator.setClobAsCharacterStream(ps, 1, clobReader, contentBytes.length);
ps.setString(2, o.getId());
}
});
Aug 08 05
What to do when the following error pops up in Eclipse while saving a file:
Save could not be Completed
Reason:
Some characters cannot be mapped using “<your-encoding-here>” character encoding.
Either change the encoding or remove the characters which are not supported by the “<your-encoding-here>” character encoding.
If you’re certain that the encoding is correct an you didn’t enter any weired characters, you should copy/paste the content of the file to an external editor and see if it tells you where those hidden, special characters are.
On Linux and Mac you may as well abuse the terminal for that for certain character set. Just paste the code to the shell and see if you find anything unusual.