Hobione's Weblog

Living & Breathing in Web 2.0 Era

RichFaces, JPA trial and error

Issue # 1. I wanted to use RichFaces Modal Panel to pop up a login screen and I got an error. Instead of going to login.xhtml, it was giving me file download error like this.
idmserror.jpg

Solution: In my web.xml file I added <welcome-file>index.xhtml</welcome-file>. I had to change index.xhtml to index.html to make it work. I guess application initialization it does not know what is xhtml. Once application get initialized, then it recognizes the xhtml extension.

Issue with Persistence Model: Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException: Deployment Error — The persistence-context-ref-name [persistence/LogicalName] in module [C:\buildLocal\WebDMS\build\web] resolves to a persistence unit called [WebDMSModelPU] which is of type RESOURCE_LOCAL. Only persistence units with transaction type JTA can be used as a container managed entity manager. Please verify your application.

Jason: Drop the type=”" (?) decl from your persistence declaration, or change it to JTA
OR stop using injection to get your EntityManager

Jason: <persistence-unit name=”WebDMSModelPU” transaction-type=”JTA”> or <persistence-unit name=”WebDMSModelPU”>
JTA is the default. if you have “RESOURCE_LOCAL”, that tells JPA that you will handle txn mgmt yourself. a container-managed EM can’t work in that… mode

So here is my workable persistence.xml looks like:

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="WebDMSModelPU" transaction-type="JTA">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<jta-data-source>jdbc/dms</jta-data-source>
<class>webdmsmodel.model.Project</class>
<class>webdmsmodel.model.ProjEpf</class>
<class>webdmsmodel.model.ProjType</class>
</persistence-unit>
</persistence>

More details on this issue: David’s blog, JSF ForumIssue 3: This was very weired. My accordion image was not showing up when I did a hot deployment to the development server from my local machine. But it worked on the local machine.
noimg.jpg
Solution: It worked after spent couple hours. I had to re start our development application server
SJSAS 9.1 UR 1) to see the change.withimg.jpgIssue # 4: Scrollable Data Table wont render data.

<rich:scrollableDataTable  id="projectTable" var="project" value="#{controller.projectList}" first="0" rows="20">

Solution: I was returning a DataModel instead of List. I assume, scrollable data table does not work with DataModel.2 cents from Jason: I’ve never used DataModel, always using a List. Internally, dataTable will convert a List to a ListDataModel, for what that’s worth. Apparently, I lose some things by not using a DataModel, but I’m not sure what that is yet. :)HH: I must say that RichFaces is such a sweet JSF component libraries to work with. Awesome. Full credit goes to Jason Lee, who introduced me with it. I have tried Sun’s Woodstock and few other libraries, but RichFaces has the best documentations, it is very easy to use and more frequently version updates.

March 20, 2008 Posted by HobiOne | Java Persistence API, Java Server Faces, Jboss RichFaces (Ajax4JSF) | | No Comments Yet