cancel
Showing results for 
Search instead for 
Did you mean: 

problem with contentService.write

madhurao
Champ in-the-making
Champ in-the-making
Hello guys,

I am getting an error with the following Code when the file content size is more than 15mb even if i have executed command with java -Xms512m -Xmx1024m -XX:MaxPermSize=256m TestUploadFile. When i make:

FileInputStream is = new FileInputStream(path);
byte[] bytes = ContentUtils.convertToByteArray(is);
ContentFormat format = new ContentFormat(contType, "UTF-8");
//Write the content
contentService.write(content, Constants.PROP_CONTENT, bytes, format);

the above code is working fine when the file content size is upto 15mb but if size of a file is more than 15 mb then i am getting the follwing(java.lang.OutOfMemoryError: Java heap space) error in tomcat server console.

error showing in tomcat server console:
01:40:19,082 User:admin INFO  [apache.axis.EXCEPTIONS] Exception:
java.lang.OutOfMemoryError: Java heap space
        at java.io.CharArrayWriter.write(CharArrayWriter.java:88)
        at org.apache.axis.message.SOAPHandler.characters(SOAPHandler.java:169)
        at org.apache.axis.encoding.DeserializationContext.characters(DeserializationContext.java:966)
       
error showing in command prompt console:

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString: java.lang.OutOfMemoryError: Java heap space; nested exception is:
        java.lang.OutOfMemoryError: Java heap space
faultActor:
faultNode:
faultDetail:
        {http://xml.apache.org/axis/}hostname:XXXXX-xxx

java.lang.OutOfMemoryError: Java heap space; nested exception is:
        java.lang.OutOfMemoryError: Java heap space

Please help me how can i resolve this issue?

Thanks,
Madhu
7 REPLIES 7

dranakan
Champ on-the-rise
Champ on-the-rise
Hello,

Are you sure that the JVM start with your arguments ? (you can see the log file)

madhurao
Champ in-the-making
Champ in-the-making
Yes it showing same values which we pass as arguments.

Regards,
Madhu

d_segato
Champ in-the-making
Champ in-the-making
I think you should use java stream buffers instead of storying your file into a byte array and then writing it somewhere else

openpj
Elite Collaborator
Elite Collaborator
I think you can solve this issue in two ways.

The first way is based on try to change memory settings in your JAVA_OPTS giving more memory available for your custom application (Xmx parameter must be increased).

The second way is based on use REST API to upload contents, so you can use Web Services API to update the new node in the repository and then you can implement a method that invoke simply an HTTP PUT method with all the bytestream.

Hope this helps.

balkis
Champ in-the-making
Champ in-the-making
Hi,

I need to upload files programatically and automatically into alfresco repository. I use Quartz scheduler to run the program that do it via the web-service API, and I'm facing the same "out of memory" issue with files up to 35 MO.
the Alfresco version I'm using is 3.3.
These are my JVM parameters:
set JAVA_OPTS=-Xms512m -Xmx1312m -Xss1024k -XX:MaxPermSize=256m -XX:NewSize=256m -server -Dalfresco.home=%ALF_HOME% -Dcom.sun.management.jmxremote

Please guys, tell me if there is a solution for this problem!
Can we use the REST API in my case ?

Thank you

hsohaib
Champ on-the-rise
Champ on-the-rise
set JAVA_OPTS=-Xms512m -Xmx1312m -Xss1024k -XX:MaxPermSize=256m -XX:NewSize=256m -server -Dalfresco.home=%ALF_HOME% -Dcom.sun.management.jmxremote

try adding : -XX:MaxPermGen=512m

jovs
Champ in-the-making
Champ in-the-making
I have the same problem like madhurao… i tried a lot of things and i didnt find solution to resolve it. I have GWT oriented application with multiuploader, files are uploading succesfully on gwt side but when i will try to write them in alfresco i get java.lang.OutOfMemoryError: Java heap space; nested exception is: java.lang.OutOfMemoryError: Java heap space on files bigger than 20mb, Files under 20 mb are writing without problem. My Alfresco version is 4.2c with xmx1024m. After a lot of testing iam pretty sure that problem occurs when alfresco client trying to write the content with bigger file with this function contentService.write(docRef, Constants.PROP_CONTENT, getBytesFromFile(file), contentFormat); Here is the full error stack from Tomcat logs:

2013-03-13 13:30:08,481  INFO  [apache.axis.EXCEPTIONS] [http-apr-8080-exec-7] Exception:
java.lang.OutOfMemoryError: Java heap space
   at org.apache.xml.security.utils.UnsyncByteArrayOutputStream.expandSize(Unknown Source)
   at org.apache.xml.security.utils.UnsyncByteArrayOutputStream.write(Unknown Source)
   at org.apache.xml.security.c14n.implementations.CanonicalizerBase.outputTextToWriter(Unknown Source)
   at org.apache.xml.security.c14n.implementations.CanonicalizerBase.canonicalizeSubTree(Unknown Source)
   at org.apache.xml.security.c14n.implementations.CanonicalizerBase.engineCanonicalizeSubTree(Unknown Source)
   at org.apache.xml.security.c14n.implementations.CanonicalizerBase.engineCanonicalizeSubTree(Unknown Source)
   at org.apache.xml.security.c14n.Canonicalizer.canonicalizeSubtree(Unknown Source)
   at org.apache.xml.security.utils.XMLUtils.outputDOM(Unknown Source)
   at org.apache.ws.axis.security.WSDoAllReceiver.invoke(WSDoAllReceiver.java:204)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)
   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: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:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
   at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
13-Mar-2013 13:30:08 com.talan.ora.service.ged.impl.GEDServiceImpl http-apr-8080-exec-3
[ERROR]: Exception lors de l'ajout du fichier [\tmp\Novicorp WinToFlash 0.7.0054 beta.zip] au niveau du GED. : [AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString: java.lang.OutOfMemoryError: Java heap space; nested exception is:
   java.lang.OutOfMemoryError: Java heap space
faultActor:
faultNode:
faultDetail:
   {http://xml.apache.org/axis/}hostname:Jovs-PC

java.lang.OutOfMemoryError: Java heap space; nested exception is:
   java.lang.OutOfMemoryError: Java heap space
   at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
   at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
   at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:606)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1742)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2900)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
   at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
   at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:489)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
   at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
   at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
   at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
   at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
   at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:302)
   at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
   at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
   at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
   at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
   at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
   at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
   at org.apache.axis.client.Call.invoke(Call.java:2767)
   at org.apache.axis.client.Call.invoke(Call.java:2443)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at org.alfresco.webservice.content.ContentServiceSoapBindingStub.write(ContentServiceSoapBindingStub.java:513)
   at com.talan.ora.service.ged.impl.GEDServiceImpl.create(GEDServiceImpl.java:574)
   at com.talan.ora.service.ged.impl.GEDServiceImpl.create(GEDServiceImpl.java:461)
   at com.talan.ora.service.ged.impl.GEDServiceImpl.create(GEDServiceImpl.java:440)
   at com.cng.go.ui.gwt.activityfollow.server.GWTCommentServiceImpl.saveComment(GWTCommentServiceImpl.java:114)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:601)
   at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
   at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:544)
   at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:504)
   at com.cng.go.ui.controller.GwtRpcController.processCall(GwtRpcController.java:91)
   at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
   at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
   at com.cng.go.ui.controller.GwtRpcController.handleRequest(GwtRpcController.java:74)
   at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
   at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:774)
   at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
   at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
   at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
   at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:119)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
   at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
   at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
   at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
   at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
   at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
   at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
   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: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:168)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
   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:407)
   at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
   at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
   at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1813)
   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)


Please someone help me getting rid of this error. Thanks