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!

10MinuteMail upgraded again

Saturday, November 3rd, 2007

Moved up to Seam 2.0 CR3, and JBoss 4.2.2. I also optimized some code, got rid of some useless error logging, etc...

Hopefully it will perform a little better:) So far it seems to process incoming e-mail much faster, which was a bottleneck under load.

Enjoy!

Quartz Scheduling and Seam (part 1)

Friday, November 2nd, 2007

I am working on a new application, which will require some scheduled jobs. I used EJB3 Timers in 10MinuteMail, but now Seam includes and uses Quartz, an open source scheduling system. So I figured I'd try the new hotness.

So far, it's been a rough road, and I'm not 100% up and running yet (hence the part 1 in the title), but I wanted to share what I've learned along the way as the Seam documentation is lacking a lot of information (although some of what's below mirrors the Seam documentation).

First you have to enable the Quartz engine for handling @Asynchronous methods. Add this line to your components.xml file:

<async:quartz-dispatcher />

I also found that I had to define the async namespace in my component.xml (generated by seam-gen from Seam 2.0 CR1):

xmlns:async="http://jboss.com/products/seam/async"

Then I set up my method:

@Asynchronous
public QuartzTriggerHandle scheduleSiteCheck(@Expiration
Date pWhen, @IntervalDuration
Long pInterval, Long pSiteId) {
Site site = (Site) entityManager.createQuery("from Site where id = :id").setParameter("id", pSiteId)
.getSingleResult();
checkSite(site);
return null;
}

(more...)

CAPTCHA with Seam in Three Minutes

Sunday, October 21st, 2007

Adding a CAPTCHA to a form using Seam is easy now that Seam is bundling jCaptcha.

The Seam documentaiton is good, and can be found in section 13.9 here:

http://docs.jboss.com/seam/2.0.0.CR2/reference/en/html/security.html#d0e7755

If you used seam-gen to create your project, you will need to make a few changes.

First, you need to modify your project's ant build script to deploy the captcha jar into your ear (or possibly .war). In the target "ear" of the build.xml file, you will find a list of many jar files being copied from your project's lib directory into the ear. Simply add the captcha jar to that list, like this:

<include name="lib/jcaptcha-all-1.0-RC6.jar"></include>

Now that the jar is deploying, you need to reference it in the application.xml file found under your project's resources/META-INF directory. Add this entry:

<module>
<ejb>lib/jcaptcha-all-1.0-RC6.jar</ejb>
</module>

If you used seam-gen you will find that the Seam Resource Servlet is already defined in your web.xml so the step defined in the documentation in section 13.9.1 is not necessary.

(more...)

seam-gen and multiple projects part two

Sunday, August 19th, 2007

This is a follow-up from my post two days ago "seam-gen and multiple projects".

After some feedback from "atao" in this thread on the JBoss Seam forum, I have taken a different approach to the problem, and have enhanced seam-gen to generate targets within the generated project's ant build script, which in turn call the related seam-gen tasks. This is more elegant for two reasons. Firstly, the projects are independent and don't rely on special configs kept outside of the project. Secondly, you can run those tasks from within your IDE (Eclipse for me) while doing development. You don't have to fire up a command prompt, navigate to your seam installation, and run the seam-gen commands there. All in all a much better solution. Thank you very much "atao" for the better approach.

The changes made to the seam-gen related files are slightly more extensive than the previous approach, but well worth it.

(more...)

seam-gen and multiple projects

Friday, August 17th, 2007

seam-gen is a command line tool (although the new JBoss Tools eclipse plugin supports an Eclipse driven version as well) which can be used to create new Seam projects with a basic set of files, configs, and templates. It can also update the Seam jars in the project, do deployments, echo settings, create new actions, new forms, new entities, and so on. It is very handy, not only for developers who are just starting out with Seam, but also for experienced Seam developers (who might have customized the template resources which seam-gen uses to create the project framework).

The one big gap with seam-gen is that it keeps it's project settings in a build.properties file in the seam-gen directory of the seam project (which I checkout from CVS as an Eclipse project, making it easy to update). What this means is that there is only one project supported. If I use seam-gen to create a new project called shoestore, then I create another project called yourspace, now I can't use seam-gen to create a new form in shoestore, or update shoestore to the latest Seam jars.

Obviously if you're only working on one project at a time, this isn't a problem, but I tend to have multiple projects going at once. A couple existing applications in maintenance mode, a couple projects under development, and maybe a project or two to test something out in. So tonight I've made a couple of tiny changes to to the seam-gen tool, and the ant build.xml file it uses, which allow you to create, and continue to work with, any number of projects using seam-gen.

The two files to change are the seam (or seam.bat if you are using Windows) executable file (found in the root directory of your Seam downloaded (or checked-out) project) and the build.xml ant build file found inside the seam-gen directory, within the Seam project.

(more...)