Archive for the ‘OpenSource’ category

Tomcat 5 not reloading changes in JSP

2011/07/24

Part of the beauty of JSP development is the easy of trying out the change. All you have to do is edit the JSP file, save it and reload the page. Yesterday I got caught by surprise by not being able to do exactly that.

I saw some strange behaviour in an EL expression used JSP tag. As it was nothing ATG specific, I decided to try it out in plain old Tomcat rather than full ATG application. So I located the instance of Tomcat 5.5 (I always have couple of Tomcats lying around) and being lazy, I decided to inject the change into out-of the box jsp-examples Web application that comes with it.

I picked a victim JSP to be modified (jsp2/el/basic-comparison.jsp), made my change, reloaded page – nothing. I must have forgotten to save the file, did it again – nothing. Weird. Maybe browser caching. Cmd-Shift-R – nothing. Tried different browser – it showed unchanged file as before. Definitely not a browser issue.

The most logical explanation would be that I am editing different file than reloading: so I verified that the JSP file I edited is indeed under WebApps, that correct version of Tomcat was started. It was. There was no context redirection in place but to be sure, I unzipped pristine copy of apache-tomcat-5.5.31.zip (I have couple of those around as well), copied the JSP there, started it – same thing.

Really weird.

Few more experiments showed that no change to any JSP page under jsp-examples was visible. Removing JSP page caused 404 error as expected, but as soon as the page was there, it reappeared in original pristine version.

At this point, I started to suspect there is something fishy with the jsp-examples application itself. And it was. Brief check of the web.xml showed that it is quite long (24K) and that it contains declaration:

<servlet>
  <servlet-name>org.apache.jsp.jsp2.el.basic_002dcomparisons_jsp</servlet-name>
  <servlet-class>org.apache.jsp.jsp2.el.basic_002dcomparisons_jsp</servlet-class>
</servlet>

....

<servlet-mapping>
  <servlet-name>org.apache.jsp.jsp2.el.basic_002dcomparisons_jsp</servlet-name>
  <url-pattern>/jsp2/el/basic-comparisons.jsp</url-pattern>
</servlet-mapping>

and suddenly it all made sense.

As long as the JSP file was present (Tomcat checks), it’s content was completely ignored and the request for /jsp2/el/basic-comparisons.jsp was served by COMPILED class /webapps/jsp-examples/WEB-INF/classes/org/apache/jsp/jsp2/el/basic_002dcomparisons_jsp.class – which of course did not contain any of the JSP file changes. When I removed file, Tomcat reported 404 a- the check for file existence comes before check for URL mapping apparently.

Moral of the story: being lazy causes one has to do more work but often learns something new. Had I created fresh new WebApp, none of these mappings were present and I would never realized what is Tomcat 5 doing behind the scenes.

Btw, in Tomcat 6 the mappings are gone and everything behaves as expected.

Although this is not technically a bug – but a feature – it is unfortunate that this optimization is used exactly in one application that can be used by newbie developer learning JSP for experimentation and not seeing it’s change can confuse the hell out of them. Especially when googling the issue will very likely sending him/her in completely wrong direction – suggesting reconfiguring Jasper, playing with valves and internals of Tomcat configuration.

Advertisements

How to show preview for CHM file in Leopard

2007/12/10

The CHM files (Microsoft compiled HTML help files) are often used for eBooks. They are readable on OS-X using excellent open source CHMOX application. If you want to get more useful preview in OuickView than the not very helpfull static icon, get this plugin.

Download here
https://sourceforge.net/project/showfiles.p…group_id=211847

How to install it: Unzip it, take the proper package for your system (the ZIP file contains several architectures, on modern Intel-based Mac’s you want to use x64), put it inside

/System/Library/Quicklook

and enjoy !

Big thanks to the developer Qian Qian – whoever that is.

Taking the pain off installation

2007/12/08

I was trying to set up an Oracle appliance – install the Oracle Express XE into a virtual machine. What (in my mind) should be smooth and straightforward process was something very different. I should have been forewarned warned after seeing the discussion … To make long story short, the installer failed on three different Linux VM’s I had available – because of unavailable dependencies, too small swap space etc, etc.

I am not picking neither on Linux nor on Oracle as there is no such thing as standard or predictable Linux installation. Even within single distribution (like Fedora 7) it is completely up to the user which subset of 1500+ packages will get selected during initial install. The installers are sophisticated enough to add missing dependencies, but nothing will prevent you not to install some seemingly unimportant package, without which the Oracle will not run. Given enough time, you can go and add the missing dependency (and it’s dependency and so on – up to the transitive closure of all missing libs), but that makes the 30 minutes installation more like 3 hours project.

What I ended up doing is loading the XP VM and the Oracle was up and running in less than 15 minutes. The Windows configuration is given (no user meddling possible) and the MSI installers do great job. The price to pay is the nagging feeling that each install may bring that huge binary blob called registry closer to it’s death … but in VM’s that is a non-issue.

There are two ways how to avoid issues like this. The option is go for pre-configured virtual appliance. Lots of appliances are available for VMWARE or for Microsoft Virtual Server.

If there is no appliance, next best thing is to go for “stack install”. Many software packages are now available bundled as stacks – e.g. LAMP/MAMP/WAMP stack (Apache with PHP and MySQL on Linux, Mac or Windows). There is good website BitNami offering many more stacks, including Liferay portal, Alfresco, Joomla, Drupal, WordPress or Ruby stack … This in combination with an “empty” VM should really ease the pain.

Reading source code considered harmful ?

2007/10/17

Every software developer will tell you how frustrating it is to trace problem in your application up to the point of third party library call (jar file or .dll / .so – make your choice) – and then have to resort to trial and error exploration, because you have no source code for that particular library module. For this very reason, most developers always prefer working with libraries or toolkits that comes with source code attached – if they have a choice. As a side benefit, these libraries are often free as a beer as well – but being able to understand the module is much more important as whether you have to pay license fee …

Couple of days ago there was an announcement about Microsoft publishing the source code for parts of the .NET framework 3.5. Few years ago such announcement would be a big deal. Now it was received mostly as “yet another me-too move on MS behalf” yawn – when many other really big companies are opensourcing many products, what options does Microsoft really have ? Robert Scoble calls it a “defensive move” and notes that as many times in last few years, Microsoft follows, rather then leads industry:

… this isn’t open sourcing .NET, just releasing the source. That’s even lamer cause the other two have actually open sourced and are accepting submissions from the community. Cool, but when you’re last to do something does it really matter anymore?

Indeed, what was done was not really opensourcing, only publishing the source – because license under which the code is available is none of accepted open source licenses (you are e.g. not allowed to modify the source). But regardless of the legalese details about the license, it is a good thing that developers are able to read the code and use it while debugging, right ? This was my first thought after reading the news. But as several people pointed out, you should be really careful before you look at the code. Steve Vaughan -Nichols even considers this to be an deliberate, malicious attempt to trap open source development – especially the Mono project.

At first it sounds crazy – why would Microsoft want to stop the Mono that exports the .NET technology to other platforms and this way helps to remove one of its main disadvantages against Java ? The one possible explanation – sounding a bit like conspiracy theory offers Kevin Hoffman (btw, it is really readworthy blog) in this post:

Microsoft is going to shut up a lot of whining Open Source people who claim that MS is just a big closed system. At First. If you ask me, the real reason for them releasing this source code is to make it more difficult for the mono project to create replicas of WPF, WinForms, and ASP.NET. With the source code available for all to see, it is far easier for Microsoft lawyers who might potentially engage in law suits in the future to claim that the people working on the Mono project stole their WPF code or their WinForms or ASP.NET code from the public BCL instead of building it on their own.

and also

What if, let’s just say, Mono suddenly became as feature-complete as the regular .NET Framework. You think Microsoft wants to start losing server business (where it makes all of its real money…) because a bunch of .NET developers decided to run Linux .NET instead of Windows .NET?

This may sound pretty wild speculation, but unfortunately just few days after release the source code, a patent infringement lawsuit was filed against RedHat and Novel. Not directly by Microsoft, but one cannot help to suspect some involvement from Redmond, considering the remark of Steve Ballmer that

People who use Red Hat, at least with respect to our intellectual property, in a sense have an obligation to compensate us ..

Now is this really a plot to derail open source project(s) – or just a symptoms that Microsoft became so large that two groups do not coordinate their steps and while one group (“techies”) trying to evolve their platform and push .NET adoption release the source, other group (“lawyers”) at the same time goes after money and very real threat of open source competition. Is it a malice or just an exceptionally bad timing ? Should we trust that it is actually OK to look at the source code ? Should we really trust a company that claims that open source software violates 235 their patents ?

Make your own conclusions – but note that Mono development team contribution policy explicitly disallows even looking at the .NET source code.

If you have looked at Microsoft’s implementation of .NET or their shared source code, you will not be able to contribute to Mono.

That may indicate something. Even if you never plan to contribute an open source project, consider what impact would have a potential legal dispute regarding intellectual property for your company, your product or your project – should it happen – and should you or your team have been using the source code in question, even if for debugging. IP lawsuits and very hard and very expensive and guess who is better prepared for a long legal fight :-).

As for myself, I will stay away from the hot source potato and use just the .NET documentation, however bad it is.
There is, after all so much great elegant and free source code to read (even in C#) …

Good book on Spring Framework version 2

2007/09/12

During my recent return to Javaland, I have noticed many improvements in newer releases of well established frameworks and toolkits, as well as many new ones. One such new release is version 2 of Spring framework. It is not really a hot news, because the final version of 2.0 is out for almost a year (October 2006), but it is new to me, because I spend pretty much all of last 12 months in DotNet, C# and OLAP worlds, with only brief visits to older Struts based, Spring-free Java projects.

Spring has an excellent documentation and great API comments, so after one gets over mental switch to IoC and AOP, there is not really strong need for reading anything else except source and documentation, bar saving some time. But because this books title – Building Spring 2 Enterprise applications – explicitly mentioned version 2 of the framework and because of Joel’s intriquing remark on how Spring 2 configuration extensions reminds him of good old ATG Dynamo, I purchased PDF version of the book from the Apress.

I am not quite done with the book yet, but I like what I have read so far. The chapter on AOP is probably one of the clearest explanations of benefits and principles of aspect oriented programming and differences against object oriented design. If you have chaos in the pointcuts, advices, advisors, aspects and join points, the chapters 3 and 4 are alone worth of $25 spent on the ebook.

Chapters 5 and 6 are dealing with data access and cover in detail using Spring JDBC helpers and extensions, that allow write clean, condense database code without worrying about pooling, connection management, resource management and cleanup and exception handling. It does not cover the alternative methods such as ORM (Hibernate, JDO) or iBatis.

There is one major problem with the book, that hopefully will be fixed soon: the book asks you to download the source code for the sample from the Apress site – and the site does not provide any source download. I have contacted the Apress tech support and got response that the authors of the book did not provide the code yet.

Without the code, the coolest feature of the programming books – instant gratification from building and running sample and then enjoying the beauty of design and discovering “how did the do it” – is lost. Even if you had time and patience to type in the examples, you could not, because the book contains only subset of the code (and rightly so). So I can only hope that the authors – Seth Ladd or Bram Smeets – will get in touch with Apress and fix it soon …

Update: as of Monday, Sept 24th, the source code is available for download.

Book review: Dreaming in Code

2007/07/02

Thanks to long weekend and more quiet time in last couple of days (Happy 140th Birthday, Canada!), I managed to read something else than Ruby-ism/Rail-ism. Among others, I finished the Dreaming in Code by Scott Rosenberg, a book promising to explain why software is hard.

It is pretty tough question to answer. The way this books tries to address it is following the story not very well known open source project named Chandler through it’s beginning over period of 3 years. Chandler was – and still is – developed by the OSAF – Open Source Application’s Foundation, founded (and financed) by Mitch Kapor, who was before the founder of Lotus Development Corporation and designer of the “Ur-spreadsheet” Lotus 1-2-3.

The Chandler project – unlike most opensource projects was blessed – or cursed – by very solid financial backing, which allowed to hire fairly large team for fairly long time, without worrying too much about running out of time or out of money. It also contributed to quite ambitious goals (“Outlook killer”) and to lot of time being allocated and spent on design and research projects (known also as BDUF – Big Design Up Front antipattern).

For me personally the most interesting discovery from reading the book was how similar can be the issues in two completely different projects that lacks clearly defined goal and requirements. In Chandlers case, the basic design questions were open for unhealthy long time: what is the platform for the repository ? Is it going to be peer-to-peer system or using centralized server ? What is the proper set of features ? How the user interface would look like ? I found these questions so familiar and reminded me of one other (non-opensource) project …

Throughout the book, you can find lots of quotations, observations and pieces of wisdom related to our profession collected from variety of sources – books, interviews, Web. For illustration few of them:

“Joy is an asset. It may well turn out that one of the most important effects of open source’s success will be to teach us that play is the most efficient mode of creative work” Eric Raymond

“In science, the whole system builds on people looking on other people’s results and building on top of them. In witchcraft, somebody had a small secret and guarded it … Traditional software is like witchcraft …” Linus Torvalds

“In any project that is introducing new technology or design … plan to throw one away, because you almost certainly won’t get it right for the first time” Frederick Brooks

“… we should train developers the way we train creative people like poets or artists…. They study great works of poetry. Do we do that in our software engineering disciplines ? No. You do not look at the source code for great piece of software. Or look at the architecture of great pieces of software. You do not look at their design …” Richard Gabriel

Conclusion: Maybe not as easy read as originally expected – mostly because of the length and level of details related to Chandler, but nevertheless worth reading by all means. If you are professionally involved in building software for living, this books outlines many issues of the field. You may even have feeling terribly strong deja-vu (if you are around for couple of years/decades). Or – if you are younger – it can be a great example of things to avoid 🙂

Recommended.

MSDN Documentation – the worst in class ?

2007/06/14

Did it ever happened to you that you were using some tool day after day – and never realized it’s pretty big deficiencies ? Until somebody, coming from different background pointed out what everything is wrong with the tool ? Before that moment of revelation, the issues were just inconvenience, but right after that they became real annoyance ?

Exactly this happened to me last week and the credit for pointing out what is wrong with MSDN documentation (and the “standard” .NET documentation format in general) goes to Joel 🙂

For developer using object oriented language such as C#, Java or Ruby, what you need on daily basis is to find information about a class, see its public interface,members, constructors, method signatures. Ideally, on single page, with possibility of drilling down to the details of a method and to a code example. You also very often need to see all implemented interfaces, have easy access to parent class and (in case of e.g. an interface inside a framework) to access the implementing classes or derived classes within this context.

Unfortunately, the Microsoft .NET documentation makes this simple task not exactly easy, pleasant or fast. As an example, lets take something really simple e.g. DateTime struct. In the documentation, information about this simple class are separated to 6 pages: datetime structure itself, Members, Fields, Constructor, Methods and Properties. If you would expect that with this devotion of low level categorization the particular page for e.g. Methods will give you all details about all DateTime methods, you are wrong. What Methods page gives you is just list of names, not even a method signatures – parameter types and return values are missing. To get this information, you must click through into the page dedicated to that method. If the method is overloaded (take e.g. omnipresent ToString), the Methods page contains only one name and only the next page gives you the signatures, linked to another page with details. See for yourself

picture-2.png

In addition to bad information structuring, almost every link causes full page reload.

Compare with how much more usable is the Java documentation: it is very easy to see all interfaces, methods, constants, parent classes, implemented interfaces in single page. The dated frames-based UI actually makes lots of sense and is (except AJAX based dynamic site) much better way how navigate the documentation.

With all that said, I am not surprised that the tools such as Reflector are so extremely popular in .NET world. It not only provides very useful debugging/inspection tool, but thanks to excellent and compact presentation of information about the class retrieved from reflection, they are the fastest way how to get meaningful information on core classes API. Other than Reflector, the other fast way how to get information on .NET core library details is Google search.

Try for example how fast you can access a documentation for particular class starting with Google search – let’s take e.g. WebConfigurationManager. Google search returns blazingly fast (as always) – with the MSDN page as first hit. Now compare how fast you will get the same information starting from MSDN home page, (which is btw, advertising ‘new and improved search and navigation‘). Your mileage may vary, but I usually see 3-8 seconds delay in search response (compare to <0.5 sec for Google). Few seconds seems like no problem, but when you do it all the time, it easily becomes pretty annoying. Even more so when you realize that Google is searching WHOLE WEB, with content they do not own or control, only index and rank, whereas MSDN search is searching MSDN data repository, which is – however you measure it – by many orders of magnitudes smaller and Microsoft fully controls most of it’s content.

Why cannot the largest and most powerful software company create documentation that is useful and usable ? Even the documentation for the OpenSource Mono project (port of .NET to Linux and other platforms) is *much* better than the original. See the class DateTime there for comparison: the menu is dynamic and does not reload page every time you click on a link, the methods have full signatures and everything is on single page with local links and only details are on second level page.