org.apache.poi.ss.usermodel.Sheet.getLastRowNum() always return 1048575 - apache-poi

I try to get last row index in Excel file using apache poi but getLastRowNum() always returns wrong number of rows and the number is always 1048575 .
My xlsx is simple. It has only three rows with content.
Here is the relevant code snippet:
Sheet sheet = workbook.getSheetAt(0);
int rowNum = sheet.getLastRowNum();
log.info("LastRowNum " + rowNum);
Apache POI version:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.2</version>
</dependency>
OS: "Arch Linux"
JAVA Version:
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)
I try upgrading apache poi but this doesn't fix the things.

Related

Anyone experiencing Error code -46 on Java SDK 1.20

Latest Java SDK (1.20) seems to throw NoSuchMethodError when trying to autheticate with the accesspoint using onAuthenticationRequired() ; Once the exception is thrown then all subsequent attempt to connect to the bridge will result in " Error - Code 46 Message bridge not responding"
Anyone experiencing this behaviour, code is executed on
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.8) (6b27-1.12.8)
OpenJDK Zero VM (build 20.0-b12, mixed mode)
Exception in thread "Thread-25" java.lang.NoSuchMethodError: java.lang.Integer.compare(II)I
at com.philips.lighting.hue.sdk.fbp.PHBridgeVersionManager$1.compare(PHBridgeVersionManager.java:83)
at com.philips.lighting.hue.sdk.fbp.PHBridgeVersionManager$1.compare(PHBridgeVersionManager.java:1)
at java.util.Arrays.mergeSort(Arrays.java:1283)
at java.util.Arrays.mergeSort(Arrays.java:1294)
at java.util.Arrays.sort(Arrays.java:1223)
at java.util.Collections.sort(Collections.java:176)
at com.philips.lighting.hue.sdk.fbp.PHBridgeVersionManager.setFallbackBridgeVersion(PHBridgeVersionManager.java:130)
at com.philips.lighting.hue.sdk.fbp.PHBridgeVersionManager.setBridgeVersion(PHBridgeVersionManager.java:365)
at com.philips.lighting.hue.sdk.connection.impl.PHBridgeInternal.processResponse(PHBridgeInternal.java:450)
at com.philips.lighting.hue.sdk.connection.impl.PHBridgeInternal$1.run(PHBridgeInternal.java:122)
Integer.compare was introduced in Java 7 and you're clearly using Java 6 based on the error message.
Try using Java 7 or Java 8.

How to connect select data from Informix database in python3 using pyodbc / unixODBC

I'm having a problem selecting data from Informix database tables using python3.5 and pyodbc/unixODBC.
I have a little py file (ifx.py) the contents of which are:
import pyodbc
db=pyodbc.connect('DSN=Test1')
db.execute("SELECT * FROM customer ")
and I get an error :
pyodbc.Error: ('HY000', '[HY000] [Informix][Informix ODBC Driver]Invalid byte in codeset conversion input. (21000) (SQLExecDirectW)')
All the searches I've done imply something to do with LOCALE settings, but I check and they're all set the same:
CLIENT_LOCALE=en_US.819
DB_LOCALE=en_US.819
dbs_collate=en_US.819
If I use the unixODBC 'isql' utility I can connect to and query the data happily.
Version Information.
unixODBC.x86_64 0:2.2.14-14.el6
pyodbc.version => '4.0.6'
Linux => Red Hat Enterprise Linux Server release 6.8
python3.5 => Python 3.5.3
Database => IBM Informix Dynamic Server Version 12.10.FC6X5
ClientSDK => IBM Informix CSDK Version 4.10, IBM Informix-ESQL Version 4.10.FC6
Environment Variable ODBCINI points to /etc/odbc.ini. Contents are:
[ODBC Data Sources]
Test1=IBM INFORMIX ODBC DRIVER
;
; Define ODBC Database Driver's Below - Driver Configuration Section
;
[Test1]
Driver=/opt/informix/lib/cli/iclis09b.so
Description=IBM INFORMIX ODBC DRIVER
Database=eunice
LogonID=
pwd=
Servername=indika_test
Port=9916
CursorBehavior=0
CLIENT_LOCALE=en_US.819
DB_LOCALE=en_US.819
TRANSLATIONDLL=/opt/informix/lib/esql/igo4a304.so
/etc/odbcinst.ini contents:
[ODBC Drivers]
IBM INFORMIX ODBC DRIVER=Installed
[IBM INFORMIX ODBC DRIVER]
Driver=/opt/informix/lib/cli/iclit09b.so
Setup=/opt/informix/lib/cli/iclit09b.so
APILevel=1
ConnectFunctions=YYY
DriverODBCVer=03.51
FileUsage=0
SQLLevel=1
smProcessPerConnect=Y
and odbcinst -j output is
unixODBC 2.2.14
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /etc/odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Thanks in advance for any help or suggestions.
This is probably due to an multibyte character in the customer table, which can not be converted to Latin 1, ISO 8859-1 from UTF8. Even with same codes set on both CLIENT_LOCALE and DB_LOCALE, an ODBC client makes an internal conversion from UTF-8 to 8859. If there are any 2-byte chars (chars beyond extended-ascii 255) they will not convert to a Latin-1 client. I would look at the data in customer table and identify the problematic data.
It is possible (or likely) that there is an Unicode encoding mismatch.
On my Debian system, the python builds (both 2.7 and 3.4) use UCS-4 encoding. You can verify with this command:
python3 -c "import sys;print(sys.maxunicode<66000 and'UCS2'or'UCS4')"
Once you find the encoding, you need to make sure the Informix odbc.ini file has the same Unicode encoding. In my odbc.ini file,
[ODBC]
;uncomment the below line for UNICODE connection
UNICODE=UCS-4
I hope this resolves your issue.
Thanks for the responses. It was unicode mismatch.
db=pyodbc.connect('DSN=Test1')
db.setdecoding(pyodbc.SQL_WCHAR, encoding='UTF-8')
db.setdecoding(pyodbc.SQL_CHAR, encoding='UTF-8')
db.setencoding(encoding='UTF-8')
By adding setencoding and setdecoding I was able to successfully select data form the Informix DB.

ClassNotFoundException with Openjdk on ubuntu

I have a problem with openjdk on ubuntu.
I have a java program that works perfectly on my machine (OSX 10.11). When I try to run it on the ubuntu I encounter errors telling me that classes are missing...
root#syncapp:/home/user# java -jar syncapp.jar
++ System >> Maximum heap size can used : 522190848 bytes
Exception in thread "main" java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(java.base#9-Ubuntu/Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(java.base#9-Ubuntu/NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(java.base#9-Ubuntu/DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(java.base#9-Ubuntu/Method.java:535)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: javax/activation/UnsupportedDataTypeException
at skay.com.xxx.yyy.sync.Application.createPIDFile(Application.java:67)
at skay.com.xxx.yyy.sync.Application.main(Application.java:29)
... 5 more
Caused by: java.lang.ClassNotFoundException: javax.activation.UnsupportedDataTypeException
at java.net.URLClassLoader.findClass(java.base#9-Ubuntu/URLClassLoader.java:388)
at java.lang.ClassLoader.loadClass(java.base#9-Ubuntu/ClassLoader.java:486)
at java.lang.ClassLoader.loadClass(java.base#9-Ubuntu/ClassLoader.java:419)
... 7 more
The line 67 of my "Application.java" file is :
final Matcher PID = Settings.get().patterns.get("PID_HOST").matcher( ManagementFactory.getRuntimeMXBean().getName() ) ;
Here is my configuration:
root#syncapp:/home/user# uname -a
Linux syncapp 4.8.0-22-generic #24-Ubuntu SMP Sat Oct 8 09:15:00 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
root#syncapp:/home/user# java -version
openjdk version "9-Ubuntu"
OpenJDK Runtime Environment (build 9-Ubuntu+0-9b134-2ubuntu1)
OpenJDK 64-Bit Server VM (build 9-Ubuntu+0-9b134-2ubuntu1, mixed mode)
Edit 1 :
Apparently it would come from a problem related to the version of openjdk installed. The following were available:
root#syncapp:/home/user# update-alternatives --config java
Il existe 3 choix pour l'alternative java (qui fournit /usr/bin/java).
Sélection Chemin Priorité État
------------------------------------------------------------
* 0 /usr/lib/jvm/java-9-openjdk-amd64/bin/java 1091 mode automatique
1 /usr/bin/gij-6 1060 mode manuel
2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 mode manuel
3 /usr/lib/jvm/java-9-openjdk-amd64/bin/java 1091 mode manuel
Appuyez sur <Entrée> pour conserver la valeur par défaut[*] ou choisissez le numéro sélectionné :
And following the message it turns out that JavaFX was not found. And we had to install the openjfx package. What's the location of the JavaFX runtime JAR file, jfxrt.jar, on Linux?
When I see the package page on the ubuntu package website (http://packages.ubuntu.com/yakkety/openjfx), I realized that it seems compatible with version 8 of the openjdk (openjdk-8-jre).
So I run the jar with this JRE and the blocking point previously encountered seems to have gone but another one has appeared. Apparently the following class seems to be absent (from the classpath) jdk/management/resource/ResourceRequestDeniedException.
root#syncapp:/home/user# /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -jar syncapp.jar
++ System >> Maximum heap size can used : 464519168 bytes
++ System >> PID (2125) created...
++ System >> USR2 Signal handled...
++ System >> Settings file (/home/user/resources/sets.ini) loaded.
++ System >> 4 worker(s) has been created and launched...
++ System >> Worker started (13#741054620)
++ System >> Worker started (10#1702086468)
++ System >> Worker started (11#1289522363)
++ System >> Worker started (12#194404)
[...]
++ System >> Database pool created (4/8)
[...]
Exception in thread "Thread-3" java.lang.NoClassDefFoundError: jdk/management/resource/ResourceRequestDeniedException
at skay.com.xxxx.yyyy.sync.core.job.associate.SynchronizeCalendarWithXXXXXXJob.apply(SynchronizeCalendarWithXXXXXXJob.java:139)
at skay.com.xxxx.yyyy.sync.core.threadpool.Worker.run(Worker.java:70)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: jdk.management.resource.ResourceRequestDeniedException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
So how I can add this library to the classpath please?
Edit 2 :
Just a small clarification regarding the "ResourceRequestDeniedException" exception. I voluntarily call it in my code in the case of a response to an HTTP request with a return code designating an error. For example here is the piece of code concerned by the exception mentioned above.
if( con == null || con.getResponseCode() != 200 )
throw new ResourceRequestDeniedException() ;
Where "con" is an "HttpURLConnection" object.
Edit 3 :
No response including on askubuntu.com. So I create a custom exception (extends Exception) to replace ResourceRequestDeniedException to see if another problem occurs. No additional problems, the application looks to run properly.

Datastax OpsCenter - Can't connect to Cassandra All host(s) tried for query failed

I have a two node and I installed DataStax OpsCenter on 10.5.0.201 but I give error ( Unable connect to any seed nodes ) when I create new cluster on OpsCenter. Can you check my config ?
address.yaml ( 10.5.0.201 )
address.yaml ( 10.5.0.203 )
nodetool status
DataStax OpsCenter
startup.log (10.5.0.201)
agent.log ( 10.5.0.201 )
Versions
Python 2.6.6
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
OpsCenter 5.2.4
Best Regards
In the comments of cassandra.yaml
# Note that unlike listen_address, you can specify 0.0.0.0, but you must also
# set broadcast_rpc_address to a value other than 0.0.0.0.
I would recommend to set rpc_address: 10.5.0.201 for the 1st node and to retry

Spark SQL: TwitterUtils Streaming fails for unknown reason

I am using the latest Spark master and additionally, I am loading these jars:
- spark-streaming-twitter_2.10-1.1.0-SNAPSHOT.jar
- twitter4j-core-4.0.2.jar
- twitter4j-stream-4.0.2.jar
My simple test program that I execute in the shell looks as follows:
import org.apache.spark.streaming._
import org.apache.spark.streaming.twitter._
import org.apache.spark.streaming.StreamingContext._
System.setProperty("twitter4j.oauth.consumerKey", "jXgXF...")
System.setProperty("twitter4j.oauth.consumerSecret", "mWPvQRl1....")
System.setProperty("twitter4j.oauth.accessToken", "26176....")
System.setProperty("twitter4j.oauth.accessTokenSecret", "J8Fcosm4...")
var ssc = new StreamingContext(sc, Seconds(1))
var tweets = TwitterUtils.createStream(ssc, None)
var statuses = tweets.map(_.getText)
statuses.print()
ssc.start()
However, I won't get any tweets. The main error I see is
14/08/04 10:52:35 ERROR scheduler.ReceiverTracker: Deregistered receiver for stream 0: Error starting receiver 0 - java.lang.NoSuchMethodError: twitter4j.TwitterStream.addListener(Ltwitter4j/StatusListener;)V
at org.apache.spark.streaming.twitter.TwitterReceiver.onStart(TwitterInputDStream.scala:72)
....
And then for each iteration:
INFO scheduler.ReceiverTracker: Stream 0 received 0 blocks
I'm not sure where the problem lies.
How can I verify that my twitter credentials are correctly recognized?
Might there be another jar missing?
NoSuchMethodError should always cause you to ask whether you are running with the same versions of libraries and classes that you compiled with.
If you look at the pom.xml file for the Spark examples module, you'll see that it uses twitter4j 3.0.3. You're bringing incompatible 4.0.2 with you at runtime and that breaks it.
Yes, Sean Owen has given the good reason, after I add two dependency files on the pom.xml file:
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-stream</artifactId>
<version>3.0.6</version>
</dependency>
In this way we change the default twitter4j version from 4.0.x to 3.0.x (http://mvnrepository.com/artifact/org.twitter4j/twitter4j-core), then the incompatible problem will be solved.

Resources