| Author |
Message |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 04/11/2008 10:30:45
|
thierry.rietsch
Joined: 28/10/2008 00:00:00
Messages: 19
Offline
|
Hi
I try to develop my first seam - liferay portlet combination but unfortunately i wasn't very successfull till yet.
I created a simple enterprise application in NetBeans which contains a war and an ejb project. I removed the war project from the ear project, so only the ejb project gets deployed. As application server I am using the glassfish-liferay bundle available from Liferay. The ear (with the ejb) deploys successfull to the glassfish instance and is visible over the glassfish administration console.
To deploy the war file, I copy the war archive after building it from the dist directory to the c:/Documents and Settings/..../liferay. This archive also deploys successfull and I am able to include the portlet over the liferay portal.
Unfortunately only half of the portlet is working.
In the WEB-INF directory of the war archive I have the required configurations files:
components.xml
Code:
<core:init debug="true" jndi-pattern="java:comp/env/#{ejbName}/local" />
<core:manager conversation-timeout="120000"
concurrent-request-timeout="500"
conversation-id-parameter="cid"/>
<component scope="APPLICATION" auto-create="true" name="renderManager" class="com.icesoft.faces.async.render.RenderManager" />
faces-config.xml
Code:
<application>
<view-handler>com.icesoft.faces.facelets.D2DSeamFaceletViewHandler</view-handler>
</application>
If one of the other configuration files (liferay-display.xml, liferay-plugin-package.xml, liferay-portlet.xml, pages.xml, portlet.xml, sun-web.xml, web.xml) is also interesting for solving the problem, I will post them here.
xhtml code
Code:
<f:view xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:ice="http://www.icesoft.com/icefaces/component">
<ice:outputDeclaration doctypeRoot="HTML"
doctypePublic="-//W3C//DTD HTML 4.01 Transitional//EN"
doctypeSystem="http://www.w3.org/TR/html4/transitional.dtd"/>
<ice:portlet>
<ice:panelGroup>
<ice:dataTable var="cs" values="#{constructionSites}">
<ice:column>
<f:facet name="header">Header1</f:facet>
<ice:outputText value="#{cs.name}" />
</ice:column>
</ice:dataTable>
</ice:panelGroup>
</ice:portlet>
</f:view>
java code
Code:
@Stateful
@Name("constructionSiteList")
public class ConstructionSiteListAction implements ConstructionSiteList {
@DataModel
private List<ConstructionSite> constructionSites;
@DataModelSelection
private ConstructionSite constructionSite;
@Logger
private Log log;
@Factory("constructionSites")
public void getConstructionSites() {
log.debug("getConstructionSites called");
ConstructionSite cs = new ConstructionSite();
cs.setName("A");
cs.setStreet("B");
cs.setZip("123");
cs.setCity("C");
cs.setCountry("D");
cs.setContact("Foo Bar");
constructionSites = new LinkedList<ConstructionSite>();
constructionSites.add(cs);
}
public ConstructionSite getConstructionSite() {
return constructionSite;
}
@Remove
public void remove() {}
}
The problem is that the xhtml site displays the header of the table column ("Header1") but not any data from the constructionSites collection. Also the log statement ("getConstructionSites called") does never appear in the log files. Also there are no exceptions in the log files (aside from the known NullPointerException when switching a page).
Is there any obvious mistake in the configuration files listed above or are there any further information required?
Thanks in advance for your help!
Kind regards,
Thierry Rietsch
Additional Information:
I forgot to mention that I deploy the ear (with the ejb-jar) over NetBeans and the war file over the liferay folder in the home directory.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 05/11/2008 09:37:04
|
judy.guglielmin
Joined: 20/02/2007 00:00:00
Messages: 1196
Offline
|
Not having deployed an ear to the Glassfish/Liferay bundle, I will assume that you have done your homework and this method of deployment is correct. (and that their deployment script is not for ear archives to be deployed??).
I would be tempted to have a method that is annotated with @Create to ensure that the backing bean is actually instantiated and go from there. If you are going to use the ajax-enabled ice components, you might want to stay away from @DataModelSelection since it requires a full page refresh or navigation and that doesn't sit well with portlet development.
Also, put a scope on this stateful bean (just use PAGE or SESSION for now when you are trying to get this working). and put a comment in your @Destroy/@Remove method to note when the bean is getting destroyed. (to ensure the life span of the bean is as you desire).
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 05/11/2008 10:12:58
|
thierry.rietsch
Joined: 28/10/2008 00:00:00
Messages: 19
Offline
|
Hi
Thanks for your answer. Well I have deployed the code in several ways (ear and war seperate, all in one war file, all in one ear file) and at the moment I use the version with all in one ear file (deploy over NetBeans). This works which means I see that seam instantiates or better say recognizes the components from my ear file.
I enhanced the source code of the ConstructionSiteListAction with the scope annotation (ScopeType.SESSION). I have also added a method which gets called after the ejb has been created (@PostConstruct).
Code:
@Stateful
@Scope(ScopeType.SESSION)
@Name("constructionSiteList")
public class ConstructionSiteListAction implements ConstructionSiteList {
@PersistenceContext(type=PersistenceContextType.EXTENDED)
private EntityManager em;
@DataModel
private List<ConstructionSite> constructionSites;
/*@DataModelSelection
private ConstructionSite constructionSite;*/
@Logger
private Log log;
@PostConstruct
public void onPostConstruct() {
System.out.println("onPostConstruct of ConstructionSiteListAction called");
}
@Factory("constructionSites")
public void getConstructionSites() {
log.debug("getConstructionSites called");
System.out.println("getConstructionSites called println");
ConstructionSite cs = new ConstructionSite();
cs.setName("Baustelle Letzigrund");
cs.setStreet("Letzigrund 3");
cs.setZip("8008");
cs.setCity("Zürich");
cs.setCountry("Schweiz");
cs.setContact("Herr Meier");
constructionSites = new LinkedList<ConstructionSite>();
constructionSites.add(cs);
}
/*
public ConstructionSite getConstructionSite() {
return constructionSite;
}*/
@Remove
public void remove() {}
}
When I now open the seam page, I see the system.out statements in the log file of the glassfish application server. To be sure that the list contains at least a row, i've also added an outputText to the xhtml site.
Code:
<ice:outputText value="Row count: #{constructionSites.rowCount}" />
<ice:dataTable var="cs" values="#{constructionSites}" rows="#{constructionSites.rowCount}">
<ice:column>
<f:facet name="header">Name</f:facet>
<ice:outputText value="#{cs.name}" />
</ice:column>
</ice:dataTable>
When I now open the site, I get the following output:
Row count: 1
Name
Really confusing is, that when I leave the rows="#{....}" away in the ice:dataTable, the bean method doesn't get called. Also confusing is, that the list contains an item (row count) but it doesn't get displayed in the table.
Any other suggestions?
Thanks a lot for your help,
Thierry Rietsch
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 05/11/2008 10:28:33
|
judy.guglielmin
Joined: 20/02/2007 00:00:00
Messages: 1196
Offline
|
how about not using the @Factory for now and just value bind the dataTable to #{constructionSiteList.constructionSite} (or even put 2 datatables in the facelet page, one with the @Factory and the other using the typical setter? Is your interface ConstructionSiteList Serializable?
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 05/11/2008 10:48:03
|
thierry.rietsch
Joined: 28/10/2008 00:00:00
Messages: 19
Offline
|
The interface is not serializable but the ejb is. I removed the @Factory annotation and now the getConstructionSites method doesn't get called anymore (I see no outputs in the log file). Additionally the row count is now empty and the table shows no data.
Even if I change the ScopeType to Application, i see no data.
Do you have probably an example of such an application (ICEfaces, Seam, Glassfish and Liferay) ?
I think I screwed up a configuration entry somewhere,
Thierry
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 05/11/2008 11:05:32
|
judy.guglielmin
Joined: 20/02/2007 00:00:00
Messages: 1196
Offline
|
no deployment exceptions on the server log? sorry...no examples yet for this configuration other than seam-comp-showcase and it's a war. Did you ensure that all the jars in this example were included in your packaging? Perhaps you can list the jars and their location (ear or war)?
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 05/11/2008 11:53:16
|
judy.guglielmin
Joined: 20/02/2007 00:00:00
Messages: 1196
Offline
|
Are you really tied to using the ejb3 container? (makeing user of an ear necessary?) You might want to try a war deployment with the same backing beans, etc to ensure the problem is the ear packaging/configuration. I have done a little investigating (and asked some questions to others more knowledgable about Liferay), and have gotten the following information:-The spec specifically identifies portlets as web modules with an extra deployment descriptor. So to follow the spec, portlets have to be .war files, not .ear files.
But that said, it doesn't mean that it can't necessarily be done.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 05/11/2008 12:03:48
|
thierry.rietsch
Joined: 28/10/2008 00:00:00
Messages: 19
Offline
|
First, thanks a lot for your help. Yes I would like to deploy the whole stuff as an ear file. Actually, the portlets reside in the war file which is inside the ear file.
Currently I am evaluating if I've included everywhere the right libraries. I will post the result here. If this doesn't lead to a result I'll put all the stuff in a war file and deploy it that way. Let's what will help...
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 05/11/2008 13:43:41
|
thierry.rietsch
Joined: 28/10/2008 00:00:00
Messages: 19
Offline
|
So I tried the different deployment methods. If I don't deploy all the files in one ear file, I run into a problem with the ejbs.
Version I: Deploy ear (with ejb) and war sepearte
In this version I tried to deploy the ear file which contains the ejb.jar over NetBeans and the war over the liferay/deploy directory.
The problem is, that the glassfish application server needs the <ejb-local-ref> declaration in the web.xml. Now during the deployment of the war file the server complains, that it can't resolve the ejb-local-ref. As far as I understand this message, it couldn't find the ejbs. Also it is strange, that there is no seam related output during the deplyment of the ear file. I've probably forgot to include some seam libraries but I'm standing in the dark about which library.
Version II: Put all the stuff in one war file. I've done this and put the ejb.jar in the WEB-INF/lib directory. Now there is again a problem with the web.xml -> ejb-local-ref as the ejb.jar isn't loaded before the web.xml is parsed and handled. Is there any option to preload a library in web.xml (sorry, never done that before).
Thank you very much for your help!
Thierry
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 05/11/2008 22:08:33
|
lightguard

Joined: 11/05/2007 00:00:00
Messages: 165
Offline
|
thierry.rietsch wrote:
So I tried the different deployment methods. If I don't deploy all the files in one ear file, I run into a problem with the ejbs.
Version I: Deploy ear (with ejb) and war sepearte
In this version I tried to deploy the ear file which contains the ejb.jar over NetBeans and the war over the liferay/deploy directory.
The problem is, that the glassfish application server needs the <ejb-local-ref> declaration in the web.xml. Now during the deployment of the war file the server complains, that it can't resolve the ejb-local-ref. As far as I understand this message, it couldn't find the ejbs. Also it is strange, that there is no seam related output during the deplyment of the ear file. I've probably forgot to include some seam libraries but I'm standing in the dark about which library.
Version II: Put all the stuff in one war file. I've done this and put the ejb.jar in the WEB-INF/lib directory. Now there is again a problem with the web.xml -> ejb-local-ref as the ejb.jar isn't loaded before the web.xml is parsed and handled. Is there any option to preload a library in web.xml (sorry, never done that before).
Thank you very much for your help!
Thierry
Hate to say it, but this really won't be feasible until EE6 is out and you can deploy EJBs within a WAR. Currently anything that touches an EJB has to be within the same EAR.
You could try populating your datamodel in an @Create method or similar. You're not seeing any data in the list because the list is empty now that the getter isn't being called (I believe before when you have the getter annotated with @Factory seam was confused with which one to fetch, the @DataModel, or the @Factory). Try adding data in @Create and see what that gives you. You could also take a look at the Query classes and see what they're doing.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 13/11/2008 02:29:59
|
thierry.rietsch
Joined: 28/10/2008 00:00:00
Messages: 19
Offline
|
Hi
Sorry for the delay in answering, I was involved in a different task the last days.
Well, why should seam be confused when a getter-Method is marked as an additional factory method? What I recognized is, that when the rows="#{constructionSites.rowCount}" statement ist missing in the xhtml, the seam component doesn't get called at all.
And also, the list is not empty. As the previous statment <ice:outputText value="Number of rows: #{constructionSites.rowCount}" /> prints out 1 on the portlet page. There is an issue with the dataTable from icefaces I think.
I went over the example seam booking for glassfish and compared the project structure after building it to the project structure of my project. I also configured the NetBeans project, that it builds the directory structure exactly the same as the glassfish example. Also the library files are the right ones and in the right location.
Related to the war / ear stuff. The portlet is in the war file, which is in the ear file. Therefor it shouldn't be a problem. Also its not possible to deploy a war file with ejbs to Glassfish as the application server becomes problems with the ejb-references from web.xml.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 13/11/2008 07:13:39
|
thierry.rietsch
Joined: 28/10/2008 00:00:00
Messages: 19
Offline
|
Hi
I found the mistake. It was a typo. In the ice:dataTable I had written values="#{constructionSites}" instead of value="#{...}". Now it works!
Sorry for this stupid question and thanks for all of your help,
Thierry
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 13/11/2008 08:48:57
|
judy.guglielmin
Joined: 20/02/2007 00:00:00
Messages: 1196
Offline
|
That's great. Just to clarify for future users though, could you confirm how you deployed the ear? Did you use the Glassfish method of deployment or did you use a combination of the Liferay deployment and Glassfish?
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 13/11/2008 09:16:34
|
thierry.rietsch
Joined: 28/10/2008 00:00:00
Messages: 19
Offline
|
Hi
I do the deployment over NetBeans built in deployment. I have created an "Enterprise Application" within NetBeans. It contains an ejb project and a web project (war). As server I've choosen the glassfish-liferay bundle which is available from the Liferay website.
To deploy simply right click the enterprise project and choose "undeploy and deploy". It also should be possible to deploy the ear file over the web interface, as the process is the same (the NetBeans deployment calls the same method like the web interface does).
If it would be helpful for other users, I could paste some more information about linked libraries and so on. I will do this tomorrow or next week.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 13/11/2008 09:25:12
|
judy.guglielmin
Joined: 20/02/2007 00:00:00
Messages: 1196
Offline
|
Did you not use the liferay deploy script for the war? Did you then manually edit your web.xml to put in all the liferay context-params, listener, etc?
|
|
|
 |
|
|