Hi. We're attempting to send large (from 55MB to 400MB) files over CXF, but
we're running into OutOfMemory exceptions even at the lower end, and it
appears that our attempts at configuring MTOM, so far, are unsuccessful,
because the data is being inlined within the XML rather than sent as a
separate part over HTTP.
Here is a sample SOAP message (truncated) :
Headers: {cache-control=[no-cache], content-type=[multipart/related;
type="application/xop+xml"; boundary="----=_Part_0_24914065.1272483361436";
start="<[email protected]>"; start-info="text/xml";
charset=UTF-8], connection=[keep-alive], host=[localhost:8080],
transfer-encoding=[chunked], SOAPAction=[""], user-agent=[Java/1.6.0_03],
Accept=[*], pragma=[no-cache]}
Messages:
Message (saved to tmp file):
Filename: C:\Program Files\Apache Software
Foundation\apache-tomcat-6.0.18\temp\cxf-tmp-718850\cos889tmp
(message truncated to 102400 bytes)
Payload:
------=_Part_0_24914065.1272483361436
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<wsse:Security
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
soap:mustUnderstand="1"><wsse:UsernameToken
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
wsu:Id="UsernameToken-9420495"><wsse:Username
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">admin</wsse:Username><wsse:Password
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">admin</wsse:Password></wsse:UsernameToken></wsse:Security></soap:Header><soap:Body><ns2:importData
xmlns:ns2="http://service.web.companyname.com/"><name>test.zip</name><notes>test
notes</notes><features>abcd</features><data>UEsDBBQAAAAIAJ1ZZDlHvpIZI9mNALpY1AAgAAAAZmVhdHVyZXMvVlZDMTk0X1YzLjUuZW5fVVNfMS5mZmnsvQ98VdWVL77PvTdwCSE5N7lpI6Ry0NhGBTyBqJGmekMChsqfSxL+tGU0kURhDJCGYHGeb3ogAaklNEBA2oK509IZXp8zk3aYjuPYNlU6ta21KGh5U6v3j6cicWymdVrbseR919r73HvuTcI/2+nn/X6Ez2b/OfvP2muvtfbaa/+5VXOra+6oX1I2f9U1/yIMIf8icMP4c+IUXnzHzLkLFos/3d9c0zTnz88WQrf0V58S5Pvw/6AmxFmvOBNC3I/4Bq8Q86rnVdd+9wWrVuX5MfLUfhdldN069aJP/I+/imuTUXSqmJzYWyyy11Vog38D9224haLP9oseO1uPxFDVmUpX/FtvizM+PZLQIj+InZqjDc5BHQ23aIMm3E/eFoNr4c+A0z6sDc6G+zrc/...
Here is the exception stack on the server:
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Unknown Source)
at java.lang.String.<init>(Unknown Source)
at java.lang.StringBuffer.toString(Unknown Source)
at com.ctc.wstx.util.TextBuffer.contentsAsString(TextBuffer.java:403)
at
com.ctc.wstx.sr.BasicStreamReader.getText(BasicStreamReader.java:821)
at
org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:719)
at org.apache.cxf.staxutils.StaxUtils.startElement(StaxUtils.java:668)
at
org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:705)
at org.apache.cxf.staxutils.StaxUtils.startElement(StaxUtils.java:668)
at
org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:705)
at
org.apache.cxf.binding.soap.saaj.SAAJInInterceptor.handleMessage(SAAJInInterceptor.java:110)
at
org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.getSOAPMessage(WSS4JInInterceptor.java:104)
at
org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:111)
at
org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:65)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:78)
at
org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestination.java:92)
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:285)
at
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:168)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServlet.java:175)
at
org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServlet.java:153)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:414)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:39)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
Our server config looks like this:
<jaxws:endpoint id="DataService" implementor="#DataWebService"
address="/DataService">
<jaxws:inInterceptors>
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken" />
<entry key="passwordType" value="PasswordText"/>
<entry key="passwordCallbackRef">
<ref bean="passwordCallback" />
</entry>
</map>
</constructor-arg>
</bean>
</jaxws:inInterceptors>
<jaxws:properties>
<entry key="mtom-enabled" value="true"/>
</jaxws:properties>
</jaxws:endpoint>
Our server-side interface looks like:
@WebService()
@MTOM(enabled=true, threshold=0)
public interface DataWebService {
public boolean importData(
@WebParam(name = "name") String name,
@WebParam(name = "notes") String notes,
@WebParam(name = "features") List<String> features,
@WebParam(name = "data")
@XmlMimeType("application/octet-stream")
DataHandler data,
@WebParam(name = "sites") List<Site> sites)
throws WebServiceException;
Some relevant client code:
public DataWebService getDataWebServiceProxy(String username, String
password) {
DataWebServiceImplService ser = new DataWebServiceImplService();
DataWebService ws = ser.getDataWebServiceImplPort(new
MTOMFeature(true));
org.apache.cxf.endpoint.Client client =
org.apache.cxf.frontend.ClientProxy.getClient(ws);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(0);
httpClientPolicy.setReceiveTimeout(0);
http.setClient(httpClientPolicy);
org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
Map<String, Object> outProps = new HashMap<String, Object>();
outProps.put(WSHandlerConstants.ACTION,
WSHandlerConstants.USERNAME_TOKEN);
outProps.put(WSHandlerConstants.USER, username);
outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
outProps.put(WSHandlerConstants.PW_CALLBACK_CLASS,
ClientPasswordHandler.class.getName());
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
cxfEndpoint.getOutInterceptors().add(wssOut);
return ws;
}
Command-line for the client test:
java -Xmx512m -Djava.endorsed.dirs=".\lib\endorsed" -classpath
.;lib\cxf-2.1.3.jar;lib\wsdl4j-1.6.2.jar;lib\wsdl4j-1.6.2.jar;lib\jaxb-xjc-2.1.7.jar;lib\xml-resolver-1.2.jar;lib\XmlSchema-1.4.2.jar;lib\wss4j-1.5.4.jar;lib\commons-logging-1.1.jar;lib\opensaml-1.1.jar;lib\xmlsec-1.4.0.jar;lib\geronimo-javamail_1.4_spec-1.6.jar
CXFTest
The webserver is Tomcat and the \endorsed directory contains
jaxb-api-2.1.jar, jaxb-impl-2.1.7.jar, and jaxws-api-2.1.7.jar.
We use the endorsed jars because we are using jre1.6.0_03, Tomcat wouldn't
start without two of them, and the impl jar we found mentioned at
http://cxf.apache.org/faq.html#FAQ-CanCXFrunwithJDK1.6%253F
We did find a post on another forum
(http://forums.java.net/jive/message.jspa?messageID=244744) that suggested
that CXF/MTOM would not work with JDK 1.6 rel 3. Here's the money quote:
I've tried [sending files with CXF/MTOM] using Sun JDK 1.6.0_03 on both
Windows and Linux. It does not work in both cases. However with Sun JDK
1.5.0_10 the data are transfered in binary form.
I don't know if that is true or not; we're hoping not.
Sorry for the length, but I thought that all might be relevant and necessary
to understanding where we are with this issue. We'd be very grateful for
any help.
Thanks,
Steve
--
View this message in context:
http://old.nabble.com/Out-of-memory-when-sending-files-%28MTOM%2C-inlining%2C-JDK-1.6%29-tp28394078p28394078.html
Sent from the cxf-user mailing list archive at Nabble.com.