Tuesday, December 27, 2005

Axis and caller IP address


MessageContext context = MessageContext.getCurrentContext();

if(context.containsProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST)) {
HttpServletRequest req = (HttpServletRequest)

if (req != null)
address = req.getRemoteAddr();

Monday, December 26, 2005

Hibernate: criteria, composite keys and joins

I had a hard time to make Hibernate to generate automatically a join between two tables, only because one of them had a composite key that was defined in a separate (inner) class. But after some time, I managed to make it work, by "faking" a property that is not updateable. I am not sure if it is a bug or a "feature". Anyway, a person just yesterday had the same problem and here is the thread, including my comment. Check the report.

Sunday, December 25, 2005

Saturday, December 24, 2005

Thursday, December 22, 2005

Eclipse Webtools: you can't remove a file

Just incredible, but Eclipse foundation is about to release the final 1.0 web tools project where you simply can't remove a file when the project is published in Tomcat. If that happens, it does not republish the project any longer. Something really bad for a developer using WTP.


Wednesday, December 21, 2005

Vida de Menina

A wonderful movie that was not popular in the movies. Tells a story about a girl in the end of 19th century from an English family that moved to Brazil to search for diamonds. Very sensitive, I recommend it highly. It is still available in a movie theather in São Paulo, but you can find it also in CineSESC today at 18h.

Remote Desktop

Just tried remote desktop client on Linux (rdesktop and also krdc) and it works perfectly to access Windows hosts. Give it a try, if you need to access any Windows hosts.

Sunday, December 18, 2005

Tomcat port monitoring in Eclipse Web Tools Platform (WTP)

For Eclipse WTP 0.7, that is the way to make the TCP/IP monitoring work. First of all, the monitors are defined in Windows -> Preferences -> Run/Debug -> TCP/IP Monitor. It is NOT the monitor menu from the Tomcat context menu. That ones are other monitors, don't mix them both.

In the TCP/IP Monitor preferences windows, define a HTTP monitor for your Tomcat port. In my case, I use the default one (8080), so I defined a monitor for localhost:8080 traffic (and set the local port to 6666, but it could have been any available port). Start this monitor.

After that, you may start your Tomcat. The TCP/IP monitor is independent of the start of your Tomcat (independent of being up or down). In order to monitor your web services, instead of sending your web services request directly to your Tomcat deployed web services, you must define a new endpoint (to the port you defined in the above step) and send your web services request to this port. That could be done by the JSP files generated by Eclipse or by the Web Services Explorer.

Finally, open the view "TCP/IP Monitor" and start monitoring all the HTTP traffic.

Note that you don't need to change your Tomcat startup parameters, define JMX monitoring and other complex stuff. Simply do the above steps and everything will be working.

What I still don't know is why Eclipse, during a bottom-up web services creation, complains that the Tomcat configuration does not support port monitoring. Actually, it does not even make the slightest sense for me, since it is a independent service. If you have further information about this, please let me know.

Wednesday, December 14, 2005

Hibernate Annotations

Just finished porting a project that used XDoclet to Hibernate Annotations. It was very simple and besides for two small problems, it worked pretty well. XDoclet didn't work as I wanted and I had already started changing the Hibernate mapping files directly. Now, it is much cleaner, sort of ready for EJB 3.0, and I don't have to generate mapping files (or change them manually).

One of the problems was that EJB 3.0 specification don't use the class qualified name, so you have an exception when you have two classes with the same name. I had to explicitly set the qualified names.

The other problem was that the cascade types for persistence in EJB specification is not as extense as Hibernate ones. I wanted a save and update operations cascade, but couldn't find this option, then I set the persist cascade type, but it didn't work. So, I had to use a hibernate specific annotation (@Cascade(value=CascadeTypes.SAVE_UPDATE)). Anyway, now everything is working fine.

Hard Work

Hard work is the refuge of those who have nothing whatever to do. - Oscar Wilde

Saturday, December 10, 2005

Life is a dream...

Life is a dream that keeps me from sleeping - Oscar Wilde

Friday, December 02, 2005

SMART monitoring tools

This week I had to fix a problem with a hard disk that wouldn't have its partition mounted. Actually, Linux would hang the mount command (the system call mount(), actually) and Windows would give me an error message telling that the hard disk is inaccessible.

After running some tools (testdisk and gpart), I found that the hard disk was acessible running dd and copying some sectors. Then I plugged it in my desktop, which had SMART monitoring tools and when I logged into KDE, I had an email telling me about a bad block in the disk. It was amazing. I learned how to use smartctl and other tools to run self-tests in the hard disk, but still didn't solve (I couldn't relocate the block as mentioned in the BadBlockHowto).

In the end, I ran Maxtor software that checked the full surface and fixed the bad block. Even then, I still wanted to try to access the partition. I checked the partition table with diskprobe (from Microsoft System Tools) and saw that the partition table was corrupted. I based that on the NTFS boot block information, what you are also able to see with this tool. Fixing the partition table size made me access the partition, but for some reason, windows tried to fix the filesystem and blew up all my files.

In order to try to recover some files, I ran PhotoRec, that was amazing at recovering most of the needed files. Finally, I ran a low level formatting and now the disk is back working.

I suggest that, if you run Microsoft Windows systems, you install SMART monitoring tools to warn you if something happens with your hard drive, before it is too late.