On 17-02-2023 16:39, shalamyansky wrote:
> I developе services based on Java 8, Spring JPA, Firebird and use
> IntelliJ IDEA with maven as tool. Recently, the service generates an
> error when closing. This error appears only when debugging under IDEA,
> but not in production mode. Therefore, it is uncritical, but unpleasant.
> Here is stack frames from log:
>
> 2023-02-17 17:57:30.999 INFO 2588 --- [ionShutdownHook]
> j.LocalContainerEntityManagerFactoryBean : Closing JPA
> EntityManagerFactory for persistence unit 'default'
> 2023-02-17 17:57:31.002 INFO 2588 --- [ionShutdownHook]
> com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown
> initiated...
> [WARNING]
> java.lang.UnsatisfiedLinkError: Error looking up function
> 'isc_detach_database': Library has been unloaded
> at com.sun.jna.Function.<init>[WARNING]
> java.lang.UnsatisfiedLinkError: Error looking up function
> 'isc_detach_database': Library has been unloaded
> at com.sun.jna.Function.<init>[WARNING]
[..]
>
> Sometimes instead of Error looking up function 'isc_detach_database':
> Library has been unloaded I see Memory access error.
>
> I use Jaybird native access to Firebird via jna.
>
> What's the matter?
It sounds like the shutdown hook or the NativeResourceUnloadWebListener
has run. I need exact reproduction steps to be able to identify a cause,
but likely it is caused by some form of the runtime
replacement/reloading of classes triggering a servlet context reload, or
maybe the servlet context being closed before other things that still
need to use connections.
I would be grateful if you could provide me with a reproduction recipe
with a minimal set of code and steps to reproduce to see if that is
something that can be addressed.
In any case, the workaround is to disable the native resource unloading
(set system property org.firebirdsql.nativeResourceShutdownDisabled to
true (e.g. -Dorg.firebirdsql.nativeResourceShutdownDisabled=true in your
run properties), or just not use native URLs.
To be honest, in a web application like yours it is my opinion that you
should use the pure Java connections, not native connections. There is
IMHO no good reason to use native connections, except maybe when you
need to use embedded (but then again, you shouldn't use embedded in a
web application).
[..]
>
> application.properties (fragments):
> spring.datasource.driverClassName:org.firebirdsql.jdbc.FBDriver
> spring.datasource.url:jdbc:firebirdsql:local:egrulapi?encoding=WIN1251
Have you read the Jaybird 5 release notes[1]? The sub-protocol local is
deprecated (technically even removed and aliased to native) and will
probably be removed entirely in a future version (maybe Jaybird 6, maybe
later). What you have works exactly the same as specifying native and is
not guaranteed to use a "local" IPC connection (neither did previous
versions, which is why it is deprecated). If you want to ensure you're
using "local" IPC connections, you'll need to use
jdbc:firebirdsql:native:xnet://egrulapi?encoding=WIN1251 (be aware, the
linked release notes have a typo, showing xnet// instead of xnet://).
However, my main advice would be to use
jdbc:firebirdsql://localhost/egrulapi?encoding=WIN1251 instead.
Mark
[1]:
https://www.firebirdsql.org/file/documentation/drivers_documentation/java/5.0.x/release_notes.html#local-protocol-removed
--
Mark Rotteveel