Site Network: Personal | Professional | Photography

Technical Blog

This blog will contain content related to Java, Seam, Security, my sites and projects, as well as other technical subjects I am interested in.

Comments and questions are welcome!

Archive for the ‘Seam’ Category

HowGoodIWas.com Beta Launch

Wednesday, May 14th, 2008

The How Good I Was website has just launched it's Friends and Family Beta. The company is not mine, but I did the development of the site.

The published Goal: To deliver on-line and community services that provide social networking and media distribution capabilities targeted at the non-professional ex-athlete and their teams.

  • Showcase your athletic accomplishments...
  • Preserve and share memories, photos, and videos...
  • Reconnect with former teammates, coaches and fans...
  • Discuss and debate all things sports..

Please check it out, and send us all your feedback either using the Contact Us link on the bottom of every page, or at this e-mail address: feedback@hgiw.com

RichFaces Modal Panels, s:graphicImage, and IE6

Sunday, April 13th, 2008

If, like me, you are using the Seam s:graphicImage tag to serve an image from within a RichFaces modal panel, you may have run into an issue where in IE6 the image does not get displayed, and you get the dreaded red X of failure. It works fine in all other browsers, including IE7, and works outside of the modal panel, but not from within the modal panel.

It's not a problem with the image data (saving the image from another browser and serving it up directly works fine. I suspect it's a delay issue with the rendering of the modal panel. For me, it was serving up the red X about 90% of the time under IE6.

The "fix" is to stop using the s:graphicImage tag within the modal, and use a Servlet to stream out the image data instead. It's pretty easy.

One gotcha I had was that I already had a Servlet handling video output, and I couldn't find an example of how to configure two separate paths into the seam web:context-filter Servlet Filter (which allows access to Seam components, like the entity manager to load up the video/image items). A helpful response on the forums gave me this solution:

 
<web:context-filter regex-url-pattern="/image/*|/video/*" />
 

Also, if you're struggling to figure out what a library's new feature isn't working for you, no matter how many permutations of the documented usage you try, check the versions in the manifest files in the library's jars. Maybe, like me, you upgraded the jars in one project, but forgot to upgrade them in this one....

Seam EntityHome Design Pattern

Friday, April 11th, 2008

I've been using Seam for over a year. At some point the "Home" object was introduced to the documentation (Chapter 11). Reading the documentation didn't convince me of the point. Being an ATG guy at heart, I still prefer using "form handlers" for managing my important entities. So I haven't bothered.

However, just recently I ran into a little problem with LazyInitializationExceptions. I'm sure you've run into them yourself. Basically, when Hibernate loads an entity for you, it's loaded by an entity manager which is available to manage that object within a specific scope. This effects persisting changes. Also, if you have properties on that entity that have a fetchType.LAZY, those properties can only be lazily loaded while the same entity manager is available. If it's not, you get LazyInitializationExceptions. No fun.

So in Seam, what I usually do to avoid this, is to create a long running conversation, and load the entity within the context of that conversation. Then, as long as you're still in that long running conversation, you can lazily load all the properties you want.

Normally this is fine. However, in my latest project the application will send e-mails to users when they get a new inter-user message. If they click on the link in the e-mail, they come to the site, but without the existing long running conversation query parameter. Their user component is session scoped, so they're still logged in, but the user object is now outside of it's conversation, and if you attempt to access lazily loaded properties, for instance the user's messages they are trying to see based on the e-mail, blammo: exception central. Unhappy users.

I was pointed to this page: Using EntityHome for entities in long-running contexts

Which showed me how to use the EntityHome to avoid the whole problem. Basically it works like this:

When the user logs in, set the user entity's id into a session scoped component. Don't bother with long running conversations (at least not for the user). The User Home component's Factory method creates a user component using the session scoped user id, anytime the user component is referenced. This component entity is loaded within the context of the current conversation (if it hasn't already been loaded). So, presto-magic, no lazy loading issues.

It let me fix the issue with about 20 lines of code, and little trouble. It's working perfectly so far.

10MinuteMail Updates

Sunday, March 23rd, 2008

I just pushed a new version of 10MinuteMail. Here are the notable updates:

  1. Removed the Ad-Aware links and text. No one was clicking on them anyhow.
  2. Added some translation fixes.
  3. Implemented AJAX based (RichFaces) refreshing of the list of e-mails in your inbox.
  4. Added smtp client throttling (in Postfix) to limit the number of messages accepted from a single source within 60 seconds. This seems to have already fixed the negative impact of high volume spammers on the function of the site.
  5. Removed the "Get Another E-Mail" feature. While this was a user request, I discovered that it was being abused by spammers.
  6. Added a Forward feature to allow you to forward a received e-mail to your home account for storage.

Enjoy! If you have any issues with the AJAX refreshes, let me know, but I think it should work better now.

Apache Proxy Breaks RichFaces

Sunday, March 23rd, 2008

I've run into this twice now, so I wanted to document it here to help other folks, and to see if anyone knows the root cause of the issue.

When using RichFaces with Seam, things work just fine on my local development JBoss instance. But when I deploy the same EAR file up to my production JBoss instance, which is sitting behind an Apache proxy, everything works EXCEPT the rich/ajax stuff.

The issue was that the JavaScript located here: ContextRoot/a4j_3_1_4.GAorg.ajax4jsf.javascript.AjaxScript

would not load.

My Apache proxy was configured like this:

	ProxyPass /10MinuteMail balancer://mycluster/10MinuteMail/
	ProxyPass /10MinuteMail/* balancer://mycluster/10MinuteMail/
	ProxyPassReverse /10MinuteMail http://127.0.0.1:8080/10MinuteMail

With mycluster defined like this:

        
                AddDefaultCharset off
                Order deny,allow
                Allow from all

		BalancerMember http://127.0.0.1:8080
                #Allow from .example.com
        

Again, this configuration worked fine for everything EXCEPT that RichFaces JavaScript.

Since I am only using one node for 10MinuteMail, there is no real need for a load balancer configuration, so I replaced the configuration with this:

	ProxyPass /10MinuteMail http://127.0.0.1:8080/10MinuteMail
	ProxyPass /10MinuteMail/ http://127.0.0.1:8080/10MinuteMail/
        ProxyPassReverse /10MinuteMail/ http://127.0.0.1:8080/10MinuteMail/

Which works, and fixed the RichFaces reference.

So there's your solution. However I have no idea what the actual root cause is.