Useful Maven links + stuff

On August 31, 2011, in Arquillian, Maven, Seam 2, Servlet 3.0, by lucasterdev

Artifact search engine:

https://repository.jboss.org/nexus/index.html

Another artifact search engine:

http://mvnrepository.com/

Maven Central Repository Browser

http://search.maven.org/#browse

Repository that contains prehistoric dependencies such as apache-httpclient:commons-httpclient. Despite being deprecated, project such as Arquillian depend on jars contained in that repository! Go figure…

<repository>
	<id>JBoss deprecated</id>
	<name>JBoss deprecated repository</name>
	<url>https://repository.jboss.org/nexus/content/repositories/deprecated/</url>
</repository>

When importing existing Maven projects into eclipse, be sure the following snippet is present in the pom.xml. Specially if you import projects that use Servlet 3.0!

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <showWarnings>true</showWarnings>
            </configuration>
        </plugin>
    </plugins>
</build>
 

http://seamframework.org/Community/IllegalClassNameException

he Problem is related to Weld: https://issues.jboss.org/browse/WELD-897

It is fixed in the current version of weld, however the JBoss AS 6 doesn’t come with that by default.

The most trivial way, to upgrade weld is to go into your

$JBOSS_HOME/server/<whatever>/deployers/weld.deployer/

and delete the weld-core-no-jsf.jar

Then download the current weld-jar (https://repository.jboss.org/nexus/content/groups/public-jboss/org/jboss/weld/weld-core/1.1.1.Final/weld-core-1.1.1.Final.jar) and throw it into the weld.deployers directory.

At least it worked for me…

Good luck

 

I wrote a .xhtml page to test the compatibility of some components:

  • h:commandButton
  • p:commandButton
  • a4j:commandButton
  • h:message
  • h:messages
  • rich:message
  • rich:messages
  • p:growl
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:rich="http://richfaces.org/rich"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:p="http://primefaces.prime.com.tr/ui"
 xmlns:s="http://jboss.com/products/seam/taglib">

<head>
 <p:resources/>
</head>

<body>

 <hr/>
 Messages: <h:panelGroup id="pgMessages"><h:messages id="messages"/></h:panelGroup>
 <hr/>
 RichMessages: <rich:messages id="richMessages"/>
 <hr/>
 <a4j:outputPanel ajaxRendered="true">
 <p:growl id="growl" showDetail="true" showSummary="true" sticky="false" rendered="true"/>
 </a4j:outputPanel>
 <hr/>

 <h:form id="form">

 <p>
 <h:outputText value="Enter Name: " />
 <h:inputText id="name" value="#{growlTestBean.name}" required="true"/><br/>
 Message: <h:panelGroup id="pgMessage"><h:message id="message" for="name"/></h:panelGroup><br/>
 RichMessage: <rich:message id="richMessage" for="name"/><br/>
 </p>

 <p>
 With h:commandButton everything is updated automatically.<br/>
 <h:commandButton value="Test" action="#{growlTestBean.testGrowl}"/>
 </p>

 <p>
 With p:commandButton, nothing is updated automatically.<br/>
 You must specify the components to update by listing their id's in the 'update' attribute.<br/>
 It doesn't update h:messages, even if you list its id in the 'update' attribute. <br/>
 To update h:messages, you must put a 'h:panelGroup' element around it and list the id of the panelGroup.<br/>
 It doesn't update h:message, even if you list its id in the 'update' attribute. <br/>
 To update h:message, you must put a 'h:panelGroup' element around it and list the id of the panelGroup.<br/>
 <p:commandButton value="Test" action="#{growlTestBean.testGrowl}" update="pgMessages,pgMessage,richMessage,richMessages,growl"/>
 </p>

 <p>
 With a4j:commandButton, only 'rich:messages' and 'rich:message' will be updated automatically.<br/>
 To update h:messages, you must list its id in the 'reRender' attribute.<br/>
 To update h:message, you must list its id in the 'reRender' attribute.<br/>
 To update p:growl, you must put it in an 'a4j:outputPanel' with ajaxRendered="true".<br/>
 <a4j:commandButton value="Test" action="#{growlTestBean.testGrowl}" reRender="pgMessages,pgMessage,growl"/>
 </p>

 </h:form>
</body>
</html>
 

How to install Seam Forge plugin

On August 12, 2011, in Seam, Seam 3, Seam Forge, by lucasterdev

forge git-plugin git://github.com/forge/plugin-find-plugin.git
forge git-plugin git://github.com/forge/plugin-richfaces.git
forge git-plugin git://github.com/forge/plugin-hibernate-tools.git
forge git-plugin git://github.com/forge/plugin-seam-persistence.git

 

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
 

[Solved] PermGen space

On August 9, 2011, in Eclipse, JBoss, by lucasterdev

Add the following arguments to the server’s Arguments in the Launch Configuration window:

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

 

(from https://forum.hibernate.org/viewtopic.php?p=2442832)

Hi ,my dear friend !
after i remove dependy of annotation-3.5.6-Final ,it’s works
when i open core3.6.2.Final i had found it contains all of the classes of annotation-3.5.6-Final !!!

I had found the confiliction , just between annotation-3.5.6-Final and core-3.6.2.Final ,did annotation-3.5.6-Final never needed later!!!