We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Presentation from InputStream

Hello,

I am trying to build a Presentation object from a PPTX file, but i had a java.lang.NegativeArraySizeException exception :

     InputStream  inputStream = Resources.getFileAsStream(location);
     Presentation pres = new Presentation(inputStream);

Please, tell me if this is the rigght way to do this.
Thanks.

@Abder,

I have observed the sample code shared by you and request you to please set the stream position to 0 before loading using Aspose.Slides.

inputStream.Position=0;

Hello @mudassir.fayyaz
Thank you for your response :slight_smile:
I can’t find the property “Position” for the “inputStream” object.
For information, i use Aspose Full Java

@Abder,

Thank you for sharing the clarification related to Java on your end. Can you please directly try loading the presentation from file rather than stream and see if there is still an issue. If you are able to reproduce the issue then please share the source presentation file with us for further investigation.

Presentation pres=new Presentation("pres.pptx");

Hello @mudassir.fayyaz

I have the same problem when putting the path directly. Below, the debugger trace :

ERROR Message.General  - Exception when invoking service 'remoting-service': flex.messaging.MessageException: java.lang.NegativeArraySizeException : null
  incomingMessage: Flex Message (flex.messaging.messages.RemotingMessage) 
    operation = saveDocument
    clientId = 5327B1F3-1509-81E9-3EAF-3156C311D970
    destination = presentationWebServiceDestination
    messageId = CD9696FF-E0D6-99F9-A66C-290604BDD844
    timestamp = 1508221781221
    timeToLive = 0
    body = null
    hdr(DSRequestTimeout) = 300
    hdr(DSId) = 53260585-591E-D0C9-F5E2-024AB1AB653C
    hdr(DSEndpoint) = my-amf
  Exception: flex.messaging.MessageException: java.lang.NegativeArraySizeException : null
	at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:447)
	at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
	at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1503)
	at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:884)
	at flex.messaging.endpoints.amf.MessageBrokerFilter.invoke(MessageBrokerFilter.java:121)
	at flex.messaging.endpoints.amf.LegacyFilter.invoke(LegacyFilter.java:158)
	at flex.messaging.endpoints.amf.SessionFilter.invoke(SessionFilter.java:44)
	at flex.messaging.endpoints.amf.BatchProcessFilter.invoke(BatchProcessFilter.java:67)
	at flex.messaging.endpoints.amf.SerializationFilter.invoke(SerializationFilter.java:146)
	at flex.messaging.endpoints.BaseHTTPEndpoint.service(BaseHTTPEndpoint.java:278)
	at flex.messaging.MessageBrokerServlet.service(MessageBrokerServlet.java:322)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:527)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:423)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:493)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:930)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:358)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:866)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
	at org.eclipse.jetty.server.Server.handle(Server.java:351)
	at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:594)
	at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1059)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:764)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217)
	at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:424)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:506)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
	at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NegativeArraySizeException
	at com.aspose.slides.obfuscated.fi.do(SourceFile:34)
	at com.aspose.slides.obfuscated.vf.try(SourceFile:65)
	at com.aspose.slides.obfuscated.vf.new(SourceFile:60)
	at com.aspose.slides.obfuscated.vf.<init>(SourceFile:47)
	at com.aspose.slides.obfuscated.ad.do(SourceFile:34)
	at com.aspose.slides.obfuscated.ad.<init>(SourceFile:30)
	at com.aspose.slides.Presentation.do(SourceFile:178)
	at com.aspose.slides.Presentation.<init>(SourceFile:550)
	at com.XXX.XXXX.getFileAsPresentation(classPres.java:37)	
	at com.XXX.XXXX.saveDocument(ClassWS.java:24)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:421)
	... 31 more

Thanks :slight_smile:

@Abder,

As requested earlier, can you please share the source presentation reproducing the issue on your end.

@mudassir.fayyaz
Fixed problem, I had a reference to the old version 2.4 of aspose that raises the problem.
Thanks for your help

@Abder,

Its good to know things are fine on your end. Please share, if I may help you further in this regard.

1 Like