I am having some difficulty with creating a simple custom controller. Getting this exception when running the application in the test dashboard.
com.hyfinity.xplatform.XPlatformException: Error creating custom engine mvc-RAR_ServiceAdministration-Load-Controller
at com.hyfinity.enginepool.CustomEngineFactory.getInstance(CustomEngineFactory.java:77)
at com.hyfinity.enginepool.DynamicEnginePool.getEngine(DynamicEnginePool.java:38)
at com.hyfinity.xagent.StandardXAgent.callXMLService(StandardXAgent.java:189)
at com.hyfinity.xagent.StandardXAgent.service(StandardXAgent.java:172)
at com.hyfinity.xplatform.XPlatform.service(XPlatform.java:429)
at com.hyfinity.xplatform.XPlatform.serviceRequest(XPlatform.java:387)
at com.hyfinity.xengine.effectors.Service.callService(Service.java:223)
at com.hyfinity.xengine.effectors.Service.effect(Service.java:179)
at com.hyfinity.xengine.effectors.BaseEffector.effect(BaseEffector.java:195)
at com.hyfinity.xengine.core.Rule.fireWithoutContext(Rule.java:197)
at com.hyfinity.xengine.core.Rule.fire(Rule.java:146)
at com.hyfinity.xengine.core.RuleBase.processRules(RuleBase.java:289)
at com.hyfinity.xengine.core.RuleBase.forwardChain(RuleBase.java:215)
at com.hyfinity.xengine.XEngine.execute(XEngine.java:95)
at com.hyfinity.xagent.StandardXAgent.callXMLService(StandardXAgent.java:197)
at com.hyfinity.xagent.StandardXAgent.service(StandardXAgent.java:172)
at com.hyfinity.xplatform.XPlatform.service(XPlatform.java:429)
at com.hyfinity.xplatform.XPlatform.serviceRequest(XPlatform.java:387)
at com.hyfinity.xengine.effectors.Service.callService(Service.java:223)
at com.hyfinity.xengine.effectors.Service.effect(Service.java:179)
at com.hyfinity.xengine.effectors.BaseEffector.effect(BaseEffector.java:195)
at com.hyfinity.xengine.core.Rule.fireWithoutContext(Rule.java:197)
at com.hyfinity.xengine.core.Rule.fire(Rule.java:146)
at com.hyfinity.xengine.core.RuleBase.processRules(RuleBase.java:289)
at com.hyfinity.xengine.core.RuleBase.forwardChain(RuleBase.java:215)
at com.hyfinity.xengine.XEngine.execute(XEngine.java:95)
at com.hyfinity.xagent.StandardXAgent.callXMLService(StandardXAgent.java:197)
at com.hyfinity.xagent.StandardXAgent.service(StandardXAgent.java:172)
at com.hyfinity.xplatform.XPlatform.service(XPlatform.java:429)
at com.hyfinity.xgate.HTTP2Java.processAction(HTTP2Java.java:1065)
at com.hyfinity.xgate.HTTP2Java.doPost(HTTP2Java.java:633)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: com.example.jcontrollers.Load
at com.hyfinity.enginepool.CustomEngineFactory.getInstance(CustomEngineFactory.java:53)
... 46 more
Right now there is literally nothing in the class:
package com.example.jcontrollers;
import com.hyfinity.utils.xml.XDocument;
import com.hyfinity.xplatform.JController;
import java.util.Map;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class Load extends JController
{
/**
* Process the request for this controller, and return the response data needed
* to display the next screen.
* @param data The bound XML data submitted from the browser.
* @param control A name to value mapping of all the other (non bound) parameters submitted.
* @param action The name of the action called from the browser.
* @return The XML data needed to show the next screen.
*/
public XDocument handleRequest(XDocument data, Map control, String action)
{
//setNextPage("mypage");
return data;
}
}
com.hyfinity.xplatform.XPlatformException: Error creating custom engine mvc-RAR_ServiceAdministration-Load-Controller
at com.hyfinity.enginepool.CustomEngineFactory.getInstance(CustomEngineFactory.java:77)
at com.hyfinity.enginepool.DynamicEnginePool.getEngine(DynamicEnginePool.java:38)
at com.hyfinity.xagent.StandardXAgent.callXMLService(StandardXAgent.java:189)
at com.hyfinity.xagent.StandardXAgent.service(StandardXAgent.java:172)
at com.hyfinity.xplatform.XPlatform.service(XPlatform.java:429)
at com.hyfinity.xplatform.XPlatform.serviceRequest(XPlatform.java:387)
at com.hyfinity.xengine.effectors.Service.callService(Service.java:223)
at com.hyfinity.xengine.effectors.Service.effect(Service.java:179)
at com.hyfinity.xengine.effectors.BaseEffector.effect(BaseEffector.java:195)
at com.hyfinity.xengine.core.Rule.fireWithoutContext(Rule.java:197)
at com.hyfinity.xengine.core.Rule.fire(Rule.java:146)
at com.hyfinity.xengine.core.RuleBase.processRules(RuleBase.java:289)
at com.hyfinity.xengine.core.RuleBase.forwardChain(RuleBase.java:215)
at com.hyfinity.xengine.XEngine.execute(XEngine.java:95)
at com.hyfinity.xagent.StandardXAgent.callXMLService(StandardXAgent.java:197)
at com.hyfinity.xagent.StandardXAgent.service(StandardXAgent.java:172)
at com.hyfinity.xplatform.XPlatform.service(XPlatform.java:429)
at com.hyfinity.xplatform.XPlatform.serviceRequest(XPlatform.java:387)
at com.hyfinity.xengine.effectors.Service.callService(Service.java:223)
at com.hyfinity.xengine.effectors.Service.effect(Service.java:179)
at com.hyfinity.xengine.effectors.BaseEffector.effect(BaseEffector.java:195)
at com.hyfinity.xengine.core.Rule.fireWithoutContext(Rule.java:197)
at com.hyfinity.xengine.core.Rule.fire(Rule.java:146)
at com.hyfinity.xengine.core.RuleBase.processRules(RuleBase.java:289)
at com.hyfinity.xengine.core.RuleBase.forwardChain(RuleBase.java:215)
at com.hyfinity.xengine.XEngine.execute(XEngine.java:95)
at com.hyfinity.xagent.StandardXAgent.callXMLService(StandardXAgent.java:197)
at com.hyfinity.xagent.StandardXAgent.service(StandardXAgent.java:172)
at com.hyfinity.xplatform.XPlatform.service(XPlatform.java:429)
at com.hyfinity.xgate.HTTP2Java.processAction(HTTP2Java.java:1065)
at com.hyfinity.xgate.HTTP2Java.doPost(HTTP2Java.java:633)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: com.example.jcontrollers.Load
at com.hyfinity.enginepool.CustomEngineFactory.getInstance(CustomEngineFactory.java:53)
... 46 more
Right now there is literally nothing in the class:
package com.example.jcontrollers;
import com.hyfinity.utils.xml.XDocument;
import com.hyfinity.xplatform.JController;
import java.util.Map;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class Load extends JController
{
/**
* Process the request for this controller, and return the response data needed
* to display the next screen.
* @param data The bound XML data submitted from the browser.
* @param control A name to value mapping of all the other (non bound) parameters submitted.
* @param action The name of the action called from the browser.
* @return The XML data needed to show the next screen.
*/
public XDocument handleRequest(XDocument data, Map control, String action)
{
//setNextPage("mypage");
return data;
}
}
RE: custom controller
From looking at the end of that stacktrace it looks like the root cause was a ClassCastException.
Your code looks ok, so I am not sure what could be causing this? One thing to check would be what version of Java you are using to compile your code, compared to the version you are running WebMaker under. It may be worth using the source and target javac options set to 1.5 just in case.
Also, I think there might be another fatal error log shown somewhere in the dashboard, which may contain some more details of the actual error.
Regards,
Gerard
RE: custom controller
RE: custom controller
I would have expected you to see another fatal error entry (black icon) in the Test Dashboard display, but it would be either before or after the whole section for the request that is failing. This should contain the original error details, but it may not be present in all scenarios.
One other problem I have seen before is when Tomcat is trying to load the core platform code, and your custom code with different classloaders. To try and prevent this issue, you can try putting your custom code in both the tomcat-runtime/common/[lib or classes] and the tomcat-runtime/webapps/ProjectName/WEB-INF/[lib or classes] directories, and then restart Tomcat.
Please let me know if this helps.
Regards,
Gerard
RE: custom controller
java.lang.ClassCastException: com.example.jcontrollers.Controller_1
at com.hyfinity.enginepool.CustomEngineFactory.getInstance(CustomEngineFactory.java:53)
at com.hyfinity.enginepool.DynamicEnginePool.getEngine(DynamicEnginePool.java:38)
at com.hyfinity.xagent.StandardXAgent.callXMLService(StandardXAgent.java:189)
at com.hyfinity.xagent.StandardXAgent.service(StandardXAgent.java:172)
at com.hyfinity.xplatform.XPlatform.service(XPlatform.java:429)
at com.hyfinity.xplatform.XPlatform.serviceRequest(XPlatform.java:387)
at com.hyfinity.xengine.effectors.Service.callService(Service.java:223)
at com.hyfinity.xengine.effectors.Service.effect(Service.java:179)
at com.hyfinity.xengine.effectors.BaseEffector.effect(BaseEffector.java:195)
at com.hyfinity.xengine.core.Rule.fireWithoutContext(Rule.java:197)
at com.hyfinity.xengine.core.Rule.fire(Rule.java:146)
at com.hyfinity.xengine.core.RuleBase.processRules(RuleBase.java:289)
at com.hyfinity.xengine.core.RuleBase.forwardChain(RuleBase.java:215)
at com.hyfinity.xengine.XEngine.execute(XEngine.java:95)
at com.hyfinity.xagent.StandardXAgent.callXMLService(StandardXAgent.java:197)
at com.hyfinity.xagent.StandardXAgent.service(StandardXAgent.java:172)
at com.hyfinity.xplatform.XPlatform.service(XPlatform.java:429)
at com.hyfinity.xplatform.XPlatform.serviceRequest(XPlatform.java:387)
at com.hyfinity.xengine.effectors.Service.callService(Service.java:223)
at com.hyfinity.xengine.effectors.Service.effect(Service.java:179)
at com.hyfinity.xengine.effectors.BaseEffector.effect(BaseEffector.java:195)
at com.hyfinity.xengine.core.Rule.fireWithoutContext(Rule.java:197)
at com.hyfinity.xengine.core.Rule.fire(Rule.java:146)
at com.hyfinity.xengine.core.RuleBase.processRules(RuleBase.java:289)
at com.hyfinity.xengine.core.RuleBase.forwardChain(RuleBase.java:215)
at com.hyfinity.xengine.XEngine.execute(XEngine.java:95)
at com.hyfinity.xagent.StandardXAgent.callXMLService(StandardXAgent.java:197)
at com.hyfinity.xagent.StandardXAgent.service(StandardXAgent.java:172)
at com.hyfinity.xplatform.XPlatform.service(XPlatform.java:429)
at com.hyfinity.xgate.HTTP2Java.processAction(HTTP2Java.java:1065)
at com.hyfinity.xgate.HTTP2Java.doPost(HTTP2Java.java:633)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
[hr][/hr]
Thanks for that last tip by the way! I put the class into the WEB-INF for the specific app, and it looks to be working now. I was putting it into common before.
RE: custom controller
So the data parameter in handleRequest only seems to have a small chuck of XML and not the whole factbase as I would have expected?
This is what the data parameter contains:
<bizflow_details xmlns="" xmlns:fo="http://www.w3.org/1999/XSL/Format"><SessionInfoXML><SESSIONINFO DEPTID="9000000000" IP="SERVER" KEY="2472_1247564545" PORT="7201" SERVERID="0000001001" USERID="0000000101" USERTYPE="U"/></SessionInfoXML><ProcID>1001</ProcID><ActSeq>3</ActSeq><WitemSeq>101</WitemSeq><AppSeq>102</AppSeq><archive>false</archive></bizflow_details>
This is what the fact base looks like according to the development log:
<mvc:eForm xmlns="http://www.hyfinity.com/xplatform" xmlns:mvc="http://www.hyfinity.com/mvc" xmlns:xg="http://www.hyfinity.com/xgate"><mvc:Control><appseq xmlns="http://www.hyfinity.com/mvc">102</appseq><is_script_enabled xmlns="http://www.hyfinity.com/mvc">true</is_script_enabled><isarchive xmlns="http://www.hyfinity.com/mvc">false</isarchive><workseq xmlns="http://www.hyfinity.com/mvc">101</workseq><procid xmlns="http://www.hyfinity.com/mvc">1001</procid><actseq xmlns="http://www.hyfinity.com/mvc">3</actseq><sessioninfo xmlns="http://www.hyfinity.com/mvc"><SESSIONINFO KEY="2472_1247564545" USERID="0000000101" SERVERID="0000001001" IP="SERVER" PORT="7201" DEPTID="9000000000" USERTYPE="U" /></sessioninfo><Page xmlns="http://www.hyfinity.com/mvc">BizFlowEntry.xsl</Page><Controller xmlns="http://www.hyfinity.com/mvc">mvc-RAR_ServiceAdministration-PrepareForm-Controller</Controller><action xmlns="http://www.hyfinity.com/mvc">bizflowEntry</action><mvc:CurrentDate>2011-11-07T13:50:41-05:00</mvc:CurrentDate></mvc:Control><mvc :D ata>
<bizflow_details xmlns="" xmlns:fo="http://www.w3.org/1999/XSL/Format"><SessionInfoXML><SESSIONINFO DEPTID="9000000000" IP="SERVER" KEY="2472_1247564545" PORT="7201" SERVERID="0000001001" USERID="0000000101" USERTYPE="U"/></SessionInfoXML><ProcID>1001</ProcID><ActSeq>3</ActSeq><WitemSeq>101</WitemSeq><AppSeq>102</AppSeq><archive>false</archive></bizflow_details>
<WorkitemContext xmlns="">
<SessionInfoXML><SESSIONINFO DEPTID="9000000000" IP="SERVER" KEY="2472_1247564545" PORT="7201" SERVERID="0000001001" USERID="0000000101" USERTYPE="U" xmlns:xg="http://www.hyfinity.com/xgate" xmlns="" /></SessionInfoXML>
<Process>
<ID>1001</ID>
<Name>Process Name</Name>
<Description/>
<State>R</State>
<ProcessDefinitionID>126</ProcessDefinitionID>
<ProcessDefinitionName>Process Definition Name</ProcessDefinitionName>
<Deadline>0</Deadline>
<Initiator>0000000101</Initiator>
<InitiatorName>Initiator Name</InitiatorName>
<CreationDateTime>2009/08/18 15:21:23</CreationDateTime>
<CompleteDateTime/>
<CustomAttributes>
<CustomAttribute>
<Name>String</Name>
<CustomAttributeValueType>String</CustomAttributeValueType>
<Value>String</Value>
<Description>String</Description>
</CustomAttribute>
<CustomAttribute>
<Name>String</Name>
<CustomAttributeValueType>String</CustomAttributeValueType>
<Value>String</Value>
<Description>String</Description>
</CustomAttribute>
<CustomAttribute>
<Name>String</Name>
<CustomAttributeValueType>String</CustomAttributeValueType>
<Value>String</Value>
<Description>String</Description>
</CustomAttribute>
</CustomAttributes>
<ProcessVariables xmlns:xs="http://www.w3.org/2001/XMLSchema"><NumericPV>1234</NumericPV><StringPV>string value</StringPV></ProcessVariables></Process>
<Activity>
<Sequence>9</Sequence>
<Name>Activity Name</Name>
<Description>Activity Description</Description>
<State>R</State>
<CreationDateTime>2009/08/18 15:21:23</CreationDateTime>
<CompleteDateTime/>
<Responses>
<Response>
<Name>String</Name>
<IsDefault>String</IsDefault>
<Rule>String</Rule>
</Response>
<Response>
<Name>String</Name>
<IsDefault>String</IsDefault>
<Rule>String</Rule>
</Response>
<Response>
<Name>String</Name>
<IsDefault>String</IsDefault>
<Rule>String</Rule>
</Response>
</Responses>
<CustomAttributes>
<CustomAttribute>
<Name>String</Name>
<CustomAttributeValueType>String</CustomAttributeValueType>
<Value>String</Value>
<Description>String</Description>
</CustomAttribute>
<CustomAttribute>
<Name>String</Name>
<CustomAttributeValueType>String</CustomAttributeValueType>
<Value>String</Value>
<Description>String</Description>
</CustomAttribute>
<CustomAttribute>
<Name>String</Name>
<CustomAttributeValueType>String</CustomAttributeValueType>
<Value>String</Value>
<Description>String</Description>
</CustomAttribute>
</CustomAttributes>
</Activity>
<Workitem>
<Sequence>101</Sequence>
<Participant>0000000101</Participant>
<ParticipantName>Participant Name</ParticipantName>
<ParticipantType>U</ParticipantType>
<State>I</State>
<CreationDateTime>2009/08/18 15:21:23</CreationDateTime>
<StartDateTime>2009/08/20 15:43:15</StartDateTime>
<CompleteDateTime/>
<CheckedOutUser>0000000101</CheckedOutUser>
<CheckedOutUserName>Checked Out User Name</CheckedOutUserName>
<Deadline>0</Deadline>
</Workitem>
<User>
<LoginID>a.b@handysoft.com</LoginID>
<MemberID>0000000101</MemberID>
<Name>a b</Name>
<ShortName>ab</ShortName>
<DepartmentName>Root</DepartmentName>
<EmployeeCode/>
<Email>a.b@handysoft.com</Email>
<JobTitle1/>
<JobTitle2/>
<JobTitle3/>
<CustomAttribute1/>
<CustomAttribute2/>
<CustomAttribute3/>
<CustomAttribute4/>
<CustomAttribute5/>
</User>
<Application>
<Name>Application Name</Name>
<ApplicationState>N</ApplicationState>
<CheckOutState/>
<CheckedOutUser/>
<Updatable>U</Updatable>
<ViewType>W</ViewType>
</Application>
<TestMode>IsolatedForm</TestMode></WorkitemContext></mvc :D ata></mvc:eForm>
RE: custom controller
RE: custom controller
This is a restriction of the current Java Controller implementation, as the data parameter will only ever contain the first block of information under the /eForm/Data structure.
If you need to access different information, then you can use a standard controller to restructure the data as required before calling the Java one.
Regards,
Gerard
RE: custom controller
RE: custom controller
I'm passing two edit boxes to a custom controller and the xml looks like this in the controller:
<formData xmlns="http://www.hyfinity.com/mvc"><edit></edit><edit_2></edit_2></formData>
The xml is being modified after the controller and looks like this:
<formData xmlns=""><edit></edit><edit_2></edit_2></formData>
This unfortunately puts formData and all of its subnodes in the default null namespace. :-/
My colleague and I have tried a number of work-a-rounds to no avail.
How do I fix this?
Regards,
Andrew
RE: custom controller
Firstly, my apologies for the slow reply.
The behaviour you are seeing does seem strange. Are you able to provide some more details on what processing is occurring inside the custom controller?
Also when you say that the namespace is getting changed after the controller, how are you determining this? For example are you logging the XML at the end of your processing before it gets returned? Is the XML then incorrect in the outgoing message show in the dashboard/debugger?
Can I also check which WebMaker version you are using?
One thing you could try doing is adding a call to the DOM Document normalizeDocument() function. I have seen this resolve a similar namespace corruption issue in the past.
Regards,
Gerard