Cannot deserialize element in SOAP response from Ofbiz - node.js

I am trying to call a SOAP service deployed on ofbiz instance running on my local machine itself using node:
var soap = require('soap');
var url = 'https://localhost/webtools/control/SOAPService/testSoapSimple?wsdl';
var args = {'login.username':'flexadmin', 'login.password':'ofbiz'};
soap.createClient(url, function(err, client){
if(err) throw err;
console.log(client.describe());
client.testSoapSimple.testSoapSimplePort.testSoapSimple(args,function(err, result, raw, soapHeader){
console.log(result);
console.log(raw);
});
});
The console output looks like:
{ testSoapSimple: { testSoapSimplePort: { testSoapSimple: [Object] } } }
{ 'map-Map': { 'map-Entry': [ [Object], [Object] ] } }
<?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><testSoapSimpleResponse xmlns="http://ofbiz.apache.org/service/"><map-Map>
<map-Entry>
<map-Key>
<std-String value="responseMessage"></std-String>
</map-Key>
<map-Value>
<std-String value="error"></std-String>
</map-Value>
</map-Entry>
<map-Entry>
<map-Key>
<std-String value="errorMessage"></std-String>
</map-Key>
<map-Value>
<std-String value="Cannot deserialize element named login.username"></std-String>
</map-Value>
</map-Entry>
</map-Map></testSoapSimpleResponse></soapenv:Body></soapenv:Envelope>
It returns the value as Cannot deserialize element named login.username.
I checked the logs and it says:
2015-08-28 22:30:28,218 (http-bio-0.0.0.0-443-exec-29) [ SOAPEventHandler.java:233:ERROR]
---- exception report ----------------------------------------------------------
Exception: org.ofbiz.entity.serialize.SerializeException
Message: Cannot deserialize element named login.username
---- stack trace ---------------------------------------------------------------
org.ofbiz.entity.serialize.SerializeException: Cannot deserialize element named login.username
org.ofbiz.entity.serialize.XmlSerializer.deserializeCustom(XmlSerializer.java:478)
org.ofbiz.entity.serialize.XmlSerializer.deserializeSingle(XmlSerializer.java:460)
org.ofbiz.entity.serialize.XmlSerializer.deserialize(XmlSerializer.java:128)
org.ofbiz.service.engine.SoapSerializer.deserialize(SoapSerializer.java:45)
org.ofbiz.webapp.event.SOAPEventHandler.invoke(SOAPEventHandler.java:180)
org.ofbiz.webapp.control.RequestHandler.runEvent(RequestHandler.java:662)
org.ofbiz.webapp.control.RequestHandler.doRequest(RequestHandler.java:406)
org.ofbiz.webapp.control.ControlServlet.doGet(ControlServlet.java:224)
org.ofbiz.webapp.control.ControlServlet.doPost(ControlServlet.java:87)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.ofbiz.webapp.control.ContextFilter.doFilter(ContextFilter.java:344)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
java.lang.Thread.run(Thread.java:662)
Can anybody explain what am I doing wrong? Or if there is something wrong with the WSDL that has been provided?

This happened because the SOAP format which I was trying to send was not in the appropriate format provided by the service provider.
"login.username" was being considered as an element here where as it should be the value of an attribute. For example in this case it might be something like :
<map-Map>
<map-Entry>
<map-Key>
<login.username>123456</login.username>
</map-Key>
</map-Entry>
<map-Map>
which is not compliant to what the service provider supports. It should be something like :
<map-Map>
<map-Entry>
<map-Key>
<std-String value="login.username"></std-String>
</map-Key>
<map-Value>
<std-String value="123456"></std-String>
</map-Value>
</map-Entry>
<map-Map>

Related

Changing from request scope to view scope gives ManagedBeanResolver Error in JSF 2.2

I am upgrading from Myfaces 1.2 to Myfaces 2.2.
I was getting an issue, when bean value was getting lost due to re-initialization of bean. So I tried changing the scope of bean from request scope to view scope but I am getting below error.
Error in Console:-
java.lang.NullPointerException
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver$5.put(ManagedBeanResolver.java:101) [myfaces-impl-2.2.2.jar]
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.putInScope(ManagedBeanResolver.java:367) [myfaces-impl-2.2.2.jar]
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.createManagedBean(ManagedBeanResolver.java:340) [myfaces-impl-2.2.2.jar]
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.getValue(ManagedBeanResolver.java:296) [myfaces-impl-2.2.2.jar]
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67) [el-api.jar:2.2.FR]
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:179) [myfaces-impl-2.2.2.jar]
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72) [jasper-el.jar:7.0.39]
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) [jasper-el.jar:7.0.39]
at org.apache.myfaces.lifecycle.PhaseListenerManager.informPhaseListenersBefore(PhaseListenerManager.java:77) [myfaces-impl-2.2.2.jar]
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:184) [myfaces-impl-2.2.2.jar]
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:143) [myfaces-impl-2.2.2.jar]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198) [myfaces-api-2.2.2.jar]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) [catalina.jar:7.0.39]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.39]
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349) [tomahawk20-1.1.10.jar]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) [catalina.jar:7.0.39]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [catalina.jar:7.0.39]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) [catalina.jar:7.0.39]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) [catalina.jar:7.0.39]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) [catalina.jar:7.0.39]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) [catalina.jar:7.0.39]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) [catalina.jar:7.0.39]
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947) [catalina.jar:7.0.39]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [catalina.jar:7.0.39]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) [catalina.jar:7.0.39]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009) [tomcat-coyote.jar:7.0.39]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) [tomcat-coyote.jar:7.0.39]
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310) [tomcat-coyote.jar:7.0.39]
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [1.6.0_35]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [1.6.0_35]
at java.lang.Thread.run(Thread.java:662) [1.6.0_35]
If you are trying to access data from the view scope bean try loading bean with data by calling a method on page pre-render event.

Exception - Unable to set property userLogin for managed bean credentials

For authentication purposes, I am injecting a request scoped backing bean into another session scoped bean that is going to store the logged user. Or at least it should...
Following , a bit of code:
Request scoped bean - managed property
#ManagedProperty(value="userLogin")
Error
Unable to set property userLogin for managed bean credentials
Stack trace
com.sun.faces.mgbean.ManagedBeanCreationException: Unable to set property userLogin for managed bean credentials
at com.sun.faces.mgbean.ManagedBeanBuilder$BakedBeanProperty.set(ManagedBeanBuilder.java:615)
at com.sun.faces.mgbean.ManagedBeanBuilder.buildBean(ManagedBeanBuilder.java:133)
at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:104)
at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409)
at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269)
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244)
at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72)
at org.apache.el.parser.AstValue.getValue(AstValue.java:161)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:437)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:124)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.el.ELException: Cannot convert userLogin of type class java.lang.String to class model.businessLogic.UserLogin
at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:420)
at org.apache.el.ExpressionFactoryImpl.coerceToType(ExpressionFactoryImpl.java:47)
at com.sun.faces.el.ELUtils.coerce(ELUtils.java:536)
at com.sun.faces.mgbean.BeanBuilder$Expression.evaluate(BeanBuilder.java:592)
at com.sun.faces.mgbean.ManagedBeanBuilder$BakedBeanProperty.set(ManagedBeanBuilder.java:606)
... 51 more
Read the exception's root cause to understand the cause (and inherently thus also the solution):
Caused by: javax.el.ELException: Cannot convert userLogin of type class java.lang.String to class model.businessLogic.UserLogin
Thus, you were referencing a String instance as a managed bean instead of UserLogin instance.
And indeed, your managed property value is invalid:
#ManagedProperty(value="userLogin")
It references a plain vanilla String. You need to reference a managed bean instead:
#ManagedProperty(value="#{userLogin}")
Or, shorter, as the value attribtue is the annotation's default attribute:
#ManagedProperty("#{userLogin}")
In addition to the first answer, you must clean the spaces too, for example:
this is OK:
#ManagedProperty(value="#{userLogin}")
this is NOT OK, the app doesn't work if you do that
#ManagedProperty(value = "#{userLogin}")

primefaces update attribute not working

Whenever I run the following code on Home.xhtml page, I get the following exception. I try to call the contents of panel with id = items but without success. It says that compiler cannot find the component with items identifier.
1)part of Home.xhtml
<h:form>
<p:commandButton type="submit" value="Speak Out" action="#{statusBean.save}" ajax="true" styleClass="buttonstyle" update="items"/>
</h:form>
<p:panel id="items">
//content
</p:panel>
2)Exception
Mar 12, 2013 1:38:04 AM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException
SEVERE: Error Rendering View[/Home.xhtml]
javax.faces.FacesException: Cannot find component with identifier "items" in view.
at org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java:249)
at org.primefaces.renderkit.CoreRenderer.buildAjaxRequest(CoreRenderer.java:222)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeMarkup(CommandButtonRenderer.java:81)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeEnd(CommandButtonRenderer.java:53)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:164)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:300)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:181)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:125)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Mar 12, 2013 1:38:04 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/FreeBird_v.6] threw exception [Cannot find component with identifier "items" in view.] with root cause
javax.faces.FacesException: Cannot find component with identifier "items" in view.
at org.primefaces.util.ComponentUtils.findClientIds(ComponentUtils.java:249)
at org.primefaces.renderkit.CoreRenderer.buildAjaxRequest(CoreRenderer.java:222)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeMarkup(CommandButtonRenderer.java:81)
at org.primefaces.component.commandbutton.CommandButtonRenderer.encodeEnd(CommandButtonRenderer.java:53)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:879)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:164)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:300)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:181)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:125)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:849)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1643)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1646)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:389)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:127)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:117)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:135)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:309)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Okey, shortly you should try :items, because it's outside the component tree. And for more details of using ajax behavior of primefaces you can check the examples in showcase from here. In addition you can use firebug in this case to observe your components.
EDIT:
After BalusC's warning, it's correct that your problem lies on not due to the it's not inside the same component tree, because it's not in the same NamingContainer.
Standard components like h: form , f: subview and h: dataTable are naming containers. Most sets of components possess in some naming containers, so in your case it's outside of the tag for that reason :items will be correct way to refer it.
Please refer to these posts help you understand the topic nicely:
Jsf How to create a Naming Container
Naming Container and Jsf

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure ( in windows)

When I run my application in widows, myeclipse IDE gives me the below error when I want to connect to MySQL database. The port is OK (3306), IP 127.0.0.1, and I have installed the driver.
How can I connect to the MySQL database?
`String driver = "com.mysql.jdbc.Driver";
String url ="jdbc:mysql://locahost:3306/registrationdb";
String dbusername = "root";
String dbpassword = "root";
try{
Class.forName(driver);
Connection con = DriverManager.getConnection(url, dbusername, dbpassword);
System.out.println("dbconnected");
String insert = "insert into registrationdetails values(?,?,?,?,?,?,?)";
PreparedStatement pstmt=con.prepareStatement(insert);
pstmt.setString(1,username);
pstmt.setString(2,password);
pstmt.setString(3,address);
pstmt.setString(4,DateofBirth);
pstmt.setString(5,civilstatus);
pstmt.setString(6,sex);
pstmt.setString(7,telephone);
int i = pstmt.executeUpdate();
if (i<0){
out.println("Registration Success");
}else{
out.println("Registration Fail");
}
}catch (Exception e){
e.printStackTrace();
out.println("Some Exception occur please return to the registration page");
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:350)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2408)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2445)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2230)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:399)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:221)
at com.sqlite.registration.RegistrationServlet.doPost(RegistrationServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:931)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.net.UnknownHostException: locahost
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:866)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1258)
at java.net.InetAddress.getAllByName0(InetAddress.java:1211)
at java.net.InetAddress.getAllByName(InetAddress.java:1127)
at java.net.InetAddress.getAllByName(InetAddress.java:1063)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:249)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
... 33 more

Tomcat + RichFaces 4.1 exceptions when loading file

I have deployed my webapp but for some reason, some exceptions appear when trying to load files into server, I don't know why is this happening. Sometimes when I try to upload a file the rich:fileUpload doesn't upload the file, the progress bar of the component never gets filled and an exception like the following appears on Tomcat's log:
may 21, 2012 8:38:04 PM org.richfaces.request.MultipartRequest25 parseIfNecessary
SEVERE: Exception parsing multipart request: Request prolog cannot be read
org.richfaces.exception.FileUploadException: Exception parsing multipart request: Request prolog cannot be read
at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:156)
at org.richfaces.request.MultipartRequest25.parseIfNecessary(MultipartRequest25.java:77)
at org.richfaces.request.MultipartRequest25.getParameter(MultipartRequest25.java:114)
at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:75)
at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:56)
at java.util.Collections$UnmodifiableMap.get(Collections.java:1339)
at com.sun.faces.application.view.MultiViewHandler.calculateRenderKitId(MultiViewHandler.java:220)
at javax.faces.application.ViewHandlerWrapper.calculateRenderKitId(ViewHandlerWrapper.java:155)
at com.sun.faces.context.FacesContextImpl.isPostback(FacesContextImpl.java:211)
at javax.faces.context.FacesContextWrapper.isPostback(FacesContextWrapper.java:402)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:188)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1824)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: Request prolog cannot be read
at org.richfaces.request.MultipartRequestParser.readProlog(MultipartRequestParser.java:270)
at org.richfaces.request.MultipartRequestParser.initialize(MultipartRequestParser.java:172)
at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:148)
... 30 more
may 21, 2012 8:38:04 PM org.richfaces.request.MultipartRequest25 parseIfNecessary
SEVERE: Exception parsing multipart request: Request prolog cannot be read
org.richfaces.exception.FileUploadException: Exception parsing multipart request: Request prolog cannot be read
at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:156)
at org.richfaces.request.MultipartRequest25.parseIfNecessary(MultipartRequest25.java:77)
at org.richfaces.request.MultipartRequest25.getParameter(MultipartRequest25.java:114)
at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:75)
at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:56)
at java.util.Collections$UnmodifiableMap.get(Collections.java:1339)
at com.sun.faces.application.view.MultiViewHandler.calculateRenderKitId(MultiViewHandler.java:220)
at javax.faces.application.ViewHandlerWrapper.calculateRenderKitId(ViewHandlerWrapper.java:155)
at com.sun.faces.context.FacesContextImpl.isPostback(FacesContextImpl.java:211)
at javax.faces.context.FacesContextWrapper.isPostback(FacesContextWrapper.java:402)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:188)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:473)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:455)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:399)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:191)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1824)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: Request prolog cannot be read
at org.richfaces.request.MultipartRequestParser.readProlog(MultipartRequestParser.java:270)
at org.richfaces.request.MultipartRequestParser.initialize(MultipartRequestParser.java:172)
at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:148)
... 33 more
may 21, 2012 8:38:04 PM org.richfaces.request.MultipartRequest25 parseIfNecessary
SEVERE: Exception parsing multipart request: Request prolog cannot be read
org.richfaces.exception.FileUploadException: Exception parsing multipart request: Request prolog cannot be read
at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:156)
at org.richfaces.request.MultipartRequest25.parseIfNecessary(MultipartRequest25.java:77)
at org.richfaces.request.MultipartRequest25.getParameter(MultipartRequest25.java:114)
at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:75)
at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:56)
at java.util.Collections$UnmodifiableMap.get(Collections.java:1339)
at com.sun.faces.application.view.MultiViewHandler.calculateRenderKitId(MultiViewHandler.java:220)
at javax.faces.application.ViewHandlerWrapper.calculateRenderKitId(ViewHandlerWrapper.java:155)
at com.sun.faces.context.FacesContextImpl.isPostback(FacesContextImpl.java:211)
at javax.faces.context.FacesContextWrapper.isPostback(FacesContextWrapper.java:402)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:188)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1824)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: Request prolog cannot be read
at org.richfaces.request.MultipartRequestParser.readProlog(MultipartRequestParser.java:270)
at org.richfaces.request.MultipartRequestParser.initialize(MultipartRequestParser.java:172)
at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:148)
... 30 more
may 21, 2012 8:38:04 PM org.richfaces.request.MultipartRequest25 parseIfNecessary
SEVERE: Exception parsing multipart request: Request prolog cannot be read
org.richfaces.exception.FileUploadException: Exception parsing multipart request: Request prolog cannot be read
at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:156)
at org.richfaces.request.MultipartRequest25.parseIfNecessary(MultipartRequest25.java:77)
at org.richfaces.request.MultipartRequest25.getParameter(MultipartRequest25.java:114)
at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:75)
at com.sun.faces.context.RequestParameterMap.get(RequestParameterMap.java:56)
at java.util.Collections$UnmodifiableMap.get(Collections.java:1339)
at com.sun.faces.application.view.MultiViewHandler.calculateRenderKitId(MultiViewHandler.java:220)
at javax.faces.application.ViewHandlerWrapper.calculateRenderKitId(ViewHandlerWrapper.java:155)
at com.sun.faces.context.FacesContextImpl.isPostback(FacesContextImpl.java:211)
at javax.faces.context.FacesContextWrapper.isPostback(FacesContextWrapper.java:402)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:188)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:473)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:455)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:399)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:191)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1824)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.io.IOException: Request prolog cannot be read
at org.richfaces.request.MultipartRequestParser.readProlog(MultipartRequestParser.java:270)
at org.richfaces.request.MultipartRequestParser.initialize(MultipartRequestParser.java:172)
at org.richfaces.request.MultipartRequestParser.parse(MultipartRequestParser.java:148)
... 33 more
Any idea on what could be happening? Where can I start looking for fixing this on my app?
CHeers,
I was having the same stacktrace in my project. I can explain why this is happening and few ways to fix it.
So richfaces fileUpload component assumes that multipart request InputStream was not yet read from other places. But if you have in your application any filter that executes simple
request.getParameter(anyParamName) this forces multipart request to read full inputstream and put everything into request.getParts() collection.
When richfaces fileupload attempts to read something from inputstream it cannot do it because the stream cursor is at the end(this is in tomcat sources) and just returns -1; This causes richfaces to think that it can not read anything from the stream.
To fix this you can remove all filters that force multipart request to parse inputStream.
Also as a hot fix you can try to alter some of the richfaces classes like MultipartRequest25 or MultipartRequestParser.
I have added hot fix to MultipartRequestParser in order to check if request already has Parts and attempt to parse there parts into FileUploadParam. This is quite hacky checking the message of the exception but it can work as a hot fix.
There exists non resolved issue in jboss jira that seems to be about this issue. You can check it out. I was adding a comment there too. https://issues.jboss.org/browse/RF-13061
public void parse() throws FileUploadException {
try {
initialize();
while (!sequenceMatcher.isEOF()) {
readNext();
}
} catch (IOException e) {
if(e.getMessage().equals(REQUEST_PROLOG_CANNOT_BE_READ)){
//means it can not read request prolog. maybe application server already read everything and stores data in parts
try {
if(request.getParts()!=null && request.getParts().size()>0){
Collection<Part> parts = request.getParts();
//parts seem to be complete files so get the headers and so on here
//and create fileUploadItems from parts
for(Part part:parts){
String headersString = part.getHeader("content-disposition");
Multimap<String, String> headers = LinkedListMultimap.create();
String[] split = headersString.split("\r\n");
for (String headerString : split) {
parseParams(headerString, "; ", headers);
}
FileUploadParam param = createParam(headers);
if (param == null) {
continue;
}
param.create();
try{
int size = (int)part.getSize();
byte[] buf = new byte[size];
part.getInputStream().read(buf, 0, size);
param.handle(buf, size);
}finally{
param.complete();
}
if (param.isFileParam()) {
uploadedFiles.add(new UploadedFile25(param.getName(), param.getResource(), headers));
} else {
parametersMap.put(param.getName(), param.getValue());
}
}
//return from the method if everything was successfull
return;
}
} catch (Exception e1) {
this.cancel();
throw new IllegalStateException("Could get Parts from the request", e1);
}
}
this.cancel();
throw new FileUploadException(MessageFormat.format("Exception parsing multipart request: {0}", e.getMessage()), e);
}
}

Resources