Danny Angus

Vague but Dire

[blog home] [web home] [flickr] [twitter] [contact me] [subscribe by email]
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Tuesday, April 22, 2008

OMG - java weenie goes LAMP!

Well yes, I've spent the past week or so trying to apply a load of stuff that I want to do from the world of Java to the word of LAMP, or php to you and me.

I should also say that before I embarked on my career as a java-weenie I'd spent four years man-and-boy programming perl, so the php itself wasn't any kind of hurdle, my challenge has been to see if I could introduce all of the application architecture patterns which I know and love from Java world.

So what things have I uncovered?

1/ IDE - the Eclipse PDT, with zend debugger, is excellent. Not quite as robust as Eclipse java tools, there are still some flaky moments and the code completion can't always work out what class $this->thing actually is, but that is all made up for and more by subclipse and the zend debugger. Keep up the good work PDT guys. For others who want to investigate I followed these instructions.

2/ OOP Yes, PHP5's OOP is pretty decent, but (obviously) it is weakly typed which I find annoying coming from a strongly typed background. And surprisingly I had to write my own classloader, which was fun and instructive and it seems to work fine, but why? I haven't started using exceptions yet, hopefully they'll be familiar.

3/ ORM Oh yes, this is cruicial to my plans Mua hahaha, and it seems so far that the excellent Doctrine ORM is well up to the task, if not quite in the same league as Hibernate.
One thing thats puzzling me is where the transactionality has gone, but perhaps thats because I haven't read the manual fully yet.

4/ Logging, oh wow- log4php - in incubation at Apache this is the php sibling of log4j it works fine and smells very familiar.

5/ Unit testing, haven't tried it yet but while I was talking through my researches with the guys who will have to suffer the consequences of my decision making they said phpunit, which certainly sounds like the right thing!

6/ MVC I'm not keen to adopt a big framework wholesale, for reasons which I can't be bothered to explain now, but its been relatively painless to knock together an OO MVC framework using Doctrine, homespun controllers, and Views generated by the Smarty template engine which at least lets us bind, using simple {$my.attribute} syntax, display elements to objects from the model, not sure how far Smarty will suit at this early stage but its looking promising for now.

I have no stirring conclusions at this stage, but its looking good, stay tuned and I'll let you know how it all turns out.

Wednesday, March 19, 2008

Google Summer of Code 2008 - Apache James email Projects

The Apache James team have submitted two proposed student projects for Google Summer of Code 2008, you can read them here.

In brief they are:

1) Develop a VERP Mailet to allow James to write VERP modified return addresses on outbound messages, and an inbound mailet/matcher to identify VERP bounces and invoke configurable "do something" code.

And 2) James' provided mailing list manager is fine for small closed groups, but lacks the functionality of a more robust MLM, the project is to add some all or more of the following features subscriber and message moderation, double opt-in and bounce handling.

Spread the word, James needs Students!

Saturday, February 02, 2008

Storing MIME email in JCR with James and Jackrabbit

I read a post on the James dev list that mentioned this blog posting which goes into some detail of the method Jukka Zitting used to create a JCR message repository (using Apache Jackrabbit) for Apache James in the James sandbox. I thought this would be a good excuse to mention that work here.

I find it an exciting idea because it takes the inherently richly structured MIME messages and stores them in a way that can cope with the full richness of the structure including the mixture of content types, the recursion of nesting, and the mixture of encodings and character sets supported very well by the totally fan-bloody-tastic MIME spec. In fact JCR is much more aptly suited to storing MIME structures than a traditional RDBMS or the filesystem because it is flexible in the right ways and can also manage the metadata.

The expensive act of parsing the MIME message is only carried out once, when the message is exploded into the store, and thereafter the whole message, or just specific parts of it, can be passed around as a serialisable reference to a location rather than as unserialisable streams, or big byte[]'s.

What's more any system that can manipulate the JCR repository can become involved in the life of the messages, for example web mail stops being a web interface for traditional mail protocols and becomes a first class citizen, web applications built straight ontop of the repository.

Add Web Services and the repository can participate in CRM systems which use WS to integrate channels and systems into a single Agent Desktop and a Single Customer View.

The fact that Jukka made the James JCR repository (with an html viewer as well) in a few hours at Apachecon EU is testament to the suitability of JCR, the extensibility of JAMES and the value of the Hackathon as a tool for innovation.

Have a look at the code here or subscribe to the server-dev@james.apache.org list to discuss it.

Tuesday, October 23, 2007

ADB and HBM

We here can cope with using JAXB generated models with hibernate HBM.XML mapping. But Colleague X, working with Axis 2, is struggling to find a way of using ADB and Hibernate together without having to write converters or delegates or whatever by hand.

I know one of you knows how to do this, after all how unusual can it be? So please... Send Help to the usual address (danny at apache dot org)!

Monday, September 10, 2007

J2EE application development


Aaron Farr posted this about the frustration of modern web design, including an exellent pie chart of the time breakdown. Well colleague X has sent me an updated version showing the breakdown of time spent developing tapestry/spring/hibernate J2EE web-apps.

Tuesday, May 15, 2007

What Future for Apache Jakarta?

Apache Jakarta is a project which has spawned many significant landmarks in open source Java; Ant, Tomcat, Jakarta Commons, Maven, and Struts amongst many others.

In years gone by it was a widely known and respected "brand" which working java developers trusted.
I trusted it, I got free stuff to help me with what I was doing but more important than that I knew that I could make Jakarta my first stop if I had a problem that needed solving.

However the world moved on and two things happened:

Firstly the ASF Board indicated three years or so ago that the Members weren't happy that Jakarta should be as large, powerful and autonomous as it was fast becoming, and so after much debate the agreed direction was clear, Jakarta sub-projects would be encouraged and supported in becoming top level projects of Apache, deflating Jakarta and restoring balance and oversight. Most of them have been promoted in the intervening years, and only a few die-hards remain, but this is changing and they are now preparing to leave as well.

Secondly the Java ecology has changed radically in the past few years. Not only through the normal maturing of ideas and the distillation of best practice, but also from the introduction of resources like java.net, the entry of other trusted (often commercial) players into the open source arena, and changes to the JCP which have resulted in JSR's actually completing their life cycle. All of these have significantly enhanced the pool of "trusted sources" that java developers can go to.

So as we now approach the end of the reorganisation of Jakarta we're faced with a big decision, should we consign the brand to the history blogs? Or does it continue to represent something valuable to Java developers?

Successful brands are hard to create and easy to destroy, if we act without thinking about it we might be making a big mistake. On the other hand I am too close to it now to know whether or not this brand still means something to people who are, like I was then, the geek on the street.

So Please let me know whether you think the Apache Jakarta brand is worth preserving, or not worth loosing too much sleep over.

Record your opinion: (If you can't see the drop down list below click here)
  • If you think the brand should be retained choose I agree.
  • If you think there is no longer a need for it in today's world choose I disagree.



Click here to view the votes so far.

Or you can comment here, say something on general@jakarta, or blog about it and link your posts to this one.

Friday, May 11, 2007

Friend or FUD?

Jonathan Schwartz is quoted by Tim O'Brian as having said "There is nothing at all right now stopping Apache from shipping Harmony. Nothing, they are free to do so, the code is available they can distribute it wherever and whenever they want…We’re very, very, very focused right now on the GPL community."

I have to ask whether he (as a busy guy with lots of PR plates to keep spinning during conference season) has just misunderstood the issue, or whether this reveals an attempt to divide the OSS community and reduce their influence over Sun's baby.

I hope that Mr. Schwartz just missed the point here, which is that the Apache Software Foundation (ASF) want to be able to give their users software which passes certification, and
the use of which is unrestricted.

The alternative implication is much less pleasant.
It's well known that the ASF and the Free Software Foundation (FSF) (publishers of the GPL) have repeatedly failed to find enough common ground to achieve compatibility between their licences, and now that the ASF has come out publicly against some of the IP restrictions around the JCK (the TCK for JSE) Sun seems to be moving towards the GPL. Is it coincidence that the FSF's GPL prevents downstream users from benefiting commercially whereas the Apache Licence deliberately allows anyone to profit as long as the code is "free" (free as in speech, not beer)? I really hope not, that would just be bad for everyone.

**NB I'm not trying to score any points here, just saying it as I see it, if I'm wrong post a comment. **

Thursday, May 10, 2007

Apache is Java Community Process Member of the year

The JCP have voted the Apache Software Foundation as "Member of the year 2007".
In the light of the recent waves Apache has been creating around IP restrictions on test kits this is either very ironic, or something of a show of support from the other members. In either case well done to the Apache folks who participate.

Geir Magnusson Jr. told ASF Members,

"It's a combination of our broad and deep participation in
expert groups, our numerous implementations of specifications, and
our activities as a EC member, where in our drive to bring our values
of transparency and openness, we push the JCP out of it's "comfort
zone", in a constructive and progressive manner that is good for the
ecosystem as a whole."

Wednesday, May 09, 2007

Mailet Site goes up

Thanks to everyone who helped, we now have a site for the Mailet API.

Tuesday, May 08, 2007

Architect tools

Steve Loughran took the piss out of architects during the lightning talks at Apachecon, claiming that we (and when I say we I was the only mug to put my hand up!) worked only in M$ Word and PowerPoint. Well, I'm glad to say that I put him straight on that one, his blog post on the subject which proposes "ArchitectUnit" now acknowledges that I was right all along and there is a lot more to the job than that, namely Visio diagrams as well. Hopefully we can now expect to see our efforts recognised for the true value they add, with not only ArchitectUnit but why not an ant task to turn our priceless hard work directly into fully operational systems? Thus avoiding all the opportunities for mistakes to creep in during the so called analysis and development phases of a project, and highlighting the fact that innacurate claims in the vendor marketing literature on which we base our product selections is the *real* reason why IT projects so often fail to live up to their promises. ;-)

Monday, April 30, 2007

Apache JAMES Server 2.3.1 released

The Apache JAMES project is happy to announce the final version
of JAMES Server 2.3.1. This is a bugfix release. You should upgrade as soon as possible.


JAMES Server 2.3.1 can be downloaded at:

http://james.apache.org/download.cgi


The bugfixes / tasks since 2.3.0 are:

* Remove ordb.org from docs
* OOM caused by unbounded cache in InetAddress (was James leaks memory slowly)
* sendmail.py doesn't handle multiple TO-recipient
* sendmail.py crashes on line "from_addr = os.environ['USER'] + '@' + socket.getfqdn()"
* ServerConnection doesn't properly handle the TCP/IP backlog
* Search & Fix broken links on the new website
* MBoxMailRepository.remove(String key) causes ClassCastException
* Failure to correctly set mail.smtp.localhost leads to mail servers
being listed on cbl.abuseat.org and mail being rejected by Spamhaus.
* MailAddress not check for valid syntax if new MailAddress(user, domain) is used
* sendmail.py use localhost to connect to local smtpserver. We should use 127.0.0.1
* exporting variables using build.sh on solaris breaks
* James will not start if there is directory with too many files and folders in the repostiory path
* python/sendmail.py is not added to the binary distribution package

* Update license headers to follow the latest ASF requirements as of November the 1st
* Merge 2.3.0a1 to 2.3.0 final releases on JIRA
* Upgrade dnsjava to 2.0.3 when available
* Add documentation for the dns ttl issue
* Make sure our container use an expiration for cached dns data


For more information see the changelog page.

Apache James Team

Tuesday, April 17, 2007

Apache James at Apachecon US 2007

Well the Call For Papers for Apachecon US 2007 is now open:

  • The Call for Papers is now open for ApacheCon US, to be held November
  • 12-16 at the Peachtree Westin, Atlanta. The conference will consist
  • of two day of tutorials (November 12-13) and three days of regular
  • conference sessions (November 14-16).
  • Please log in to the website at http://apachecon.com/html/login.html
  • to submit your proposal.
I've submitted the talk on James which I'm giving in Amsterdam on May 2nd.

JSR-000313 Java Platform, Enterprise Edition 6 Specification - Withdrawn

A couple of days ago I got this email on the JCP interest list:

This JSR seems to have had attracted some positive interest not least, I suspect, because the stated goals included:
  • "the Java EE platform has fostered a vibrant community and marketplace for additional technologies, frameworks, and applications that work with the platform. Some of these provide facilities that are missing from the platform. Others provide alternatives to platform facilities. A major theme for this release is to embrace and support those technologies as part of the overall Java EE landscape, while also continuing to simplify the platform to better target a wider range of developers. To that end we propose two goals for this release - extensibility and profiles"
This seemed to indicate that JEE was about to mature into something which could accept some competition, allow more freedom for architects to build things they way they want to within JEE, and simultaneously resolve the obsolescence and bloat which was becoming apparent by providing alternative distributions based on the needs of targeted application types, e.g
  • "... the first version of a Java EE Web Profile - a subset of the Java EE platform targeted at web application development.".

It seems from the vote comments that this has been a victim of concerns over IP, For example SAP said:
  • "We will need to get more clarification for the new proposed license terms which seem to require a license fee per Java EE profile. If this means a fundamental change in the Java EE licensing model, SAP may decide to vote "NO" on this JSR based on the proposed license terms. "
and it seems in part to have been fuelled by the ASF's position on the Java SE TCK, Red Hat said:
  • "The spec lead of the EE6 specification has confirmed that the EE6 TCK would contain no "field of use restrictions", as originally raised by Apache with regard to another JSR (i.e. the SE TCK licensing). That is a good thing.

    However, in the absence of an explicit JSPA rule that would forbid such field-of-use restrictions, we will remain worried that a similar issue might resurface anytime, for any JSR.
    "
We all know that there's a big gap between intention and execution, and JEE 6 might not have been the universal panacea it hoped to be, but take a second to join me and lets cross our fingers and hope that the value of the changes proposed in this JSR are not lost just because we're having another IP turf war.

Monday, April 16, 2007

Still having trouble with ClassCastException?

Photo Sharing and Video Hosting at Photobucket
ClassCastException is still the most common search term that sends people to this blog, although "swim across the atlantic ocean" is about to overtake it thanks, I can only guess, to fans of Detroit Roller Derby (don't ask ...).

So to be helpful to those readers who are not from Michigan I thought I'd clarify things as much as I can, be warned though it isn't much.

Because Sun's spec doesn't enforce a requirement for ClassCastExceptions to show the classes of the objects which you are trying to cast (see this earlier post) it is normally only possible to make any sense of a ClassCastException by reading the source code, and you really need to attach a debugger and examine the object that your programme is trying to cast before you can start to figure out why it won't work.

If your object seems to be of the correct class the problem is probably related to ClassLoaders, this article explains succinctly why that happens.

Sometimes, if you're smart, you can make a smart guess.

Sometimes (more often if programmers will take my advice) the exception message will tell you, but don't count on it.


If you are seeing a ClassCastException being thrown by a product you have installed then you need to check its documentation.

If the documentation doesn't help then you need to get help from the people who wrote it.

Friday, March 09, 2007

James - Google Summer Of Code 2007

Google Summer of Code '07 will soon be accepting applications from students.

If you have an idea for a student to work on as a James SoC project send it to general@james.apache.org or post it on this wiki

If you are a student and want to submit an application to google about James, please discuss it on the general@james.apache.org mailinglist as well.

Not only do we have a lot of knowledge about what James needs (and doesn't need) we also have two years of experience of evaluating the proposals and experience mentoring two former SoC students.

We can help you to polish your application, and introduce you to our project.

James missed out on a SoC '06 student so I want to make sure we do everything we can to get good proposals and have them accepted.

Thursday, January 18, 2007

jSPF passes all the tests

James developers are currently voting to release jSPF-0.9b4. This release passes all the tests at www.openspf.org

If you want to try it out before its released the rc is here Remember to let us know what you think of it.

Tuesday, January 09, 2007

Mailet Annotations - Proof of concept.

Well I did it at last, got my hands wet with annotations.

Work being work we're still well stuck in the j2sdk1.4 era because of the stuff we don't have the balls to upgrade too quickly :-)

James being James we tend to stick like glue to the oldest JDK we can until we have a justification for requiring an upgrade, as opposed to just a half-arsed reason for it, which is what we usually manage.

So yesterday, after a few weeks of debate on the mailet-api@james list about how we would deal with satisfying mailets' dependance on arbitrary services, I had a go with annotations.

We'd originally toyed with the idea of the service location pattern using JNDI. I built a POC for that out of the Apache Directory naming stuff, which is pretty comprehensively top-notch in both the "it works" and "its easy" categories. But that really seemed to be a cop-out since James has long espoused IoC. So the feeling on the list which incidentally includes some non-james people interested in the API, was that dependance injection should be specified where possible in the API, and Annotations used to let the container know what the Mailet is expecting.

Working on a sandbox fork of James, which I'm doing so I can get away with this stuff *and* let other people see it before I accidentally delete it, I created a custom annotation type and annotated a mutator ("setter").
The idea being that, in this case, the annotation would contain a String name parameter of a pre-configured datasource (javax.sql.Datasource) and on finding the annotation James' mailet loader would lookup the service (in this case in the JNDI context as it happens) and inject it into the mailet by calling the annotated method.
Although I did it with DataSource's which aren't quite the same as Services will be, it was relatively easy to programme James to sort this stuff out, and extremely nice and easy to annotate the method.

Whats more, and this is the big selling point for me, it worked first time.
I know it counts for nothing but it output this reassuring message to the console...

ToRepository Mailet requires datasource maildb
maildb is org.apache.james.util.dbcp.JdbcDataSource@652552
mailet got datasource :-) org.apache.james.util.dbcp.JdbcDataSource@652552

So now, having proven it, I guess I have to get to grips with the niceties of Annotations and design the annotations we want to use.

Monday, January 08, 2007

VERP, Mailet, and James

I just stumbled on this blog entry by Aaron Johnson from last Summer which demonstrates quite nicely a lot of the Big Good Thing (flexibility and plug-in architecture) about James and the Mailet API and VERP

ClassCastException - why so coy?

Well it seems that 23% of the people who read this blog read it because they searched for the term "classcastexception".

If you are reading this because you are having trouble with a ClassCastException I suggest you try searching for "troubleshooting classcastexception" or something like that instead, it might also be a good idea to add the name of the class or product which is causing your pain. You could also read some of my other posts on the subject here.

But I'm going to say this again anyway...

Why doesn't ClassCastException have a constructor takes two objects and outputs the message "Can't cast xx.xx.xx to yy.yy.yy at" so that we can find out what couldn't be cast to what simply by applying our reading skills to the message and not having to
a) read the stack trace and
b) attach a debugger just to find out what the wrong type was.

I see this bug registered with Sun, so obviously someone else cares too, but not that much because it has been in-progress since june 2004.

The last time I blogged about CCE I got a comment, but it wasn't wholly supportive it just said "Get any Desired College Degree, In less then 2 weeks.!"

Thursday, January 04, 2007

Apache James at Apachecon EU 2007 ?

Flushed with the sucess of my first ApacheCon presentation in Dublin last year, Happy New Year by the way, which the Dublin audience [pictured below] liked everything about apart from my competence (I'll practice for next time I promise!) which was below average but NOT "poor"!, I just proposed two James related papers for ApacheCon EU 07 , one on James as an application server and the other on the Mailet API as distinct from James.

Hopefully at least one of them will be accepted, IMO it is high time the James community started to make up for the woeful lack of James related activities outside of the project itself.
So if you're involved in the review of the submissions I'm shamelessly asking you to give James its 15 minutes (well 2 x 60 minutes in fact) in the spotlight this year...