• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue in converting Struts view to JSF view using struts-faces integration library  RSS feed

 
BlueStreak Warrior
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am facing a issue in my Sruts to JSF conversion application using struts-faces.jar integration library.
Need expert's help desperately as I am not able to use <s:form> tag in my new jsf page to call a struts action.
I want to call a struts action from my web page designed using JSF,
but it seems impossible without using <s:form> tag from struts-faces integration library.
Please suggest how to resolve this...

I am using WSAD 5.1 IDE with inbuilt Test environment WebSphere server
JSF Version: Sun's RI 1.1
Struts framework: 1.2.6
Struts-Faces Integration Library version: 1.0


I have configured a controller element in struts-config.xml file as has been suggested by different online
documents I studied:
----------------------
<controller>
<set-property property="processorClass"
value="org.apache.struts.faces.application.FacesRequestProcessor"/>
</controller>
----------------------

But configuring a controller does not allow my test server to start up properly and due to errors the ActionServlet also becomes unavailable.
If I comment the controller and start the test server it starts fine but then I cannot access the converted jsf page which contains the <s:form action="/xxxxx.do"> tag.
If now I get back to <h:form> tag instead of <s:form> tag with a <h:commandButton action="xxxx.do"/> for form submission in my jsf page, I see the html page generated with all components but now checking the html source generated I see
<form action="/contextName/jspFolder/sameDisplayedPage.jsf"> which is not valid and never gets called successfully.

I think someways I need to use the <s:form> tag with the controller configured properly to use the struts-faces integration library's request processor, to get things working. But HOW???
Following is the error I get if I use the <controller> tag element in struts-config.xml file and start the server.
This error appears on starting the server without accessing any application's jsp web page

------------------------------------------------------

[6/12/06 15:31:14:109 IST] 3e311815 ActionServlet E org.apache.struts.action.ActionServlet Unable to initialize Struts ActionServlet due to an unexpected exception or error thrown, so marking the servlet as unavailable. Most likely, this is due to an incorrect or missing library dependency.

[6/12/06 15:31:14:109 IST] 3e311815 ActionServlet E org.apache.struts.action.ActionServlet TRAS0014I: The following exception was logged java.lang.IllegalAccessError: org.apache.commons.digester.SetPropertyRule tried to access method org/apache/commons/beanutils/BeanUtils.setProperty(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V
at org.apache.commons.digester.SetPropertyRule.begin(SetPropertyRule.java:198)
at org.apache.commons.digester.Rule.begin(Rule.java:200)
at org.apache.commons.digester.Digester.startElement(Digester.java:1273)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.commons.digester.Digester.parse(Digester.java:1548)
at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:736)
at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:685)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:331)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doInit(StrictServletInstance.java:82)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._init(StrictLifecycleServlet.java:147)
at com.ibm.ws.webcontainer.servlet.PreInitializedServletState.init(StrictLifecycleServlet.java:270)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.init(StrictLifecycleServlet.java:113)
at com.ibm.ws.webcontainer.servlet.ServletInstance.init(ServletInstance.java:189)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.addServlet(WebAppServletManager.java:870)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:224)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadAutoLoadServlets(WebAppServletManager.java:542)
at com.ibm.ws.webcontainer.webapp.WebApp.loadServletManager(WebApp.java:1277)
at com.ibm.ws.webcontainer.webapp.WebApp.init(WebApp.java:283)
at com.ibm.ws.webcontainer.srt.WebGroup.loadWebApp(WebGroup.java:387)
at com.ibm.ws.webcontainer.srt.WebGroup.init(WebGroup.java:209)
at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:987)
at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:136)
at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:356)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:418)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:787)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:354)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:575)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:271)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:249)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:125)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:183)
at com.ibm.ws.runtime.WsServer.start(WsServer.java:128)
at com.ibm.ws.runtime.WsServer.main(WsServer.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)


[6/12/06 15:31:14:188 IST] 3e311815 WebGroup E SRVE0020E: [Servlet Error]-[ActionServlet]: Failed to load servlet: javax.servlet.UnavailableException: org.apache.commons.digester.SetPropertyRule tried to access method org/apache/commons/beanutils/BeanUtils.setProperty(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:366)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doInit(StrictServletInstance.java:82)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._init(StrictLifecycleServlet.java:147)
at com.ibm.ws.webcontainer.servlet.PreInitializedServletState.init(StrictLifecycleServlet.java:270)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.init(StrictLifecycleServlet.java:113)
at com.ibm.ws.webcontainer.servlet.ServletInstance.init(ServletInstance.java:189)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.addServlet(WebAppServletManager.java:870)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet(WebAppServletManager.java:224)
at com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadAutoLoadServlets(WebAppServletManager.java:542)
at com.ibm.ws.webcontainer.webapp.WebApp.loadServletManager(WebApp.java:1277)
at com.ibm.ws.webcontainer.webapp.WebApp.init(WebApp.java:283)
at com.ibm.ws.webcontainer.srt.WebGroup.loadWebApp(WebGroup.java:387)
at com.ibm.ws.webcontainer.srt.WebGroup.init(WebGroup.java:209)
at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:987)
at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:136)
at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:356)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:418)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:787)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:354)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:575)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:271)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:249)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:125)
at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:183)
at com.ibm.ws.runtime.WsServer.start(WsServer.java:128)
at com.ibm.ws.runtime.WsServer.main(WsServer.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
at java.lang.reflect.Method.invoke(Method.java:386)
at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:94)
at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)

(same error message re-iterates/repeats itself... and finally -
Error 503: Failed to load target servlet [ActionServlet] comes in web-browser
)

------------------------------------------------------


Following is the error which I get if I comment the <controller> element in the struts-config.xml file
and use a <s:form action="xxxxx.do"> in the struts converted jsf page. The web-server starts fine, but
accessing the jsf page givers error as:

----------------------------------------------------------
[6/12/06 15:38:00:781 IST] 696f19de WebGroup I SRVE0180I: [Sample Struts-JSF integration application] [/training2] [Servlet.LOG]: /jsp/welcomeF.jsp: init
[6/12/06 15:38:01:219 IST] 696f19de WebGroup E SRVE0026E: [Servlet Error]-[]: java.lang.NullPointerException
at org.apache.struts.faces.renderer.FormRenderer.encodeBegin(FormRenderer.java:114)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:683)
at javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:591)
at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:478)
at org.apache.jsp._welcomeF._jspService(_welcomeF.java:207)
at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:662)
at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
at org.apache.struts.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1054)
at org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:992)
at org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:551)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:209)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1192)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:412)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:593)

----------------------------------------------------------------------

Finally if I change my <s:form action="xxxxx.do"> tag to
<h:form>
<h:commandButton id="submit" action="xxxx.do" value="Submit" />

I see the webpage coming up in the browser (no controller element used in struts-config.xml file this time)
But in the html source of this html created from jsf I see
<form id="_id2" method="post" action="/training2/jsp/welcomeF.faces" enctype="application/x-www-form-urlencoded">

here form's action attribute is pointing to the same displayed page with the context name prefixed. I
assume it is because jsf could not resolve the "xxxx.do" action to anything so set it to the same displayed page.
May be I am wrong as usual...

Below is the simple struts jsp page which I need to convert to jsf page as I am converting only the View part of application.
I want to use the same struts beans and application logic at the back-end. At front-end I need UIComponents from JSF to be used.
Following is the struts jsp page
-------------------------------------------------

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
<%@ taglib prefix="html" uri="/WEB-INF/lib/struts-html.tld" %>
<%@ taglib prefix="bean" uri="/WEB-INF/lib/struts-bean.tld" %>

<html:html>
<html:base/>

<html:messages id="messages" />

<font style="color:red; font=weight:italic; font-family: century gothic">
<html:errors/>
</font>
<BODY>

<P>Sample Struts and JSF integration example</P>
<BR/><P>This one is being displayed via Struts specific tags</P>

<html:form action="validateUser.do">
<bean:message key="label.name" /> : <html:text property="name" /><BR/><BR/>
<bean:message key="label.password" /> : <html:password property="password" /><BR/><BR/>
<bean:message key="label.age" /> : <html:text property="age" /><BR/><BR/>
<bean:message key="label.city" /> : <html:text property="city" /><BR/><BR/>
<bean:message key="label.address" /> : <html:text property="address" /><BR/><BR/>
<html:submit property="submit" value="Show info via Struts" />
</html:form>

</BODY>
</html:html>
-----------------------------------------------------------

I have converted it into the following jsf page
-----------------------------------------------------------

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://struts.apache.org/tags-faces" prefix="s" %>

<f:view>
<HTML><BODY>
<f:verbatim><P>Sample Struts and JSF integration example</P></f:verbatim>
<f:verbatim><P>This one is being displayed via JSF tags</P></f:verbatim>

<h:form> <!-- Want to use s:form tag instead of this h:form tag -->

<h:inputText id="name" value="#{userForm.name}" /><f:verbatim><BR/><BR/></f:verbatim>
<h:inputSecret id="password" value="#{userForm.password}" /><f:verbatim><BR/><BR/></f:verbatim>
<h:inputText id="age" value="#{userForm.age}" /><f:verbatim><BR/><BR/></f:verbatim>
<h:inputText id="city" value="#{userForm.city}" /><f:verbatim><BR/><BR/></f:verbatim>
<h:inputText id="address" value="#{userForm.address}" /><f:verbatim><BR/><BR/></f:verbatim>
<h:commandButton id="submit" action="#{user.facesAction}" value="Show info via Struts" />
</h:form>
</BODY></HTML>
</f:view>

----------------------------------------------------------

I am very hopeful of some answer from respected group experts, please help me.
I am in urgency of course but would not push for immed. response like other, just want some help for sure that is going to
be extremely valuable to me. Anticipating a helping hand...

Thanks in advance
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Bluestreak Warrior"

We'd like to welcome you to the JavaRanch! But please humor our silly conceit that we're professionals here and change your display name to conform to our Naming requirements. Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!