Eclipse Java Web Service can't read file - java

I've created a Java web service with Eclipse that was working excellently yesterday but now all of a sudden Scanner can't locate the file even though it's in the same directory!
I've tried finding the absolute path of it and providing the exact path but still it insists it cannot find it. However, if I just run it as a Java application it finds it! Am I doing something wrong in terms of trying to read a file with a web service?
The code I would have goes like this:
try {
File file = new File("./data.txt");
Scanner sc = new Scanner(file);
String[] arr = new String[3];
while(sc.hasNextLine()) {
String s = sc.nextLine();
arr = s.split(",");
}
}catch (FileNotFoundException e) {
e.printStackTrace();
}
The error I keep getting when running as a web service is
file foundjava.io.FileNotFoundException: ./data.txt (The system cannot fin
d the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.util.Scanner.<init>(Unknown Source)
at PasswordReset.passwordReset(PasswordReset.java:92)
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 org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397
)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:1
86)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
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:646)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:
327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171
)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Proce
ssor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(Abstrac
tProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:
314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.ja
va:61)
at java.lang.Thread.run(Unknown Source)
Does anyone know what the problem might be?

You are searching for the file in the wrong path.
Or the file isnt created when the program starts.
Please verify this two solutions, times ago a had the same issue.

(Posted on behalf of the OP).
Solved it. Just used ClassLoader and getResource() to actually find the file for Scanner to use and it worked!

if you run it as a Java application, "./data.txt" is in the same directory with this java class; if you run it as a web service,the directory is the work directory of server like jboss/jetty/tomcat ...

Related

Java Class "BCRSAPublicKey" Intermittently Not Found

Context
Using KNIME 4.1.2, Windows 10, x64, JDK 1.8, Java Edit Snippet
I am attempting to use the Java Snippet to read a CSV file, pgp encrypt it using a public key, and save the resulting file to a temporary folder
I have been attempting to use BounceCastle Library v1.65
try {
encryptFile(
"encryptedfile.csv.pgp",
"original.csv",
"/key/pub.asc",
false,
false);
} catch(Exception e) {
out_result = "fail";
}
The challenge is, I get the following error in the console INTERMITTENTLY and I am unclear what I am incorrectly providing to the library / not including. The confounding is because it is intermittent and sometimes yields the properly encrypted file.
Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/jcajce/provider/asymmetric/rsa/BCRSAPublicKey
at org.bouncycastle.jcajce.provider.asymmetric.rsa.KeyFactorySpi.engineGeneratePublic(Unknown Source)
at java.security.KeyFactory.generatePublic(KeyFactory.java:328)
at org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter.implGeneratePublic(Unknown Source)
at org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyConverter.getPublicKey(Unknown Source)
at org.bouncycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator.encryptSessionInfo(Unknown Source)
at org.bouncycastle.openpgp.operator.PublicKeyKeyEncryptionMethodGenerator.generate(Unknown Source)
at org.bouncycastle.openpgp.PGPEncryptedDataGenerator.open(Unknown Source)
at org.bouncycastle.openpgp.PGPEncryptedDataGenerator.open(Unknown Source)
at JSnippet.encryptFile(JSnippet.java:144)
at JSnippet.encryptFile(JSnippet.java:107)
at JSnippet.snippet(JSnippet.java:174)
at org.knime.base.node.jsnippet.JavaSnippetCellFactory.getCells(JavaSnippetCellFactory.java:300)

Microsoft Translator API error retrieving translation

I'm simply trying to run this sample code below:
import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;
public class Translator {
public static void main(String[] args) throws Exception {
Translate.setClientId("ID GOES HERE");
Translate.setClientSecret("SECRET GOES HERE");
String translatedText = Translate.execute("Bonjour le monde",
Language.FRENCH, Language.ENGLISH);
System.out.println(translatedText);
}
}
and I'm getting the following Exception:
Exception in thread "main" java.lang.Exception: [microsoft-translator-api] Error retrieving translation : datamarket.accesscontrol.windows.net
at com.memetix.mst.MicrosoftTranslatorAPI.retrieveString(MicrosoftTranslatorAPI.java:202)
at com.memetix.mst.translate.Translate.execute(Translate.java:61)
at Translator.main(Translator.java:10)
Caused by: java.net.UnknownHostException: datamarket.accesscontrol.windows.net
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.security.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
at com.memetix.mst.MicrosoftTranslatorAPI.getToken(MicrosoftTranslatorAPI.java:133)
at com.memetix.mst.MicrosoftTranslatorAPI.retrieveResponse(MicrosoftTranslatorAPI.java:160)
at com.memetix.mst.MicrosoftTranslatorAPI.retrieveString(MicrosoftTranslatorAPI.java:199)
... 2 more
I know it seems like I'm not even trying to figure this out on my own but I'm a complete beginner and can't really understand the Exception trace at all by myself. I'm pretty sure I got the right client Secret. In my azure account I only see an application ID and an Object ID. I'm using the application ID as the client ID.
Does anyone have any ideas on what might be causing this? Any help is greatly appreciated.
Thank you!
The third party Java wrapper boatmeme/microsoft-translator-java-api for MS Azure Translator API is too old & unavailable, because it wrappered the old Microsoft Translator - Text Translation which is old & unavailable now.
There is a notice at the page top of the site Azure datamarket.
DataMarket and Data Services are being retired and will stop accepting new orders after 12/31/2016. Existing subscriptions will be retired and cancelled starting 3/31/2017. Please reach out to your service provider for options if you want to continue service.
For using the new Azure Translator API on Azure portal, you need to refer to the document Announcements: Microsoft Translator Moves to the Azure portal to know how to create the new one on Azure portal and use it via the new REST APIs. Meanwhile, just as reference, you can see my answer in Java for the other SO thread Microsoft Translator API Java, How to get client new ID with Azure.
Hope it helps.

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.

SilkTest base state unrecognized after consecutive tests run

In my testing environment, we have classes that perform certain actions, some of them using SilkTest stuff. The test procedures are defined by XML files that we parse, turn into ActionImpl classes, and perform stuff with. For example, the following will login to our app, switch users, and then restart the server:
<Script refBean="validateState" retry="false">
<DataGroups>
<Step action="log" mod="5.10.13 - Step 1" />
<Step action="switchUsers" target="mlane" />
<Step action="restartServer" />
</DataGroups>
</Script>
In the case of the restartServer action, the code eventually calls the following method, which creates a BaseState using the currently running eclipse.exe that the test is running in.
private PassFail restartServerInEclipse() {
Desktop desktop = new Desktop();
BaseState eclipseBaseState = new BaseState("*eclipse.exe", "/Shell[#caption='Java EE*']", TechDomain.SWT, TechDomain.XBROWSER, TechDomain.WIN32);
desktop.executeBaseState(eclipseBaseState);
// Do some stuff, like finding CTabItem objects, clicking them, etc.
return passFail;
}
Let's say I'm running the first test of the day. I just got to work, and decided to run a test. If the code gets to a restartServer action, and calls restartServerInEclipse(), it'll recognize the currently running eclipse.exe, and successfully perform any Silk methods on any Silk objects that I tell it to.
However, without exiting Eclipse or Open Agent, after a test has finished, if I run the same test again, as in, entirely new objects, entirely new test thread, the test ran and stopped, and I clicked the green run button in Eclipse again, I get the following error when it gets to the BaseState eclipseBaseState = new BaseState(...) code:
com.borland.silktest.jtf.common.LaunchApplicationFailedException: Failed to start application '*eclipse.exe' in working directory 'null'. The system cannot find the file specified.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.borland.silktest.jtf.agent.ExceptionTranslatorUtil.createException(ExceptionTranslatorUtil.java:60)
at com.borland.silktest.jtf.agent.ExceptionTranslatorUtil.translate(ExceptionTranslatorUtil.java:37)
at com.borland.silktest.jtf.agent.JtfModule.executeBaseState_aroundBody39$advice(JtfModule.java:121)
at com.borland.silktest.jtf.agent.JtfModule.executeBaseState(JtfModule.java:1)
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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.remoting.support.RemoteInvocationTraceInterceptor.invoke(RemoteInvocationTraceInterceptor.java:77)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy24.executeBaseState(Unknown Source)
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 org.springframework.remoting.support.RemoteInvocation.invoke(RemoteInvocation.java:205)
at org.springframework.remoting.support.DefaultRemoteInvocationExecutor.invoke(DefaultRemoteInvocationExecutor.java:38)
at org.springframework.remoting.support.RemoteInvocationBasedExporter.invoke(RemoteInvocationBasedExporter.java:78)
at org.springframework.remoting.rmi.RmiBasedExporter.invoke(RmiBasedExporter.java:72)
at org.springframework.remoting.rmi.RmiInvocationWrapper.invoke(RmiInvocationWrapper.java:72)
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at org.springframework.remoting.support.RemoteInvocationUtils.fillInClientStackTraceIfPossible(RemoteInvocationUtils.java:47)
at org.springframework.remoting.rmi.RmiClientInterceptor.doInvoke(RmiClientInterceptor.java:351)
at org.springframework.remoting.rmi.RmiClientInterceptor.invoke(RmiClientInterceptor.java:258)
at com.borland.silktest.startservice.RmiConnectionUtil$1.invoke(RmiConnectionUtil.java:134)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy0.executeBaseState(Unknown Source)
at com.borland.silktest.jtf.Agent.executeBaseState(Agent.java:452)
at com.borland.silktest.jtf.BaseState.execute(BaseState.java:298)
at com.borland.silktest.jtf.Desktop.executeBaseState(Desktop.java:69)
at scripts.misc.validation.action.RestartServerActionImpl.restartServerInEclipse(RestartServerActionImpl.java:62)
at scripts.misc.validation.action.RestartServerActionImpl.evaluate(RestartServerActionImpl.java:25)
at scripts.misc.validation.ValidateState.evaluateStep(ValidateState.java:108)
at scripts.misc.validation.ValidateState.script(ValidateState.java:131)
at scripts.base.BaseScript.runWithRetries(BaseScript.java:204)
at scripts.base.BaseScript.runIt(BaseScript.java:312)
at suite.MainThread.script(MainThread.java:667)
at suite.MainThread.run(MainThread.java:281)
The base state that worked completely fine two seconds previous is now incorrect. As if something about Eclipse changes once the base state is initially set, so it can't re-recognize it.
The only way to get around this is to restart Eclipse and Open Agent, but even that doesn't work sometimes, and I run into some license server issues with OA occasionally, which requires a computer reboot.
From the log file you posted, I can see that you are switching between testing eclipse.exe and iexplore.exe. The way your script is currently built it is either one or the other. This means that as soon as you switch to Internet Explorer, Silk Test is detaching from Eclipse and will no longer recognize the window.
Since you are starting your applications through other mechanisms anyway, I suggest the attach method, which is cumulative and will add the pattern instead of replacing it, so you'll avoid switching between the applications.
Desktop desktop = new Desktop();
desktop.attach("*\\eclipse.exe", TechDomain.SWT, TechDomain.XBROWSER, TechDomain.WIN32);
desktop.attach("*\\iexplore.exe", TechDomain.SWT, TechDomain.XBROWSER, TechDomain.WIN32);
Shell eclipse = desktop.find("/Shell[#caption='Java EE*']");
BrowserApplication browserApp = desktop.find("/BrowserApplication");

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.

Categories

Resources