cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: Out of memory when sending files (MTOM, inlining, JDK 1.6)
Date Thu, 29 Apr 2010 01:41:01 GMT

By default, the WSS4JOutInterceptor turns off MTOM since the attachments would 
not be signed/encrypted.   Basically, it takes the "secure" route.

You can tell it to not do that by:

<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">               
<constructor-arg>
....
</contructor-arg>
<property name="allowMTOM" value="true"/>
....




Dan

On Wednesday 28 April 2010 5:16:47 pm Steve T/V wrote:
> 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="<root.message@cxf.apache.org>"; 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: <root.message@cxf.apache.org>
> 
> <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-wssecur
> ity-secext-1.0.xsd" soap:mustUnderstand="1"><wsse:UsernameToken
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecur
> ity-secext-1.0.xsd"
> xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecur
> ity-utility-1.0.xsd" wsu:Id="UsernameToken-9420495"><wsse:Username
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecur
> ity-secext-1.0.xsd">admin</wsse:Username><wsse:Password
> xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecu
> rity-secext-1.0.xsd"
> Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-tok
> en-profile-1.0#PasswordText">admin</wsse:Password></wsse:UsernameToken></ws
> se:Security></soap:Header><soap:Body><ns2:importData
> xmlns:ns2="http://service.web.companyname.com/"><name>test.zip</name><note
> s>test
> notes</notes><features>abcd</features><data>UEsDBBQAAAAIAJ1ZZDlHvpIZI9mNAL
> pY1AAgAAAAZmVhdHVyZXMvVlZDMTk0X1YzLjUuZW5fVVNfMS5mZmnsvQ98VdWVL77PvTdwCSE5N
> 7lpI6Ry0NhGBTyBqJGmekMChsqfSxL+tGU0kURhDJCGYHGeb3ogAaklNEBA2oK509IZXp8zk3aY
> juPYNlU6ta21KGh5U6v3j6cicWymdVrbseR919r73HvuTcI/2+nn/X6Ez2b/OfvP2muvtfbaa/+
> 5VXOra+6oX1I2f9U1/yIMIf8icMP4c+IUXnzHzLkLFos/3d9c0zTnz88WQrf0V58S5Pvw/6AmxF
> mvOBNC3I/4Bq8Q86rnVdd+9wWrVuX5MfLUfhdldN069aJP/I+/imuTUXSqmJzYWyyy11Vog38D9
> 224haLP9oseO1uPxFDVmUpX/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(SAAJInInte
> rceptor.java:110) at
> org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.getSOAPMessage(WSS4JInI
> nterceptor.java:104) at
> org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInIn
> terceptor.java:111) at
> org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInIn
> terceptor.java:65) at
> org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai
> n.java:220) at
> org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationO
> bserver.java:78) at
> org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDestinati
> on.java:92) at
> org.apache.cxf.transport.servlet.ServletController.invokeDestination(Servle
> tController.java:285) at
> org.apache.cxf.transport.servlet.ServletController.invoke(ServletController
> .java:168) at
> org.apache.cxf.transport.servlet.AbstractCXFServlet.invoke(AbstractCXFServl
> et.java:175) at
> org.apache.cxf.transport.servlet.AbstractCXFServlet.doPost(AbstractCXFServl
> et.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(Applicatio
> nFilterChain.java:290) at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
> hain.java:206) at
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.ja
> va:414) at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
> nFilterChain.java:235) at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
> hain.java:206) at
> com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java
> :39) at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicatio
> nFilterChain.java:235) at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterC
> hain.java:206) at
> org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCl
> eanUp.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;l
> ib\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

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Mime
View raw message