Skip navigation
lightguard

DevNexus 2012

Posted by lightguard Mar 26, 2012

I recently returned from DevNexus where I spoke about Apache DeltaSpike and CDI extensions. We also have talks from other Red Hat employees about JBoss AS7, Forge and OpenShift. The conference was well attended with approximately 620 people! My talk was not well attended, however, those whom did attend seemed to enjoy it and asked some great questions. We're looking forward to DeltaSpike as more is discussed and finalized as we continue towards 1.0. Thanks to all those who attented DevNexus!

lightguard

Seam 3 Examples

Posted by lightguard Feb 24, 2012

Hey everyone, recently (and also not so recently) we've had requests for Seam 3 examples outside the ones that exist in the Seam 3 distrubtion, which admitedly aren't very comprehensive. I'd like to list a few examples that have come to my attention over the past few weeks in hopes that they will help people looking for Seam 3 examples and tutorials.

 

 

I'm sure there may be others out there we're not aware of, if you have an example you think others may benefit from seeing / exploring, please leave a comment!

lightguard

Great CDI tutorial

Posted by lightguard Feb 23, 2012

I came across a very well written and thorough tutorial about the basics of dependency injection using CDI the other day. The tutorial doesn't go into detail about scopes, interceptors, decorators, or extensions. Rick Hightower (the author) does an amazing job at describing, explaining and demonstrating (with real code you can download and run yourself) explaining @Inject, qualifiers, alternatives and producers. There is also another tutorial he has written to explain interceptors. I'd love to see more tutorials covering decorators, scopes, events and extensions.

 

Excellent job Rick! I hope to see more, and also would like to extend the invitation to contribute the tutorials to DeltaSpike as some introductory material about CDI.

The short: All www.seamframework.org forums will be moving to community.jboss.org forums on February 1st 2012. All bookmarks and RSS feeds will need to be updated after the migration. The migration will happen at 1300 UTC (1 PM). 

 

The longer version:  We have been looking at doing this migration for some time now, and thought we had everything ready back in November. Fortunately it didn't happen in November. We found a somewhat large hole just after the planned migration in November. We will be putting in place a ServletFilter to handle redirects to the forums which should redirect you to the new thread location (note, unfortunately it will not navigate to the actual post, but the start of the thread). All RSS feeds will need to get the new location after the move. Email notifications will probably not occur until you set them up again.

 

Users will be matched up based on their email address. If you have a user at community.jboss.org with the same email address as your  seamframework.org user they will be combined and posts will be associated with your community.jboss.org username. Users who do not have a community.jboss.org user will have one created for them with the email address that was used at seamframework.org and posts will be attributed to that user.  The Seam Team feels there will be better synergy and also more people willing to help out with problems once the forums are migrated. There will potentially be more people looking at forum posts as many other JBoss projects have their forums hosted here as well. We hope for a quick and painless migration. The scheduled window of downtime starts at 1300 UTC and is scheduled to end at 1700 UTC (5 PM). We hope it does not take that long however. Thank you for your patience. 

 

This information was posted to the mailing lists about a week ago.

For those of you tracking Seam 3 releases and bug fixes, you might have seen SEAM-99 was fixed with Seam 3.1.0.CR1 we released last week. I just discovered a small gotcha when using non-JTA transactions. If you are, your EntityManager must not be scoped @ConversationScoped or it will fail on every request.

 

We prefer JTA and hope the majority of our users do as well, but some may choose to simply use transactions from the EntityManager, which is fine too. Just be aware of that little gotcha if you are not using JTA.

lightguard

Seam 3 on Tomcat 7

Posted by lightguard Sep 2, 2011

There have been a fair amount of comments about getting Seam 3 working correctly on Tomcat. Of course we recommend JBoss AS7, but if Tomcat is a must please use the following snippets in your project to get started.

 

pom.xml

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.jboss.seam</groupId>
                <artifactId>seam-bom</artifactId>
                <version>3.1.0.Beta2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <!-- Use this instead of mojarra if you desire
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-api</artifactId>
            <version>2.0.6</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-impl</artifactId>
            <version>2.0.6</version>
            <scope>runtime</scope>
        </dependency>
        -->
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.0.4-b09</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.0.4-b09</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>javax.enterprise</groupId>
            <artifactId>cdi-api</artifactId>
            <version>1.0-SP4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet</artifactId>
            <version>1.1.2.Final</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.6.7.Final</version>
            <scope>runtime</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <version>1.0.1.Final</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.seam.persistence</groupId>
            <artifactId>seam-persistence</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.seam.faces</groupId>
            <artifactId>seam-faces</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.seam.catch</groupId>
            <artifactId>seam-catch</artifactId>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>JBOSS_NEXUS</id>
            <url>http://repository.jboss.org/nexus/content/groups/public</url>
        </repository>
    </repositories>
    <build>
        <finalName>seam3-tomcat-basic</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

 

web.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

    <listener>
        <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
    </listener>

    <resource-env-ref>
        <resource-env-ref-name>BeanManager</resource-env-ref-name>
        <resource-env-ref-type>
            javax.enterprise.inject.spi.BeanManager
        </resource-env-ref-type>
    </resource-env-ref>

</web-app>

 

context.xml

 

<Context>
    <Resource name="BeanManager"
              auth="Container"
              type="javax.enterprise.inject.spi.BeanManager"
              factory="org.jboss.weld.resources.ManagerObjectFactory"/>
</Context>

 

Using those files your project should be setup to use CDI, Seam 3 (Faces, Catch and Persistence) and Hibernate as the JPA provider (of course you'll need your datasource and persistence.xml file).

I'd like to introduce you all to the newest Seam Community member to step up and help us with Seam 3, Hanneli Tavante! Hanneli lives in São Paulo.

Hanneli (a.k.a. @hannelita) is a developer addicted to code, learn new 
programming languages, frameworks, blow capacitors, do some C programming 
to relax and commit useful (or unuseful) code for random Open Source Projects 
that she finds at Github. She met JBoss products into 2009 and since then she 
tries to help the community with her blog, http://hannelita.wordpress.com.
She also likes coffee, specially the ones from Starbucks. 

Hanneli's help comes at an excellent time as we prepare for the Seam 3.1 release in the coming months. She will be helping us create more cross module examples and improve overall documentation for our release!

lightguard

Seam Catch Release

Posted by lightguard Nov 24, 2010

Seam Catch Alpha1 was released yesterday! You can read about ithere, or the docs. Bits can be found in the JBossrepository using maven:

<dependency>
    <groupId>org.jboss.seam.catch</groupId>
    <artifactId>seam-catch-api</groupId>
    <version>3.0.0.Alpha1</version>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>org.jboss.seam.catch</groupId>
    <artifactId>seam-catch-impl</groupId>
    <version>3.0.0.Alpha1</version>
    <scope>runtime</scope>
</dependency>

Or at SourceForge. I'm very interested in any feedback that you may have.

What is Catch?

Catch is the exception handling infrastructure in Seam3. I like to refer to it as Next Generation Exception Handling. It really goes beyond what was available in Seam2 and offers a complete solution for Exception Handling. It's built on top of CDI events so the entry point is very minimal and usage is quite easy.

Usage

For those who are familiar with CDI events, creating your own handlers will be very familiar. Handlers are quite similar to CDI Observers, though there are a few differences:

  1. handlers must be contained in a bean marked by @HandlesExceptions
  2. the first parameter in the method must be annotated with @Handles and be an instance of CaughtException&lt;T extends Throwable>
  3. handlers are ordered before they're invoked

Keep those things in mind and the rest is very easy.

Creating a Handler

The docs really cover this very well, but here's a simple handler to get you started:

@HandlesExceptions
public class JsfHandlers {
    public void redirectingHandler(@Handles(precedence = -100) CaughtException<Throwable> event, NavigationHandler nav) {
        nav.handleNavigation(FacesContext.getCurrentInstance(), null, "/error.xhtml");
    }
}

NOTE: The best way to tie this handler into JSF is by adding a JSF to Catch bridge by creating an ExceptionHandler (this will be added to Catch in the next release, as a separate jar) to fire the ExceptionToCatchEvent.

 

There's not much there as you can see. We're saying this is a general handler (the CaughtException type is Throwable) and we want it run towards the end of the cause container traversal (precedence = -100). If you're not familiar with JSF, this is will navigate the user to the error page at the end of the exception handling. Of course this would require some extra JSF integration pieces to produce the NavigationHandler such as Seam Faces or Apache CODI, or your own producer. The NavigationHandler is injected via CDI, in fact, any additional parameters past the CaughtException param will be injected for you. Anything that you need for your exception handling, as long as CDI can create it, can be injected for you.

Entering Catch

Above I mentioned the ExceptionToCatchEvent. This event is all that's needed to start the handling process. Something as simple as

@Inject Event<ExceptionToCatchEvent> catchEvent;
...
try {
    your code
} catch (Exception e) {
    catchEvent.fire(new ExceptionToCatchEvent(e));
}

will get the ball rolling.

That's really all there is to it! I'm looking forward to any feedback you may have, and bugs if you find them. Bugs should be filled in JIRA. In the next release look for bridges for JSF, JAX-RS and others, and the ability to filter stack traces!