I am trying to connect BigQuery from Spring boot using Simba jdbc driver but I am getting below exception. Any input is appreciated. I am not sure why spring-boot is looking for a certifcate. I am able to connect with simple java main class, But I am getting this error with Spring boot only.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceInitializerInvoker': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getDataSource' defined in class path resource [com/test/demo/services/config/DBConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.simba.googlebigquery.jdbc42.DataSource]: Factory method 'getDataSource' threw exception; nested exception is java.sql.SQLException: [Simba]BigQueryJDBCDriver HttpTransport IO error : PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target.
DataSource ds = new com.simba.googlebigquery.jdbc42.DataSource();
Connection connection = null;
ds.setURL(
"jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=project)id;OAuthType=0;OAuthServiceAcctEmail=serviceAccountEmail;OAuthPvtKeyPath=p12CertPath;");
ds.setProjectId("projectId");
// ds.setOAuthType(0);
// connection = ds.getConnection();
connection = ds.getConnection();
Remove the extra spaces from your JDBC URL, it looks like they are interfering with mandatory OAuthPvtKeyPath, OAuthServiceAcctEmail parameters:
jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=<Your Project ID>;OAuthType=0;OAuthServiceAcctEmail=<Your Email>;OAuthPvtKeyPath=<Path To Cert>;
Related
I have the following value configured in my SQS Listener in springboot. The queue is configured only for DEV and STAGE environments. So I want to disable it in my local after testing. How do i achieve that?
#SqsListener(value = { "${cloud.aws.endpoint}" } , deletionPolicy =SqsMessageDeletionPolicy.ON_SUCCESS)
public void processMessage(String message) throws Exception {
}
I tried to add the following to my application-local.xml(to keep it local), but it didn't work. Anyone went through the same scenario?
autoconfigure:
exclude:
- org.springframework.cloud.aws.autoconfigure.messaging.MessagingAutoConfiguration
- org.springframework.cloud.aws.autoconfigure.context.ContextStackAutoConfiguration
- org.springframework.cloud.aws.autoconfigure.context.ContextRegionProviderAutoConfiguration
I am getting the following error everytime.
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'stackResourceRegistryFactoryBean' defined in class path resource [org/springframework/cloud/aws/autoconfigure/context/ContextStackAutoConfiguration.class]: Unsatisfied dependency expressed through method 'stackResourceRegistryFactoryBean' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'autoDetectingStackNameProvider' defined in class path resource [org/springframework/cloud/aws/autoconfigure/context/ContextStackAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.aws.core.env.stack.config.StackNameProvider]: Factory method 'autoDetectingStackNameProvider' threw exception; nested exception is java.lang.IllegalArgumentException: No valid instance id defined
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:799) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
com.amazonaws.SdkClientException: Failed to connect to service endpoint:
at com.amazonaws.internal.EC2ResourceFetcher.doReadResource(EC2ResourceFetcher.java:100) [aws-java-sdk-core-1.11.867.jar:na]
Caused by: java.net.ConnectException: Host is down (connect failed)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'autoDetectingStackNameProvider' defined in class path resource [org/springframework/cloud/aws/autoconfigure/context/ContextStackAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.aws.core.env.stack.config.StackNameProvider]: Factory method 'autoDetectingStackNameProvider' threw exception; nested exception is java.lang.IllegalArgumentException: No valid instance id defined
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:657) ~[spring-beans-5.2.12.RELEASE.jar:5.2.12.RELEASE]
at org.sprin
I've faced similar issues while using #SqsListener. What I usually do is comment out the annotation when running the app locally - it's ugly but it works.
I am having this error while trying to run the ResourceServer, it complains about the: http://localhost:8080/auth/realms/xxxnapp/protocol/openid-connect/certs as it has no protocol
Error creating bean with name 'jwtDecoderByJwkKeySetUri' defined in
class path resource
[org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration$JwtDecoderConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [org.springframework.security.oauth2.jwt.JwtDecoder]:
Factory method 'jwtDecoderByJwkKeySetUri' threw exception; nested
exception is java.lang.IllegalArgumentException: Invalid JWK Set URL
"=
http://localhost:8080/auth/realms/xxxnapp/protocol/openid-connect/certs"
: no protocol: =
http://localhost:8080/auth/realms/xxxnapp/protocol/openid-connect/certs
any idea how I over come this error.
there is an additional "=" before the url in the proprieties file which is causing the error. by modifying it I have my program running.
I got a problem in one of my cloud server today and it was restarted by the administrators when action was in progress. Since the restart of the server my backend doesn't want to restart, it seems like there is a problem with my postgresql database.
For information : I can connect to the database with the username and the password of the user with no problem and also do modification with pgAdmin or directly with psql.
ERROR c.b.myapp.progress.ProgressServiceImpl.updateProgressApplication (169) - error updating progress for c24f3d42-965b-459e-8afd-2e016ddb3394
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Unsatisfied dependency expressed through method 'dataSource' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties' : prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is java.lang.IllegalStateException: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#5e57643e has not been refreshed yet
at [...]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Unsatisfied dependency expressed through method 'dataSource' parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties' : prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is java.lang.IllegalStateException: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#5e57643e has not been refreshed yet
at [...]
Caused by: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties': Could not bind properties to 'DataSourceProperties' : prefix=spring.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is java.lang.IllegalStateException: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#5e57643e has not been refreshed yet
at [...]
Caused by: java.lang.IllegalStateException: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#5e57643e has not been refreshed yet
at [...]
ERROR o.s.a.i.SimpleAsyncUncaughtExceptionHandler.handleUncaughtException (39) - Unexpected exception occurred invoking async method: public void com.myapp.progress.ProgressServiceImpl.processAllApplications()
org.springframework.orm.jpa.JpaSystemException: Unable to rollback against JDBC Connection; nested exception is org.hibernate.TransactionException: Unable to rollback against JDBC Connection
at [...]
Caused by: org.hibernate.TransactionException: Unable to rollback against JDBC Connection
at [...]
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
Can someone help ? (Everything was working fine before this server restart)
How would I catch an exception thrown by Spring after failing to connect to the database during startup? I'd like to make the error message user-friendly.
For example, if the password isn't correct, the following is thrown:
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "cikfedlekqbuk"
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:525) ~[postgresql-42.2.14.jar:42.2.14]
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:146) ~[postgresql-42.2.14.jar:42.2.14]
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:197) ~[postgresql-42.2.14.jar:42.2.14]
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.14.jar:42.2.14]
...
Or if the format is incorrect, this is thrown:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, jdbc:postgresql://url:port
... Stack trace
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, jdbc:postgresql://url:port
... Stack trace
Caused by: java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, jdbc:postgresql://url:port
... Stack trace
The two possible solutions I've come across were using #ExceptionHandler or using AOP. Both failed however, because #ExceptionHandler is MVC specific and AOP wouldn't recognize the methods. Here's the example of a pointcut I've tried:
#AfterThrowing(value="execution(* org.springframework.boot.autoconfigure.orm.jpa.*())", throwing="e")
I've also tried with com.zaxxer.hikari.util.DriverDataSource and others.
Thanks in advance!
Check your application.properties:
spring.datasource.url = jdbc:postgresql://localhost:5432/database_name
spring.datasource.username = postgres
spring.datasource.password = postgres
I am trying to create a simple Spring application with Teradata database.
It was working with mySql database and driver but after changing to Teradata driver/databased i receive following exception :
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalArgumentException: URL must start with 'jdbc'
Application Properties :
spring.datasource.url =jdbc:teradata://servername/db
spring.datasource.username = dbc
spring.datasource.password = dbc
spring.datasource.driverClassName=com.ncr.teradata.TeraDriver
I think that is problem of Spring you might be using #Autowire on constructor but spring can't inject class with that name. To solve the problem, just define a DataSource in your context - at which point Spring will be able to inject the bean and correctly bootstrap the context.