Error When Updating HikariCP with JTDS and Spring Boot 1.5 - java

APPLICATION FAILED TO START
Description:
Binding to target HikariDataSource (HikariPool-1) failed:
Property: spring.datasource.hikari.connectionTestQuery
Value: SELECT 1
Reason: Property 'connectionTestQuery' threw exception; nested exception is java.lang.IllegalStateException: The configuration of the pool is sealed once started. Use HikariConfigMXBean for runtime changes.

As per Hikari documentation, you may not required to set this property if you use latest JDBC drivers. This property is for legacy JDBC drivers (<JDBC4).
You can try running your application without setting this property. Moreover, if still issue persists, please share hikari bean definition; I will update my answer based on that.

After upgrading the application to the below version of the spring boot, the application started with no errors
<parent>
<groupId>com.accurate.boot</groupId>
<artifactId>accurate-spring-starter-parent</artifactId>
<version>1.5.22.RELEASE</version>

Related

H2 in memory database not working after update to SpringBoot 2.4.0

I have an SpringBoot application with integrationtests utilising an H2 inmemory database. The tests work, if I use SpringBoot in versino 2.3.4.RELEASE. They fail if I upgrade to 2.4.0 with the following error:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is java.lang.RuntimeException: Driver com.microsoft.sqlserver.jdbc.SQLServerDriver claims to not accept jdbcUrl, jdbc:h2:mem:integrationTestDB;DB_CLOSE_DELAY=-1;MODE=MSSQLServer;INIT=CREATE SCHEMA IF NOT EXISTS dbo\;SET SCHEMA dbo
Caused by: java.lang.RuntimeException: Driver com.microsoft.sqlserver.jdbc.SQLServerDriver claims to not accept jdbcUrl, jdbc:h2:mem:integrationTestDB;DB_CLOSE_DELAY=-1;MODE=MSSQLServer;INIT=CREATE SCHEMA IF NOT EXISTS dbo\;SET SCHEMA dbo
Here is my integration-test.properties, that is used by the tests:
spring.datasource.url=jdbc:h2:mem:integrationTestDB;\
DB_CLOSE_DELAY=-1;\
MODE=MSSQLServer;\
INIT=CREATE SCHEMA IF NOT EXISTS dbo\\;SET SCHEMA dbo
spring.datasource.driver=org.h2.Driver
spring.datasource.hikari.driver-class-name=org.h2.Driver
hibernate.dialect=org.hibernate.dialect.SQLServerDialect
hibernate.hbm2ddl.auto=none
spring.datasource.username=sa
spring.datasource.password=
spring.liquibase.user=sa
spring.liquibase.password=
The version of H2 is 1.4.200.
The difference between success and failure is the SpringBoot version in the parent element of the pom:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
</parent>
The liquibase version changed from 3.8.9 to 3.10.3. I configured it to stay at 3.8.9 but that didn't help.
I read the release notes and found the part about the embedded database detection: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.4-Release-Notes#embedded-database-detection
But adding
spring.datasource.initialization-mode=always
to the properties didn't help either.
I remember that it took some time to find the right datasource url last time, but I can't find any new clues with google.
Can you give me a hint, what causes this problem?
Kind regards,
Ulrich
Your properties contain a mixture of H2 and SQL Server configuration. For example, you've configured an H2 JDBC URL for the DataSource but configured Hibernate to use SQLServerDialect. The exception shows that SQL Server's JDBC driver is being used when trying to initialise Liquibase. It looks to me like you're trying to use H2 in your integration tests, replacing SQL Server that's used when your app's deployed.
There's a new spring.liquibase.driver-class-name property in 2.4.0. When not set, it falls back to using spring.datasource.driver-class-name. There's no spring.datasource.driver property so try replacing the following two lines:
spring.datasource.driver=org.h2.Driver
spring.datasource.hikari.driver-class-name=org.h2.Driver
with the following line:
spring.datasource.driver-class-name=org.h2.Driver

DependencyException: Failed to find provider with satisfied dependency set for interface org.ehcache.core.spi.store.Store

I have an app that uses EHCache, it worked when using Payara Application server version 1.0.5 but after upgrading to 1.1.0 it started breaking.
Here's a snippet of the code:
persistentEntityStoreCacheManager
= CacheManagerBuilder.newCacheManagerBuilder().withCache("defaultPersistentEntityStoreCache",
CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, PersistentEntityStore.class, ResourcePoolsBuilder.heap(100)).build()).build(true);
And it is throwing this error:
java.lang.IllegalStateException: org.ehcache.core.spi.ServiceLocator$DependencyException: Failed to find provider with satisfied dependency set for interface org.ehcache.core.spi.store.Store$Provider [ca
ndidates []]
at org.ehcache.core.spi.ServiceLocator$DependencySet.build(ServiceLocator.java:350)
at org.ehcache.core.EhcacheManager.resolveServices(EhcacheManager.java:154)
at org.ehcache.core.EhcacheManager.<init>(EhcacheManager.java:125)
at org.ehcache.core.EhcacheManager.<init>(EhcacheManager.java:115)
at org.ehcache.core.EhcacheManager.<init>(EhcacheManager.java:111)
at org.ehcache.config.builders.CacheManagerBuilder.newCacheManager(CacheManagerBuilder.java:117)
at org.ehcache.config.builders.CacheManagerBuilder.build(CacheManagerBuilder.java:73)
What's this EHCache and and what could be missing here?
In my case, there are multiple EhCache imported by different modules.After useing the same version of EhCache. The problem solved.

Spring cloud config server not able to read property file

My Spring cloud config server is throwing below error when trying to access the property file content using http://localhost:8080/application/default
There was an unexpected error (type=Internal Server Error, status=500).
Could not construct context for config=application profile=default label= includeOrigin=false; nested exception is java.lang.IllegalStateException: ConfigFileApplicationListener [org.springframework.boot.context.config.ConfigFileApplicationListener] is deprecated and can only be used as an EnvironmentPostProcessor
org.springframework.cloud.config.server.environment.FailedToConstructEnvironmentException: Could not construct context for config=application profile=default label= includeOrigin=false; nested exception is java.lang.IllegalStateException: ConfigFileApplicationListener [org.springframework.boot.context.config.ConfigFileApplicationListener] is deprecated and can only be used as an EnvironmentPostProcessor
at org.springframework.cloud.config.server.environment.NativeEnvironmentRepository.findOne(NativeEnvironmentRepository.java:161)
at org.springframework.cloud.config.server.environment.AbstractScmEnvironmentRepository.findOne(AbstractScmEnvironmentRepository.java:59)
at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepository.findOne(MultipleJGitEnvironmentRepository.java:187)
at org.springframework.cloud.config.server.environment.CompositeEnvironmentRepository.findOne(CompositeEnvironmentRepository.java:58)
at org.springframework.cloud.config.server.environment.EnvironmentEncryptorEnvironmentRepository.findOne(EnvironmentEncryptorEnvironmentRepository.java:61)
at org.springframework.cloud.config.server.environment.EnvironmentController.getEnvironment(EnvironmentController.java:136)
at org.springframework.cloud.config.server.environment.EnvironmentController.defaultLabel(EnvironmentController.java:108)
at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
My application.properties in config server looks like this
spring.cloud.config.server.git.uri=/Users/joe/MyProgs/Java/spring-ws/config and I even tried with this spring.cloud.config.server.git.uri=${HOME}/MyProgs/Java/spring-ws/config
Content of the property file in the local git repository is
martin:
name: Martin D'vloper
job: Developer
skill: Elite
Please let me know what I am doing wrong.
It looks like this deprecation message was added just a couple of weeks ago in this issue. These changes are not even released yet (marked for release in a future milestone version of Spring Boot 2.4.0-M2).
What version of Spring Boot are you using? I suppose you have a SNAPSHOT dependency somewhere in your build configuration.

servicemix 4.5 NoInitialContextException

We have the osgi application that perfectly worked on Servicemix 5. But for some reasons we must migrate to Servicemix 4.5. I tried it and got this
Error parsing SQL Mapper Configuration. Cause:
org.apache.ibatis.builder.BuilderException: Error parsing SQL MapperConfiguration. Cause: org.apache.ibatis.datasource.DataSourceException: There was an error configuring JndiDataSourceTransactionPool. Cause: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
What does it need?
Install the Aries JNDI feature?
features:install jndi

What are the __pm and __nontx suffixes?

My java EE application is giving following error when i try to run the application on glassfish server. It says "Invalid resource : jdbc/busservice__nontx". Where should i look to fix this error? Previously it was giving error with "jdbc/busservice__pm". Once I created JDBC resource and connected with connection pool, error disappeared. However i'm still getting error with "jdbc/busservice__nontx"
Info: PER02100: Could not load Toplink Essentials. Assuming this is an upgrade from V2. Switching Persistence Unit [BusReservationPU] to use [org.eclipse.persistence.jpa.PersistenceProvider] as JPA provider. If you intend to use Toplink Essentials, please ensure that it is visible to your application."
Severe: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
Severe: java.lang.RuntimeException: Invalid resource : jdbc/busservice__nontx
at com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:593)
at com.sun.enterprise.connectors.ConnectorRuntime.lookupNonTxResource(ConnectorRuntime.java:559)
at org.glassfish.persistence.common.PersistenceHelper.lookupNonTxResource(PersistenceHelper.java:59)
at org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupNonTxDataSource(ProviderContainerContractInfoBase.java:76)
at org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:109)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:142)
Do not add "jdbc/busservice__pm" to your Glassfish JDBC Resources, just add it as "jdbc/busservice". It looks like the __pm and __nontx are some internal names that it adds to the end of your jdbc name internally, and when you specifically add it will mess it up and throw that error.

Categories