AWS s3 image put object - java

I am trying to decode image from base64 to byte array and load into S3 bucket. Bellow is my code,
byte[] imagecontent = Base64.decodeBase64(IMMAGE_CONTENT);
if(imagecontent .length>0) {
input = new ByteArrayInputStream(screenshot);
String file_name = "img_SOME_LOGIC.jpg";
conn.putObject( this.bucketname, file_name, input, new ObjectMetadata());
}
Above code is working fine for text documents. meaning reading text file and uploading. However above is not working for image.
Following is the error i got,
com.amazonaws.AmazonClientException: Unable to unmarshall error response (The declaration for the entity "ContentType" must end with '>'.)
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:532)
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:283)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:168)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2555)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1044)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:928)
Can you please help me ?
UPDATED:
[Fatal Error] strict.dtd:81:5: The declaration for the entity "ContentType" must end with '>'.
97943 [Thread-62-s3store-executor[20 20]] ERROR c.a.h.AmazonHttpClient - Unable to unmarshall error response (The declaration for the entity "ContentType" must end with '>'.)
org.xml.sax.SAXParseException: The declaration for the entity "ContentType" must end with '>'.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) ~[xercesImpl-2.11.0.jar:?]
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source) ~[?:1.8.0_112]
at com.amazonaws.util.XpathUtils.documentFrom(XpathUtils.java:67) ~[aws-java-sdk-1.2.15.jar:?]
at com.amazonaws.services.s3.internal.S3ErrorResponseHandler.handle(S3ErrorResponseHandler.java:63) ~[aws-java-sdk-1.2.15.jar:?]
at com.amazonaws.services.s3.internal.S3ErrorResponseHandler.handle(S3ErrorResponseHandler.java:38) ~[aws-java-sdk-1.2.15.jar:?]
at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:516) [aws-java-sdk-1.2.15.jar:?]
at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:283) [aws-java-sdk-1.2.15.jar:?]
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:168) [aws-java-sdk-1.2.15.jar:?]
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:2555) [aws-java-sdk-1.2.15.jar:?]
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1044) [aws-java-sdk-1.2.15.jar:?]
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:928) [aws-java-sdk-1.2.15.jar:?]
at com.bgt.aggregation.bolt.s3bolt.execute(s3bolt.java:171) [classes/:?]
at org.apache.storm.daemon.executor$fn__5044$tuple_action_fn__5046.invoke(executor.clj:727) [storm-core-1.1.0.jar:1.1.0]
at org.apache.storm.daemon.executor$mk_task_receiver$fn__4965.invoke(executor.clj:459) [storm-core-1.1.0.jar:1.1.0]
at org.apache.storm.disruptor$clojure_handler$reify__4480.onEvent(disruptor.clj:40) [storm-core-1.1.0.jar:1.1.0]
at org.apache.storm.utils.DisruptorQueue.consumeBatchToCursor(DisruptorQueue.java:472) [storm-core-1.1.0.jar:1.1.0]
at org.apache.storm.utils.DisruptorQueue.consumeBatchWhenAvailable(DisruptorQueue.java:451) [storm-core-1.1.0.jar:1.1.0]
at org.apache.storm.disruptor$consume_batch_when_available.invoke(disruptor.clj:73) [storm-core-1.1.0.jar:1.1.0]
at org.apache.storm.daemon.executor$fn__5044$fn__5057$fn__5110.invoke(executor.clj:846) [storm-core-1.1.0.jar:1.1.0]
at org.apache.storm.util$async_loop$fn__557.invoke(util.clj:484) [storm-core-1.1.0.jar:1.1.0]
at clojure.lang.AFn.run(AFn.java:22) [clojure-1.7.0.jar:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_112]

You can try using HTTPS instead of HTTP. AWS Client seems to be having issues with HTTP.

Related

ERROR: 'Namespace for prefix 'xsi' has not been declared.'

Why am I getting this error:
ERROR: 'Namespace for prefix 'xsi' has not been declared.'
Here is my Java code:
package com.emp.ma.jbl.nsnhlrspmlpl.nsnhlrspmlpl.internal.action;
import com.emp.ma.util.xml.XMLDocument;
import com.emp.ma.util.xml.XMLDocumentBuilder;
public class yay {
public static void main(String[] args) {
XMLDocument xmldoc = XMLDocumentBuilder.newDocument().addRoot("spml:modifyRequest");
xmldoc.gotoRoot().addTag("modification").addText("");
xmldoc.gotoChild("modification").addTag("valueObject").addText("");
xmldoc.gotoChild("valueObject").addAttribute("xsi:type","halo");
System.out.println(xmldoc);
}
}
This code was functioning properly until I tried throwing transformer exception whilst converting XML file to HTML for experimenting only.
I need to create an xml file with the format:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<spml:modifyRequest>
<modification>
<valueObject xsi:type="halo">
</valueObject>
</modification>
</spml:modifyRequest>
I removed the transformer part from the code already and yet I'm getting this error in eclipse:
ERROR: 'Namespace for prefix 'xsi' has not been declared.'
Exception in thread "main" com.emp.ma.util.xml.XMLDocumentException: java.lang.RuntimeException: Namespace for prefix 'xsi' has not been declared.
at com.emp.ma.util.xml.XMLDocumentImpl.toResult(XMLDocumentImpl.java:1244)
at com.emp.ma.util.xml.XMLDocumentImpl.toStream(XMLDocumentImpl.java:1314)
at com.emp.ma.util.xml.XMLDocumentImpl.toString(XMLDocumentImpl.java:1336)
at com.emp.ma.util.xml.XMLDocumentImpl.toString(XMLDocumentImpl.java:1325)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.emp.ma.util.xml.XMLDocumentBuilder$XMLDocumentHandler.invoke(XMLDocumentBuilder.java:55)
at $Proxy1.toString(Unknown Source)
at java.lang.String.valueOf(Unknown Source)
at java.io.PrintStream.println(Unknown Source)
at com.emp.ma.jbl.nsnhlrspmlpl.nsnhlrspmlpl.internal.action.yay.main(yay.java:13)
Caused by: javax.xml.transform.TransformerException: java.lang.RuntimeException: Namespace for prefix 'xsi' has not been declared.
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
at com.emp.ma.util.xml.XMLDocumentImpl.toResult(XMLDocumentImpl.java:1242)
... 12 more
Caused by: java.lang.RuntimeException: Namespace for prefix 'xsi' has not been declared.
at com.sun.org.apache.xml.internal.serializer.SerializerBase.getNamespaceURI(Unknown Source)
at com.sun.org.apache.xml.internal.serializer.SerializerBase.addAttribute(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(Unknown Source)
... 15 more
I'm stuck because of this one exception and I don't know how to undo this. Please do help. Like i said, it was functioning properly before trying this experiment of mine, if possible how do I remove this transformer integration. I've tried changing workspace as well -- still not working.
For an XML document to be well-formed, all used namespace prefixes must be declared.
Simply declare the xsi namespace prefix on the root element of your XML,
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<spml:modifyRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modification>
<valueObject xsi:type="halo">
</valueObject>
</modification>
</spml:modifyRequest>
and your error will go away.
Note that you'll similarly have to define the spml namespace prefix.
I got the same error "AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server faultSubcode: faultString: java.lang.RuntimeException: Namespace for prefix 'xsi' has not been declared." while calling the soap web service from coldfusion 9 server, as the error does not resolve quickly as I had to spent more time, finnaly found that due to the incorrect date value supplying to the webservice parameters, it throws different issue. Whenever we got this issue please check input values that are supplying to the webservcie parameters. In my case due to the datetime format 2015-03-04T00:00:00.000Z(It's a part of ISO-8601 date representation), issue happened, 2015-03-04 00:00 resolves the issue. For example for datetime If I provide string(xxxx), coldfusion axis webservice shows te irrelevant error --Namespace for prefix 'xsi' has not been declared....

jasperreports Out of memory after lots of reports

I would avoid an Out of Memory exception in my JasperReport Server.
please, help me.
EDIT 29/08/2015
I'm using JasperReport server 6.1 on Ubuntu 14.04, java 8
Same result --- DETAILS BELOW
I wrote a java code to download (store in local files) multiple pdf reports from my instance of JasperReport Server.
It works well for about 600 reports, after that it produce an error 500.
In the JasperServer log file I see an Out of memory exception.
maybe there is an error in my code? don't think so.
Instead I think there is a memory leak in the jasperReport server.
here you can see my java code (class ga.system.jasperserver.ReportExtractor)
for (ReportParameters aReportParams : listOfReportParameters)
{
String filename = "report-"+aReportParams.getParameter1()+ ".PDF";
jasperreport_url = combineParamsIntoJasperserverUrl(aReportParams);
URL website = new URL(jasperreport_url);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destPath+"/" +filename);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
here you can see a snippet of the exception I get
java.io.IOException: Server returned HTTP response code: 500 for URL: http://myjasperserverurl/jasperserver/rest_v2/reports/TestDir/TestReport.pdf?j_username=xxx&j_password=xxx&PARAMETER1=9734&PARAMETER2=0&PARAMETER3=815G21
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at ga.system.jasperserver.ReportExtractor.extract(ReportExtractor.java:102)
...
...
...
Here you can see the log in JasperReport Server (catalina.out snippet)
2015-08-17 18:16:17,091 ERROR RunReportServiceImpl,pool-5-thread-66:511 - caught Throwable exception: Java heap space
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2271)
at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113)
at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at com.lowagie.text.pdf.OutputStreamCounter.flush(Unknown Source)
at com.lowagie.text.DocWriter.close(Unknown Source)
at com.lowagie.text.pdf.PdfWriter.close(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.close(Unknown Source)
at com.lowagie.text.Document.close(Unknown Source)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:815)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:513)
at com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.exportToPdf(EngineServiceImpl.java:559)
at com.jaspersoft.jasperserver.remote.exporters.PdfExporter.exportReport(PdfExporter.java:98)
at com.jaspersoft.jasperserver.remote.services.impl.ReportExecutorImpl.exportReport(ReportExecutorImpl.java:177)
at com.jaspersoft.jasperserver.remote.services.impl.RunReportServiceImpl.generateReportOutput(RunReportServiceImpl.java:478)
at com.jaspersoft.jasperserver.remote.services.impl.RunReportServiceImpl.executeExport(RunReportServiceImpl.java:378)
at com.jaspersoft.jasperserver.remote.services.impl.RunReportServiceImpl$2.run(RunReportServiceImpl.java:343)
at com.jaspersoft.jasperserver.api.logging.util.LoggableExecutorService$1.run(LoggableExecutorService.java:59)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Virtualizer used in my server (applicationContext.xml snippet)
<bean id="fileVirtualizerFactory" class="com.jaspersoft.jasperserver.api.engine.common.service.impl.FileVirtualizerFactory">
<property name="maxSize" value="3000"></property>
<property name="directory" value="${java.io.tmpdir}"></property>
</bean>
I'm using JasperReport server 5.6.0 on Ubuntu 14.04 (trusty), java 8
EDIT 29/08/2015
new test using JasperReport server 6.1 on Ubuntu 14.04, java 8
Same result, freshly installed server, after 580 pdf produced the server hangs showing this message (read last line: "Caused by: java.lang.OutOfMemoryError: Java heap space"):
org.hibernate.exception.GenericJDBCException: could not initialize
lazy properties:
[com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.persistent.RepoFileResource#8448]
at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at
org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyPropertiesFromDatastore(AbstractEntityPersister.java:831)
at
org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyProperty(AbstractEntityPersister.java:771)
at
org.hibernate.intercept.AbstractFieldInterceptor.intercept(AbstractFieldInterceptor.java:97)
at
org.hibernate.intercept.cglib.FieldInterceptorImpl.readObject(FieldInterceptorImpl.java:98)
at
com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.persistent.RepoFileResource.$cglib_read_data(Unknown
Source) at
com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.persistent.RepoFileResource.getData(Unknown
Source) at
com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.persistent.RepoFileResource.copyData(Unknown
Source) at
com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.HibernateRepositoryServiceImpl$22.execute(HibernateRepositoryServiceImpl.java:1420)
at
com.jaspersoft.jasperserver.api.metadata.common.service.impl.HibernateDaoImpl.executeCallback(HibernateDaoImpl.java:56)
at
com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.HibernateRepositoryServiceImpl.getResourceData(HibernateRepositoryServiceImpl.java:1414)
at sun.reflect.GeneratedMethodAccessor337.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy32.getResourceData(Unknown Source) at
sun.reflect.GeneratedMethodAccessor337.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) at
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at
com.jaspersoft.jasperserver.api.metadata.user.service.impl.PermissionsPrefetcher.invoke(PermissionsPrefetcher.java:79)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at
com.jaspersoft.jasperserver.api.metadata.user.service.impl.PermissionsPrefetcher.invoke(PermissionsPrefetcher.java:79)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at
org.springframework.security.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:66)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at
org.springframework.security.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:66)
at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at com.sun.proxy.$Proxy38.getResourceData(Unknown Source) at
com.jaspersoft.jasperserver.api.engine.jasperreports.util.repo.RepositoryConnection.getInputStream(RepositoryConnection.java:114)
at java.net.URL.openStream(URL.java:1037) at
net.sf.jasperreports.engine.util.JRLoader.getInputStream(JRLoader.java:298)
at
net.sf.jasperreports.repo.DefaultRepositoryService.getInputStream(DefaultRepositoryService.java:100)
at
net.sf.jasperreports.repo.InputStreamPersistenceService.load(InputStreamPersistenceService.java:48)
at
net.sf.jasperreports.repo.DefaultRepositoryService.getResource(DefaultRepositoryService.java:155)
at
net.sf.jasperreports.repo.RepositoryUtil.findInputStream(RepositoryUtil.java:176)
at
net.sf.jasperreports.repo.RepositoryUtil.getBytesFromLocation(RepositoryUtil.java:192)
at
net.sf.jasperreports.engine.RenderableUtil.getRenderable(RenderableUtil.java:121)
at
net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:536)
at
net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:472)
at
net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259)
at
net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:456)
at
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBackground(JRVerticalFiller.java:1846)
at
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:288)
at
net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:152)
at
net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:963)
at
net.sf.jasperreports.engine.fill.BaseFillHandle$ReportFiller.run(BaseFillHandle.java:120)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$SynchronousExecutor.execute(EngineServiceImpl.java:886)
at
net.sf.jasperreports.engine.fill.BaseFillHandle.startFill(BaseFillHandle.java:165)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:1804)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$SynchronousReportFiller.fillReport(EngineServiceImpl.java:790)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:1731)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportFill.runWithDataSource(EngineServiceImpl.java:1086)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportFill.runReport(EngineServiceImpl.java:1015)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$ReportRunnable.run(EngineServiceImpl.java:908)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl$SynchronousExecutor.execute(EngineServiceImpl.java:886)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.fillReport(EngineServiceImpl.java:607)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.executeReportUnitRequest(EngineServiceImpl.java:1937)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.domain.impl.ReportUnitRequest.execute(ReportUnitRequest.java:67)
at
com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.EngineServiceImpl.execute(EngineServiceImpl.java:497)
at
com.jaspersoft.jasperserver.remote.services.impl.ReportExecutorImpl$GenericRunReportStrategy.runReport(ReportExecutorImpl.java:225)
at
com.jaspersoft.jasperserver.remote.services.impl.ReportExecutorImpl.runReport(ReportExecutorImpl.java:127)
at
com.jaspersoft.jasperserver.remote.services.impl.RunReportServiceImpl$1.run(RunReportServiceImpl.java:230)
at
com.jaspersoft.jasperserver.api.logging.util.LoggableExecutorService$1.run(LoggableExecutorService.java:59)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724) Caused by:
org.postgresql.util.PSQLException: Fine memoria scaricando i risultati
della query. at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1816)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:510)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:386)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271) at
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at
org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
at
org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyPropertiesFromDatastore(AbstractEntityPersister.java:802)
... 73 more
Caused by: java.lang.OutOfMemoryError: Java heap space
feel free to ask for details you need!
Please help
Thanks
Memory management is a common problem with Jasper. You want to use a Jasper Virtualizer to cut down on the heap load.
I am having the exact same problem. Lots of fast running, small reports eventually wipe out memory. Eclipse MAT says that shortest path to GC Root is:
Ultimately this turned out to be a corrupt .jasper file. Regenerating the jasper file for the main report and all subreports fixed the issue for me.

HTTP Post with Matlab

I followed the example given in this post: How to send data from Matlab to Rails, but am receiving an error message that I cannot find any information on. My script looks like this:
javaaddpath('./httpcomponents/httpclient-4.2.2.jar')
javaaddpath('./httpcomponents/httpcore-4.2.2.jar')
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
httpclient = DefaultHttpClient();
httppost = HttpPost('http://localhost:3000/signin');
httppost.addHeader('Content-Type','application/json');
httppost.addHeader('Accept','application/json');
tokenRequest = StringEntity('{"session", "{email_address:""email#aol.com,""password:""password""}"}');
httppost.setEntity(tokenRequest);
response = httpclient.execute(httppost);
On the last line, I get the error:
Java exception occurred: java.lang.VerifyError: Cannot inherit from final class
From searches online, I gather that this is a software version issue. I tried using the 4.2 builds of those files (the same ones used in the other post), but I received the same error. Does anyone have an idea what could be wrong? Or know a way to do what I am trying to do without using these external libraries?
EDIT:
originally I tried using this code:
tokenRequest = {'session', '{''email_address'':''email#aol.com'',''password'':''password''}'};
token = urlread('http://localhost:3000/signin','POST',tokenRequest);
but I received the NoMethodError that led me to that other post:
NoMethodError (undefined method `each' for "{'email_address':'email#aol.com','password':'password'}":String):
app/models/session.rb:14:in `initialize'
I think the reason it throws this error is because the server thinks it is receiving a String object, which doesn't have an each method. I assume I would fix this by using the 'Content-Type' argument to specify that its json. Is there a way to do this using urlread?
EDIT: full stack trace for java libs issue
Java exception occurred:
java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at com.mathworks.jmi.CustomURLClassLoader.findClass(ClassLoaderManager.java:760)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.apache.http.impl.client.DefaultHttpClient.createHttpParams(DefaultHttpClient.java:157)
at org.apache.http.impl.client.AbstractHttpClient.getParams(AbstractHttpClient.java:448)
at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:309)
at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:466)
at org.apache.http.impl.client.AbstractHttpClient.createHttpContext(AbstractHttpClient.java:286)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:851)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
Looks like the data being sent is not properly quoted. End result should be
{'email_address':'email#aol.com','password':'password'}
Try changing the code to
tokenRequest = StringEntity('{"session", {"email_address":"email#aol.com","password":"password"}}');
urlread2 turned out to be a much better solution. This code does the job:
tokenRequest = '{ "session" : { "email_address": "email#aol.com", "password": "password" } }';
header = http_createHeader('Content-Type','application/json');
token = urlread2('http://localhost:3000/signin.json','POST',tokenRequest,header);

issue with SAX parser in java

When web service is called by using SOAP request it will give following parse error.
I have check about the prolog of request its right there is no whitespace or dash. Even though it will cause following error
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Un
known Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispat
ch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Un
known Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Sour
ce)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
at requestModel.SimpleCheckMail.checkMail(SimpleCheckMail.java:162)
at model.InboxDataBean.prepareList(InboxDataBean.java:97)
at model.InboxDataBean.getemailList(InboxDataBean.java:207)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELR
esolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELRe
solver.java:203)
at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:1
89)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpress
ion.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.
java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.
java:182)
at javax.faces.component.UIData.getValue(UIData.java:731)
at javax.faces.component.UIData.getDataModel(UIData.java:1798)
at javax.faces.component.UIData.setRowIndexWithoutRowStatePreserved(UIDa
ta.java:484)
at javax.faces.component.UIData.setRowIndex(UIData.java:473)
at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRen
derer.java:81)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.jav
a:820)
at javax.faces.component.UIData.encodeBegin(UIData.java:1118)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1754)
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:1756)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView
(FaceletViewHandlingStrategy.java:401)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewH
andler.java:131)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePha
se.java:121)
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:410)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
torBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp
11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
AbstractProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoin
t.java:1805)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:907)
at java.lang.Thread.run(Thread.java:619)
Please let me know whats the problem......of this error....thanx in advance
Ya....all of you are right ....But what i am getting is that it is an SOAP request and i have already see the request carefully there is no bad character.....But the problem is that when i am invoking the web service through soap request it gives null as a respone so i am getting the error.....
As soon as Webservice work properly ......this works fine now....thanks all of you
It means that there is something in xml before <?xml ... look carefully in it. Also check that there is no invisible character (you can do it in any HEX editor). Sometimes windows notepad adds his marker in the file beginning.
The parser sees character data before the actual XML itself is started. Either make sure your XML does not contain any stuff before the XML starts, or let your SAX parser ignore this...
Try to display the data you're actually parsing. Maybe some bad characters are inserted before the beginning of your xml, or maybe you're not reading the right file.
This may be a because of a BOM, if your XML file is stored as UTF-8 (which it probably is).
Here, you have an example of an InputStream, that gets rid of the BOM.

Accessing Magento API with Java : Procedure ххх not present

I need to build Special Java Api to wrap Magento Api. After struggling with several Magento bugs, I am finally able to login and get session id; but any method I call leads me to an error. The error is:
Procedure '*procedure name*' not present
I generated Java code from wsdl using Eclipse build in plugin and wsdl located at my local server: http://localhost/magento/index.php/api/v2_soap?wsdl=1.
The example of java code I use:
Mage_Api_Model_Server_V2_HandlerPortTypeProxy proxy = new Mage_Api_Model_Server_V2_HandlerPortTypeProxy(
"http://localhost/magento/index.php/api/");
String sessionId = proxy.login("magentobot", "123456");
System.out.println("Session: " + sessionId);
CatalogProductEntity[] products = proxy.catalogProductList(sessionId, new Filters(), "");
And here is the exception I got:
Session: 12abdaf054fb7100b6c5d84ab8cb8311
Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
faultSubcode:
faultString: Procedure 'catalogProductList' not present
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:Procedure 'catalogProductList' not present
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 org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
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.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
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.client.AxisClient.invoke(AxisClient.java:165)
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 Magento.Mage_Api_Model_Server_V2_HandlerBindingStub.catalogProductList(Mage_Api_Model_Server_V2_HandlerBindingStub.java:3104)
at Magento.Mage_Api_Model_Server_V2_HandlerPortTypeProxy.catalogProductList(Mage_Api_Model_Server_V2_HandlerPortTypeProxy.java:260)
at Main2.main(Main2.java:14)
{http://xml.apache.org/axis/}hostname:Dacer
Here is the link to the official documentation: Magento product API
It says that the method is called catalog_product.list
The php code for the API works fine:
<?php
$proxy = new SoapClient('http://localhost/magento/index.php/api/?wsdl');
$sessionId = $proxy->login('magentobot', '123456');
$filters = array();
$products = $proxy->call($sessionId, 'product.list', array($filters));
var_dump($products);
?>
I will be glad to any help.
I've never used the API from java before, but looking over your code example, you said you generated code using the v2 WSDL (which is supposed to have better Java/.NET SOAP support), but in your code sample you're pointing at the v1 URL
http://localhost/magento/index.php/api/
I would assume you want your code sample pointing at
http://magento1point4.dev/index.php/api/v2_soap
but again, not a big Java (or SOAP, for that matter) guy, so appologies if there's something obvious I'm missing here.

Categories

Resources