drools xls error Failed to open Excel stream, please check that the content is xls97 format - excel

I am getting below error when I am trying the below line.
VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder();
Verifier verifier = vBuilder.newVerifier();
Reader reader = new InputStreamReader(multipartExcel.getInputStream());
DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType(DecisionTableInputType.XLS);
verifier.addResourcesToVerify(ResourceFactory.newReaderResource(reader), ResourceType.DTABLE, dtconf);
The same code is working fine in my windows pc. But when I deploy as a docker into a linux vm I am getting this error. I tried the size of file received in both servers, its same.
equest processing failed; nested exception is org.drools.template.parser.DecisionTableParseException: Failed to open Excel stream, please check that the content is xls97 format.] with root cause
java.io.IOException: Your InputStream was neither an OLE2 stream, nor an OOXML stream
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:258) ~[poi-4.1.2.jar:4.1.2]
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:221) ~[poi-4.1.2.jar:4.1.2]
at org.drools.decisiontable.parser.xls.ExcelParser.parseFile(ExcelParser.java:101) ~[drools-decisiontables-7.46.0.Final.jar:7.46.0.Final]
at org.drools.decisiontable.SpreadsheetCompiler.parseResource(SpreadsheetCompiler.java:136) ~[drools-decisiontables-7.46.0.Final.jar:7.46.0.Final]
at org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:120) ~[drools-decisiontables-7.46.0.Final.jar:7.46.0.Final]
at org.drools.decisiontable.SpreadsheetCompiler.compile(SpreadsheetCompiler.java:93) ~[drools-decisiontables-7.46.0.Final.jar:7.46.0.Final]
at org.drools.decisiontable.DecisionTableProviderImpl.compileResource(DecisionTableProviderImpl.java:74) ~[drools-decisiontables-7.46.0.Final.jar:7.46.0.Final]
at org.drools.decisiontable.DecisionTableProviderImpl.loadFromResource(DecisionTableProviderImpl.java:42) ~[drools-decisiontables-7.46.0.Final.jar:7.46.0.Final]
at org.drools.compiler.compiler.DecisionTableFactory.loadFromResource(DecisionTableFactory.java:35) ~[drools-compiler-7.46.0.Final.jar:7.46.0.Final]
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.decisionTableToPackageDescr(KnowledgeBuilderImpl.java:412) ~[drools-compiler-7.46.0.Final.jar:7.46.0.Final]
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addPackageFromDecisionTable(KnowledgeBuilderImpl.java:381) ~[drools-compiler-7.46.0.Final.jar:7.46.0.Final]
at org.drools.compiler.builder.impl.KnowledgeBuilderImpl.addKnowledgeResource(KnowledgeBuilderImpl.java:749) ~[drools-compiler-7.46.0.Final.jar:7.46.0.Final]
at org.drools.verifier.builder.VerifierPackageBuilder.addKnowledgeResource(VerifierPackageBuilder.java:40) ~[drools-verifier-drl-7.46.0.Final.jar:7.46.0.Final]
at org.drools.verifier.builder.VerifierImpl.addResourcesToVerify(VerifierImpl.java:199) ~[drools-verifier-drl-7.46.0.Final.jar:7.46.0.Final]
at RuleService.validateRule(RuleService.java:272) ~[rule-1.0.0.jar:na]
at RuleService.saveRule(RuleService.java:87) ~[rule-1.0.0.jar:na]
at RuleController.createRule(RuleController.java:70) ~[rule-1.0.0.jar:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]

Finally I resolved it. Posting here, as if this help others.
Instead of passing reader, I 've saved the multipart into a file and passed the file into the ResourceFactory. like below
verifier.addResourcesToVerify(ResourceFactory.newFileResource(downloadedFile), ruleResourceType, dtconf);

Related

How do I avoid the stream from closing abruptly while I am reading the records from an upstream OData Service while using GetAllRequestBuilder?

I am trying to read about 3.9 million records from an upstream odata service using GetAllRequestBuilder. The code sets the pageSize to 5000 and uses the instance of HttpDestination to read from the upstream service.
The exact snippet that is executed :
CompletableFuture.runAsync(() ->{
// initial setup code for destination
Stream<Product> stream = new DefaultProductService()
.getAllProduct()
.withPreferredPageSize(5000)
.streamingEntities()
.execute(sourceDestination);
// ...
stream.peek(entry -> {log.info("entry: " + entry.toString());})
.forEach(entry -> publishOnEventBus(entry));
});
After a while, I receive an ODATADeserializationException. I cannot share the exact stack trace, but in the stack trace I see Caused by: com.google.gson.JsonIOException: java.io.IOException: Stream closed.
The exception is thrown in the class HttpEntityReader.
"com.sap.cloud.sdk.datamodel.odata.client.exception.ODataDeserializationException: A problem occurred while streaming the OData response.","tat com.sap.cloud.sdk.datamodel.odata.client.request.HttpEntityReader.lambda$stream$0(HttpEntityReader.java:121)"
This occurs abruptly, during multiple runs, sometimes 66k records are read, sometimes 400k, sometimes 14k.
Note : We use com.sap.cloud.sdk.datamodel to generate the service classes. We use getAllProduct that returns a GetAllRequestBuilder. The execute method itself returns deserialized entities.
Is there something that I can do to ensure that this exception does not occur and stream continues reading to the end? We are using sap-cloud-sdk version 3.48.0.

How to fix the error: org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file?

First I had the following error: GenericFileOperationFailedException - Cannot change directory to: ..]
I've fixed it by adding stepwise=false to the endpoint string:
sftp://sales.data.com:22/data/100?fileName=20190410.dat.gz&password=xxxxxx&stepwise=false&username=UserName
After that it failed with the below Error and I could not find any relevant information about fixing this. What could cause the problem here?
org.apache.camel.component.file.GenericFileOperationFailedException: Cannot retrieve file: data/100/20190410.dat.gz
at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:692)
at org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:638)
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:411)
at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:137)
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:226)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:190)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:175)
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:102)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.InterruptedIOException
at java.io.PipedInputStream.read(PipedInputStream.java:328)
at java.io.PipedInputStream.read(PipedInputStream.java:377)
at com.jcraft.jsch.ChannelSftp.fill(ChannelSftp.java:2325)
at com.jcraft.jsch.ChannelSftp.header(ChannelSftp.java:2351)
at com.jcraft.jsch.ChannelSftp.access$800(ChannelSftp.java:36)
at com.jcraft.jsch.ChannelSftp$2.read(ChannelSftp.java:1093)
at com.jcraft.jsch.ChannelSftp$2.read(ChannelSftp.java:1053)
at org.apache.camel.util.IOHelper.copy(IOHelper.java:204)
at org.apache.camel.util.IOHelper.copy(IOHelper.java:169)
at org.apache.camel.util.IOHelper.copyAndCloseInput(IOHelper.java:218)
at org.apache.camel.util.IOHelper.copyAndCloseInput(IOHelper.java:214)
at org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:687)
Use a readLock on your consumer, making it wait until the file has been fully FTP-ed.
In the Camel documentation for ftp, look for this option:
readLock-changed
The idea is: tell Camel not to read the file when it sees it, but to keep checking to see if it is growing in size. As long as it keeps growing, Camel will wait. You can change related options to determine how long to wait, etc. Search through that page for all mentions of "readLock" to find more.

can't open link via selenium while link opens manually

I need to automate procedure of filling one form on some site. I could easily do it manually. I go to site, login and click on link - Go to form filling.
But then I run selenium test, it fails then clicks on link Go to form filling. The error is:
Internet Explorer cound not display webpage.
I guess it could be because of some security rule on this site. But I do not know how to fix it.
Could someone advice me what could be done in such occasions? Thanks
Updates:
2) Is this site AJAX heavy? - no
3) Are you using implicit or explicit timers? - I have tried explicit waits - no help
4) What code is failing and what error message does your IDE throw - the error is that driver could not find element. This element became visible after likk opens. as link is failed to open - this error is raised. so I write error message from IE as it is the root cause.
5)HtmlUnitDriver - do not try
Code:
driver.get(linkToConsole);
driver.findElement(By.xpath(loginLocator)).sendKeys(login);
driver.findElement(By.xpath(passwordLocator)).sendKeys(password);
driver.findElement(By.xpath(submitButton)).click();
wait = new WebDriverWait(driver, 5000);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(goToHomePageLocator)));
//this link doesn't open (but it works manually)
driver.findElement(By.xpath(goToHomePageLocator)).click();
// this element is not found and here error in IDE is raised
driver.findElement(By.id(manualValidation)).click();
Error:
org.openqa.selenium.NoSuchElementException:
Unable to find element with id == myid (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 30.12 seconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.37.0', revision: 'a7c61cb', time: '2013-10-18 17:14:00'
System info:
Session ID: 0976b47d-caf5-42fc-9e48-5c8a8c18e624
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{platform=WINDOWS, javascriptEnabled=true, elementScrollBehavior=0, ignoreZoomSetting=false, enablePersistentHover=true, ie.ensureCleanSession=false, browserName=internet explorer, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss, version=9, ie.usePerProcessProxy=false, ignoreProtectedModeSettings=true, cssSelectorsEnabled=true, requireWindowFocus=false, initialBrowserUrl=http://localhost:12015/, handlesAlerts=true, ie.forceCreateProcessApi=false, nativeEvents=true, browserAttachTimeout=0, ie.browserCommandLineSwitches=, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:348)
at org.openqa.selenium.By$ById.findElement(By.java:220)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
at test.java.org.fullProcess.fillConsole(FullProcess.java:87)
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:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Try changing the Protected Mode settings.
Tools --> Internet Options --> Security Tab --> Select "Enable Protected Mode" for all zones.
I assume this should be the reason for your issue.
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
ieCapabilities.setCapability("ensureCleanSession", true);
driver = new InternetExplorerDriver(ieCapabilities);
Source: http://mestachs.wordpress.com/2012/08/13/selenium-best-practices/

org.apache.thrift.transport.TTransportException: Cannot read. Remote side has closed

I'm new to use astyanax connecting to cassandra(1.2.8).
I downloaded astyanax from [https://github.com/Netflix/astyanax] and cassandra from [http://www.apache.org/dyn/closer.cgi?path=/cassandra/1.2.8/apache-cassandra-1.2.8-bin.tar.gz]. Everything is installed/built based on instruction and keep default settings(like conf/cassandra.yaml). Now I try to run the sample code [https://github.com/Netflix/astyanax/blob/master/astyanax-examples/src/main/java/com/netflix/astyanax/examples/AstCQLClient.java], and a disgusting error keeps bothering me(showed at eclipse):
Caused by: com.netflix.astyanax.connectionpool.exceptions.PoolTimeoutException: PoolTimeoutException: [host=127.0.0.1(127.0.0.1):9160, latency=5021(5021), attempts=1]Timed out waiting for connection
As I enable cassandra debug mode, the below is showed on the terminal:
DEBUG 17:06:48,968 Thrift transport error occurred during processing of message.
org.apache.thrift.transport.TTransportException: Cannot read. Remote side has closed. Tried to read 4 bytes, but only got 0 bytes. (This is often indicative of an internal error on the server side. Please check your server logs.)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86)
at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378)
at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297)
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:204)
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:22)
at org.apache.cassandra.thrift.CustomTThreadPoolServer$WorkerProcess.run(CustomTThreadPoolServer.java:199)
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)
Just to emphasize, I don't change anything in cassandra.yaml(actually I don't know what they mean); all the libs from astyanax and from cassandra-1.2.8 are all imported to the java project.
I guess the problem is due to that connections will shut down when I try to flush through frame transform... I'm a noob to database. I do appreciate to all the helps!
ps. I'm waiting on stackoverflow. If any logs you need to check(please also give me the directory to find it. I'm noob>_<), just say and I'll fetch it. Thanks a lot!!
Even though this is an old question and I'm not sure if my suggestion will help anyone but I faced the same error and here is how I solved it. Hopefully this will help another poor soul.
I was seeing the same error "cannot read remote side has closed" , but I was using csharp, Apache.Cassandra namespace and Thrift.dll.
The following is a working snippet,
TSocket socket = null;
TTransport transport = null;
socket = new TSocket("localhost", 9160);
transport = new TFramedTransport(socket);
TProtocol protocol = new TBinaryProtocol(transport);
CassandraClient cassandraClient = new CassandraClient(protocol);
cassandraClient.InputProtocol.Transport.Open();
The trick was to use cassandraClient.InputProtocol.Transport.Open(); rather than transport.open()

Bulk data upload in Cassandra using Pelops

I am using Pelops to work with Cassandra. I want to insert bulk data using mutator. When i insert around 20000 records it works fine but when I exceed the no of records it shows me a "Connection reset by peer: socket write error". I am writing the following code.
Pelops.addPool(CASSANDRA_POOL, new Cluster(CASSANDRA_HOST,
CASSANDRA_PORT), CASSANDRA_KEYSPACE);
Mutator mutator = Pelops.createMutator(CASSANDRA_POOL);
//writing cols in mutator
mutator.execute(CL_ONE)
But it is working for some limited no of records.
I am getting following error:
2757 17:42:01,211 DEBUG org.scale7.cassandra.pelops.pool.CommonsBackedPool - Attempting to borrow free connection for node 'localhost'
2757 17:42:01,211 DEBUG org.scale7.cassandra.pelops.pool.CommonsBackedPool - Borrowing connection 'Connection[MyKeyspace][localhost:9160][44937684]'
2977 17:42:01,431 WARN org.scale7.cassandra.pelops.Operand - Operation failed as result of network exception. Connection to node localhost is being marked as corrupt (and will probably be be destroyed). Cause of failure is org.apache.thrift.transport.TTransportException: java.net.SocketException: Connection reset by peer: socket write error
2977 17:42:01,431 DEBUG org.scale7.cassandra.pelops.pool.CommonsBackedPool - Returned connection 'Connection[MyKeyspace][localhost:9160][44937684]' has been closed or is marked as corrupt
2977 17:42:01,431 DEBUG org.scale7.cassandra.pelops.pool.CommonsBackedPool - Destroying connection 'Connection[MyKeyspace][localhost:9160][44937684]'
Exception in thread "main" org.scale7.cassandra.pelops.exceptions.TransportException: java.net.SocketException: Connection reset by peer: socket write error
at org.scale7.cassandra.pelops.exceptions.IExceptionTranslator$ExceptionTranslator.translate(IExceptionTranslator.java:57)
at org.scale7.cassandra.pelops.Operand.tryOperation(Operand.java:115)
at org.scale7.cassandra.pelops.Mutator.execute(Mutator.java:102)
at org.scale7.cassandra.pelops.Mutator.execute(Mutator.java:71)
at org.brickred.Cassandra.insertData(Cassandra.java:182)
at org.brickred.Test.main(Test.java:7)
Caused by: org.apache.thrift.transport.TTransportException: java.net.SocketException: Connection reset by peer: socket write error
at org.apache.thrift.transport.TIOStreamTransport.write(TIOStreamTransport.java:147)
at org.apache.thrift.transport.TFramedTransport.flush(TFramedTransport.java:157)
at org.apache.cassandra.thrift.Cassandra$Client.send_batch_mutate(Cassandra.java:1020)
at org.apache.cassandra.thrift.Cassandra$Client.batch_mutate(Cassandra.java:1008)
at org.scale7.cassandra.pelops.Mutator$1.execute(Mutator.java:97)
at org.scale7.cassandra.pelops.Mutator$1.execute(Mutator.java:93)
at org.scale7.cassandra.pelops.Operand.tryOperation(Operand.java:81)
... 4 more
Caused by: java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at org.apache.thrift.transport.TIOStreamTransport.write(TIOStreamTransport.java:145)
... 10 more

Resources