Discussion:
tomcat and sqlite
Saleem Haseeb
2018-09-10 07:38:42 UTC
Permalink
Hi,
I am trying to use sqlite in a web application on tomcat version 8.0.41
The driver that I use to connect to sqlite from within the web application is

<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.23.1</version>
</dependency>

I am using Linux to deploy the application and whenever there is a connection first made to the database I get the driver .so files created as below:

sqlite-3.23.1-71f96c59-5318-4b40-8505-8000876a12e7-libsqlitejdbc.so
sqlite-3.23.1-71f96c59-5318-4b40-8505-8000876a12e7-libsqlitejdbc.so.lck

in the contextDestroyed() hook I am trying to do something as following to deregister the driver on my classloader for the webapp like


private void deregisterDrivers() {
Enumeration<Driver> drivers = DriverManager.getDrivers();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
if (driver.getClass().getClassLoader() == cl) {
try {
logger.info("Deregistering jdbc driver: {}", driver);
DriverManager.deregisterDriver(driver);
} catch (SQLException e) {
logger.info("Error deregistering driver {} due to {}", driver, e);
}
}
}
}

the above as pointed out in some questions at stackoverflow says is implementation dependent, so I verified and found out that it does not delete those so and lck files.

As a workaround, I then tried in the same contextDestroyed method, to delete the .so and .so.lck files but then that creates files with the pattern .nfsyyyyyyy on my disk. These files seem like the driver files and for some reason, if I try to delete those as part of clean up, I get the message "Device is Busy" and the .nfs* files hang on the disk and also don't get removed by the OS.

I am struggling here to get rid of the drivers gracefully on application undeployment. Any help is appreciated!

Regards,
Haseeb
Mark Thomas
2018-09-10 08:08:10 UTC
Permalink
Post by Saleem Haseeb
Hi,
I am trying to use sqlite in a web application on tomcat version 8.0.41
The driver that I use to connect to sqlite from within the web application is
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.23.1</version>
</dependency>
sqlite-3.23.1-71f96c59-5318-4b40-8505-8000876a12e7-libsqlitejdbc.so
sqlite-3.23.1-71f96c59-5318-4b40-8505-8000876a12e7-libsqlitejdbc.so.lck
in the contextDestroyed() hook I am trying to do something as following to deregister the driver on my classloader for the webapp like
private void deregisterDrivers() {
Enumeration<Driver> drivers = DriverManager.getDrivers();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
if (driver.getClass().getClassLoader() == cl) {
try {
logger.info("Deregistering jdbc driver: {}", driver);
DriverManager.deregisterDriver(driver);
} catch (SQLException e) {
logger.info("Error deregistering driver {} due to {}", driver, e);
}
}
}
}
the above as pointed out in some questions at stackoverflow says is implementation dependent, so I verified and found out that it does not delete those so and lck files.
As a workaround, I then tried in the same contextDestroyed method, to delete the .so and .so.lck files but then that creates files with the pattern .nfsyyyyyyy on my disk. These files seem like the driver files and for some reason, if I try to delete those as part of clean up, I get the message "Device is Busy" and the .nfs* files hang on the disk and also don't get removed by the OS.
I am struggling here to get rid of the drivers gracefully on application undeployment. Any help is appreciated!
Where is the JDBC located? &CATALINA_BASE/lib, WEB-INF/lib, somewhere else?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Saleem Haseeb
2018-09-10 08:12:33 UTC
Permalink
HI Mark,
The jar file is in the application lib so yes, under WEB-INF/lib directory :)

Regards,
Haseeb

-----Original Message-----
From: Mark Thomas [mailto:***@apache.org]
Sent: den 10 september 2018 10:08
To: Tomcat Users List <***@tomcat.apache.org>
Subject: Re: tomcat and sqlite
Post by Saleem Haseeb
Hi,
I am trying to use sqlite in a web application on tomcat version
8.0.41 The driver that I use to connect to sqlite from within the web
application is
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.23.1</version>
</dependency>
sqlite-3.23.1-71f96c59-5318-4b40-8505-8000876a12e7-libsqlitejdbc.so
sqlite-3.23.1-71f96c59-5318-4b40-8505-8000876a12e7-libsqlitejdbc.so.lc
k
in the contextDestroyed() hook I am trying to do something as
following to deregister the driver on my classloader for the webapp
like
private void deregisterDrivers() {
Enumeration<Driver> drivers = DriverManager.getDrivers();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
if (driver.getClass().getClassLoader() == cl) {
try {
logger.info("Deregistering jdbc driver: {}", driver);
DriverManager.deregisterDriver(driver);
} catch (SQLException e) {
logger.info("Error deregistering driver {} due to {}", driver, e);
}
}
}
}
the above as pointed out in some questions at stackoverflow says is implementation dependent, so I verified and found out that it does not delete those so and lck files.
As a workaround, I then tried in the same contextDestroyed method, to delete the .so and .so.lck files but then that creates files with the pattern .nfsyyyyyyy on my disk. These files seem like the driver files and for some reason, if I try to delete those as part of clean up, I get the message "Device is Busy" and the .nfs* files hang on the disk and also don't get removed by the OS.
I am struggling here to get rid of the drivers gracefully on application undeployment. Any help is appreciated!
Where is the JDBC located? &CATALINA_BASE/lib, WEB-INF/lib, somewhere else?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Mark Thomas
2018-09-10 08:16:59 UTC
Permalink
Post by Saleem Haseeb
HI Mark,
The jar file is in the application lib so yes, under WEB-INF/lib directory :)
Thanks. That de-registration code looks to be correct to me.

I suspect that this might require a change in the Driver. Some things to
test:
- can you delete the files if you shut Tomcat down first?
- how does the driver behave if you access it via a stand-along Java
application

I suggest you try and recreate this with a stand-alone Java app and if
you still see the problem. If you do, I'd suggest opening an issue
against the driver.

Mark
Post by Saleem Haseeb
Regards,
Haseeb
-----Original Message-----
Sent: den 10 september 2018 10:08
Subject: Re: tomcat and sqlite
Post by Saleem Haseeb
Hi,
I am trying to use sqlite in a web application on tomcat version
8.0.41 The driver that I use to connect to sqlite from within the web
application is
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.23.1</version>
</dependency>
sqlite-3.23.1-71f96c59-5318-4b40-8505-8000876a12e7-libsqlitejdbc.so
sqlite-3.23.1-71f96c59-5318-4b40-8505-8000876a12e7-libsqlitejdbc.so.lc
k
in the contextDestroyed() hook I am trying to do something as
following to deregister the driver on my classloader for the webapp
like
private void deregisterDrivers() {
Enumeration<Driver> drivers = DriverManager.getDrivers();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
if (driver.getClass().getClassLoader() == cl) {
try {
logger.info("Deregistering jdbc driver: {}", driver);
DriverManager.deregisterDriver(driver);
} catch (SQLException e) {
logger.info("Error deregistering driver {} due to {}", driver, e);
}
}
}
}
the above as pointed out in some questions at stackoverflow says is implementation dependent, so I verified and found out that it does not delete those so and lck files.
As a workaround, I then tried in the same contextDestroyed method, to delete the .so and .so.lck files but then that creates files with the pattern .nfsyyyyyyy on my disk. These files seem like the driver files and for some reason, if I try to delete those as part of clean up, I get the message "Device is Busy" and the .nfs* files hang on the disk and also don't get removed by the OS.
I am struggling here to get rid of the drivers gracefully on application undeployment. Any help is appreciated!
Where is the JDBC located? &CATALINA_BASE/lib, WEB-INF/lib, somewhere else?
Mark
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Christopher Schultz
2018-09-11 00:12:28 UTC
Permalink
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark and Saleem,
Post by Mark Thomas
HI Mark, The jar file is in the application lib so yes, under
WEB-INF/lib directory :)
Thanks. That de-registration code looks to be correct to me.
I suspect that this might require a change in the Driver. Some
things to test: - can you delete the files if you shut Tomcat down
first? - how does the driver behave if you access it via a
stand-along Java application
I suggest you try and recreate this with a stand-alone Java app and
if you still see the problem. If you do, I'd suggest opening an
issue against the driver.
What are those ".so" files? What is your OS?

I'm wondering if the driver is dropping shared libraries onto the disk
and then loading them using e.g. System.loadLibrary.

As far as I know, it is not possible to System.unloadLibrary, so weird
things might happen if/when you try to load the JDBC driver multiple
times. Even loading it once might end up with files that the JVM/OS is
unwilling to unlock.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAluXCGwACgkQHPApP6U8
pFgpSg//StH3zUrM5AKPueBcBjC+bpU1ZZV3v8UUhLSsNBgJPOc/M9MbJUXaFt90
TcSL6jX85/Dd5zUc2JyUFvmEiw1JFU+bnnTwqnV4y9tuSbLAhrIQw7a3bc9muhAd
M5ri5Wb8X81h0jj3pyVOAI+kU86boR3z7bbA2BI2Nbh6zjnTF+GgkZFXGkIY+05u
5jH+zXcvQAV7z7/auDvnIELd5KFyWF9nskelpaXOsJl5HxB89fkLwtyG75dJfLrE
2JoLoZbBaOuvQLYzUSCCSGRaOdSezlejAPoMfUlks8mkkmiQ17jYfa4EvwSKYy+n
gc+W32KZHk3loJ7C+zPj1RwqfT1aHBU8Yfky5KTQintOvPYXa9f3YB6s30Dh8oxD
TD6q/Ly9NGi5UlQmMJ3vEqFoT8jnu9uFlfAZgg3KKDGMFrCXKdfWNTP8bRiCs29D
1lc2DIitKLnq7xg89BXPFzYBqO7HBFVY/zKZnhKlnTZAyQ1QnMN+KFxq2wXXPjNL
36zfVhJ9/xWCnxH2jzZnKYaA0rHqasS4lyFUSQVrAMZg26fw02wZeoIQ/OeE4wTa
Vs9vYJmkcFPzOxcU9HXB12fvVI3R5rTJJT079xb/GC72kE4HIiuY4Uev1AWyvAtB
7sFlZIzF57eoIG+TfbJf8m23GD1Hd4lOPbW3LysaUzwv+Jg1HqY=
=dKRo
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Saleem Haseeb
2018-09-11 05:50:26 UTC
Permalink
Hi Christopher,
I am using Linux OS and the so files are somehow the driver file. There is also a .so.lck file created

Regards,
Haseeb

-----Original Message-----
From: Christopher Schultz [mailto:***@christopherschultz.net]
Sent: den 11 september 2018 02:12
To: ***@tomcat.apache.org
Subject: Re: tomcat and sqlite

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark and Saleem,
Post by Mark Thomas
HI Mark, The jar file is in the application lib so yes, under
WEB-INF/lib directory :)
Thanks. That de-registration code looks to be correct to me.
I suspect that this might require a change in the Driver. Some things
to test: - can you delete the files if you shut Tomcat down first? -
how does the driver behave if you access it via a stand-along Java
application
I suggest you try and recreate this with a stand-alone Java app and if
you still see the problem. If you do, I'd suggest opening an issue
against the driver.
What are those ".so" files? What is your OS?

I'm wondering if the driver is dropping shared libraries onto the disk and then loading them using e.g. System.loadLibrary.

As far as I know, it is not possible to System.unloadLibrary, so weird things might happen if/when you try to load the JDBC driver multiple times. Even loading it once might end up with files that the JVM/OS is unwilling to unlock.

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAluXCGwACgkQHPApP6U8
pFgpSg//StH3zUrM5AKPueBcBjC+bpU1ZZV3v8UUhLSsNBgJPOc/M9MbJUXaFt90
TcSL6jX85/Dd5zUc2JyUFvmEiw1JFU+bnnTwqnV4y9tuSbLAhrIQw7a3bc9muhAd
M5ri5Wb8X81h0jj3pyVOAI+kU86boR3z7bbA2BI2Nbh6zjnTF+GgkZFXGkIY+05u
5jH+zXcvQAV7z7/auDvnIELd5KFyWF9nskelpaXOsJl5HxB89fkLwtyG75dJfLrE
2JoLoZbBaOuvQLYzUSCCSGRaOdSezlejAPoMfUlks8mkkmiQ17jYfa4EvwSKYy+n
gc+W32KZHk3loJ7C+zPj1RwqfT1aHBU8Yfky5KTQintOvPYXa9f3YB6s30Dh8oxD
TD6q/Ly9NGi5UlQmMJ3vEqFoT8jnu9uFlfAZgg3KKDGMFrCXKdfWNTP8bRiCs29D
1lc2DIitKLnq7xg89BXPFzYBqO7HBFVY/zKZnhKlnTZAyQ1QnMN+KFxq2wXXPjNL
36zfVhJ9/xWCnxH2jzZnKYaA0rHqasS4lyFUSQVrAMZg26fw02wZeoIQ/OeE4wTa
Vs9vYJmkcFPzOxcU9HXB12fvVI3R5rTJJT079xb/GC72kE4HIiuY4Uev1AWyvAtB
7sFlZIzF57eoIG+TfbJf8m23GD1Hd4lOPbW3LysaUzwv+Jg1HqY=
=dKRo
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org

Т���������������������������������������������������������������������ХF�V�7V'67&�&R�R���âW6W'2�V�7V'67&�&TF��6B�6�R��&pФf�"FF�F����6����G2�R�
Saleem Haseeb
2018-09-11 14:31:13 UTC
Permalink
HI Mark,
I tried by creating a standalone application and to my surprise, there are no .so and .so.lck files generated.
I used the same dependency and everything seems fine!
I am wondering what should I try now. Is it tomcat that is messing stuff for me?
Any help is appreciated in this direction

Regards
Haseeb

-----Original Message-----
From: Mark Thomas [mailto:***@apache.org]
Sent: den 10 september 2018 10:17
To: ***@tomcat.apache.org
Subject: Re: tomcat and sqlite
Post by Saleem Haseeb
HI Mark,
The jar file is in the application lib so yes, under WEB-INF/lib directory :)
Thanks. That de-registration code looks to be correct to me.

I suspect that this might require a change in the Driver. Some things to
test:
- can you delete the files if you shut Tomcat down first?
- how does the driver behave if you access it via a stand-along Java
application

I suggest you try and recreate this with a stand-alone Java app and if you still see the problem. If you do, I'd suggest opening an issue against the driver.

Mark
Post by Saleem Haseeb
Regards,
Haseeb
-----Original Message-----
Sent: den 10 september 2018 10:08
Subject: Re: tomcat and sqlite
Post by Saleem Haseeb
Hi,
I am trying to use sqlite in a web application on tomcat version
8.0.41 The driver that I use to connect to sqlite from within the web
application is
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.23.1</version>
</dependency>
sqlite-3.23.1-71f96c59-5318-4b40-8505-8000876a12e7-libsqlitejdbc.so
sqlite-3.23.1-71f96c59-5318-4b40-8505-8000876a12e7-libsqlitejdbc.so.l
c
k
in the contextDestroyed() hook I am trying to do something as
following to deregister the driver on my classloader for the webapp
like
private void deregisterDrivers() {
Enumeration<Driver> drivers = DriverManager.getDrivers();
ClassLoader cl = Thread.currentThread().getContextClassLoader();
while (drivers.hasMoreElements()) {
Driver driver = drivers.nextElement();
if (driver.getClass().getClassLoader() == cl) {
try {
logger.info("Deregistering jdbc driver: {}", driver);
DriverManager.deregisterDriver(driver);
} catch (SQLException e) {
logger.info("Error deregistering driver {} due to {}", driver, e);
}
}
}
}
the above as pointed out in some questions at stackoverflow says is implementation dependent, so I verified and found out that it does not delete those so and lck files.
As a workaround, I then tried in the same contextDestroyed method, to delete the .so and .so.lck files but then that creates files with the pattern .nfsyyyyyyy on my disk. These files seem like the driver files and for some reason, if I try to delete those as part of clean up, I get the message "Device is Busy" and the .nfs* files hang on the disk and also don't get removed by the OS.
I am struggling here to get rid of the drivers gracefully on application undeployment. Any help is appreciated!
Where is the JDBC located? &CATALINA_BASE/lib, WEB-INF/lib, somewhere else?
Mark
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org

Т���������������������������������������������������������������������ХF�V�7V'67&�&R�R���âW6W'2�V�7V'67&�&TF��6B�6�R��&pФf�"FF�F����6����G2�R
Loading...