These are some caveats you must consider if you decide to work with Seam 2 with Tomcat (and sometimes also with JBoss AS 5):

Issue #1:

Starting a conversation through annotations does not work. It’s broken. Use page descriptors or components.xml instead.

This does NOT work:

@Begin(join = true, flushMode = org.jboss.seam.annotations.FlushModeType.MANUAL)

This works:

<page view-id="/Facility.xhtml">
	<navigation from-action="#{courseWizard.addCourse}">
		<begin-conversation join="true" flush-mode="manual"/>
		<redirect view-id="/coursewizard/basicCourseInfo.xhtml"/>
	</navigation>
</page>

This works:

<page view-id="/Facility.xhtml">
	<begin-conversation join="true" flush-mode="manual"/>
</page>

This works:

<h:commandButton action="#{courseWizard.addCourse(_facility)}" value="Add course...">
	<s:conversationPropagation type="begin"/>
</h:commandButton>

I found some explanation for the manual flush not working. If the entity identifier is generated during an insertion (i.e., auto-increment column), then even with manual flushing, a flush occurs after a call to persist(). This is necessary since each managed entity in the persistence context must be assigned an identifier. To avoid the flush, you need to set the id-generation strategy to sequence (not identity).
@Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
TOO BAD IT CAN’T BE USED WITH MySQL, DESPITE IT’S THE DBMS USED IN PRODUCTION BY HALF OF THE COMPANIES!!!!! SHAME ON MySQL!!! .\/.

Issue #2:

Seam works only with an old and obviously bugged version of Hibernate (core 3.3.1, annotations 3.4.0.GA). Here is an example: if you use @JoinTable to implement an association between a JOINED subclass and another class, the schema creation will fail and throw an exception:

[org.hibernate.AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: Table JOIN_TABLE_NAME not found

Workaround: use the TABLE_PER_CLASS inheritance strategy instead? That doesn’t work either!!

During inserts, Hibernate will “forget” that the x-to-one association is realized with a join table, and will think it’s implemented through a @JoinColumn instead. It will throw a “Unknown column” exception. Precisely, the unknown column is the inexistent join column.
A possible workaround is to use always SINGLE_TABLE, but that forces you to specify explicitly the structure of all join tables, otherwise other exceptions will be thrown!!

Issue #3:

Again, the Hibernate version doesn’t implement JPA 2.0′s orphanRemoval attribute. Instead, you have to use Hibernate’s special annotation:
@Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})

Issue #4:

Seam 2 works with RichFaces 3.3.3.Final and, guess what? There are bugs in RichFaces too! An a4j:commandButton won’t reRender if it’s inside a ui:repeat or an a4j:repeat. Fortunately, there’s a workaround: Inseart an a4j:outputPanel with ajaxRendered="true" around the element you want to reRender.

Issue #5:

Hibernate validator’s @NotNull annotation is ignored and entities are persisted regardless of it. From Seam’s reference guide:

Note: specifying @NotNull on the model does not eliminate the requirement for required="true" to appear on the control! This is due to a limitation of the JSF validation architecture.

A more detailed explanation of that can be found here.

Managed bean elements represented as a JavaServer Faces text component such as inputText are initialized with the value of the empty string by the JavaServer Faces implementation.

Solution:


	javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL
	true

But it works only in JSF 2.0, not with JSF1.2!!!! And Seam only works with JSF 1.2!!! This context param is added by JBossfucking Tools themselves!!!!!!!!!!!!!!!

Issue #6:

There is a problem with binding view components to a conversation scoped component properti. Read here to find out more.

Issue #7:

Seam’s EntityHome and HibernateEntityHome look very appealing, but are not suitable for complec classes that have associations.
(from http://seamframework.org/144729.lace)

Hi,

The Home component is not really suited for managing complex trees, especially when you have relations between objects which are lazily loaded. The Instance of a Class is retrieved with a entitymanager.find method which is not able toe retrieve the whole tree. A solution is using your own component which is a subclass of EntityHome, but at the end you will decide to make a better version using a standard bean.

In short: EntityHome is great for simple classes with eagerly loaded associations.

Leo

Issue #8

TestNG tests can run only on Java 1.5 Containers such as JBoss up-to 5.1, or Tomcat 6 with Embedded JBoss. TestNG tests do NOT run on JBoss AS 6 or JBoss AS 7.

Issue #9 (also with JBoss AS 5)

Conversation doesn’t get started when adding @Begin to the @PostConstruct method of a stateful session bean.

This will NOT start the conversation:

@Begin
@PostConstruct
public void postConstruct() {
}

This will start the conversation:

@PostConstruct
public void postConstruct() {
	Conversation.instance().begin(); // you have to add this line
}

Issue #10 (also with JBoss AS 5)

Injection does not occur before the @PostConstruct method.

This will throw a NullPointerException:

@In
Conversation conversation;

@PostConstruct
public void postConstruct() {
	conversation.begin(); // will throw NullPointerException
}

This will work:

@In
Conversation conversation;

@PostConstruct
public void postConstruct() {
	conversation = Conversation.instance(); // you have to add this line
	conversation.begin();
}

Isue #11 (Also in JBoss AS 5)

If your application is going to contain EJBs, then it MUST be packaged as an EAR. So, be careful when you choose the packaging type in JBoss Tools’ Seam 2 Project creation wizard.
After all, Seam 2 is a Java EE 5 framework, and Java EE 5 supports EJB 3.0, which can not be deployed inside a WAR.

If you choose WAR packaging and you application has EJBs in it, you’ll get the following stack trace:

javax.el.ELException: /SomeEJB3Bean.xhtml: Could not instantiate Seam component: someEJB3
	at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:50)
	at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
	at com.sun.facelets.compiler.UILeaf.encodeAll(UILeaf.java:149)
	at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
	at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
	at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
	at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
	at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
	at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
	at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
	at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
	at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
	at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
	at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
	at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	at java.lang.Thread.run(Thread.java:595)
Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: someEJB3
	at org.jboss.seam.Component.newInstance(Component.java:2170)
	at org.jboss.seam.Component.getInstance(Component.java:2024)
	at org.jboss.seam.Component.getInstance(Component.java:1986)
	at org.jboss.seam.Component.getInstance(Component.java:1980)
	at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
	at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
	at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
	at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
	at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
	at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
	at org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
	at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
	at com.sun.facelets.el.ELText$ELTextVariable.writeText(ELText.java:184)
	at com.sun.facelets.el.ELText$ELTextComposite.writeText(ELText.java:108)
	at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:45)
	... 53 more
Caused by: javax.naming.NameNotFoundException: SomeEJB3Bean not bound
	at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
	at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
	at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
	at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
	at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
	at javax.naming.InitialContext.lookup(InitialContext.java:351)
	at org.jboss.seam.Component.instantiateSessionBean(Component.java:1403)
	at org.jboss.seam.Component.instantiate(Component.java:1367)
	at org.jboss.seam.Component.newInstance(Component.java:2148)
	... 68 more
 

Leave a Reply