Help

Controls

PermLinkWikiLink

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

Forum: Seam Users Forum ListTopic List
30. Apr 2008, 06:00 America/New_York | Link

I create a new EAR project into Eclipse by seam-gen with RichFaces support. Then I create a session bean which dynamically generates a HtmlOutputText and a RichFaces HtmlPanel object.

Session bean code :

import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlOutputText;
import org.richfaces.component.html.HtmlPanel;
public class HomePage {
	private UIComponent layout = null;
	public HomePage() {
	}
	public UIComponent getLayout() {
		return layout;
	}

	public void setLayout(UIComponent layout) {
		this.layout = layout;

		HtmlOutputText text = new HtmlOutputText();
		text.setId("TextComponent");
		text.setValue("TextComponent");
		layout.getChildren().add(text);

		HtmlPanel panel = new HtmlPanel();
		panel.setId("Panel");
		layout.getChildren().add(panel);
	}
}

home.xhtml

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"
	template="layout/template.xhtml">

	<ui:define name="body">
		<a4j:form id="mainForm">
			<rich:panel id="mainPanel" binding="#{homePage.layout}">
				<h:outputText value="   Static text." />
			</rich:panel>
		</a4j:form>
	</ui:define>
</ui:composition>

The first problem I met was java.lang.NoClassDefFoundError: org/richfaces/component/html/HtmlPanel.

I think this exception probably indicates missing some libraries, thus I put richfaces-ui.jar into the root of the jar directory of the ear archive.

It works, but then I face to the second problem: java.lang.IllegalArgumentException: Component mainForm:Panel not instance of org.richfaces.component.UIPanel.

I tried to debug the problem, but the exception seems not causing by my code but inside of the Seam or RichFaces.

When I comment out the last line of the session bean code, the page shows up as expected with the dynamic created HtmlOutputText object.

layout.getChildren().add(panel);

I spend many days to solve this problem but still failed. I'll be very appreciate who can help me. Thank you very much in advance.

4 Replies:
15. Oct 2009, 05:36 America/New_York | Link

You need move some jars from WAR lib to EAR lib. You should not add duplicated jars to both WAR lib and EAR lib because they are loaded by diferent class loader.

We move jboss-seam-ui.jar and richfaces-api.jar to EAR lib and fix that problem.

15. Oct 2009, 20:23 America/New_York | Link

My advice is Do not mix presentation with business ! In my opinion your EJB's should be occupied with business logic and not backing presentation components. I know that Seam encourages such practices, but it is really easier and better (design) to add to WAR another bean that would connect with EJB to get data and create appropriate Rich components.

 

Outsource your Seam projects to Poland

06. Jan 2010, 07:07 America/New_York | Link

Is this issue solved? I have been facing this issue since last few days!!

 

Sai

06. Jan 2010, 09:25 America/New_York | Link

This is very simple issue. You cannot have the same library both in war and ear and keep passing instances of classes from that library between ejbs and web tier. They are loaded by different classloaders and thus being different types.

Solution: keep library in EAR (ear/lib i guess) and remove it from war.

Still, my advice is Do not mix presentation with business !

 

Outsource your Seam projects to Poland