I'm trying to config Hawkbit following this guide: https://www.eclipse.org/hawkbit/guides/runhawkbit/
In pom.xml:
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>compile</scope>
</dependency>
In application.properties:
spring.jpa.database=MYSQL
spring.datasource.url=jdbc:mysql://localhost:3306/{SCHEMA_NAME}
spring.datasource.username={USER_NAME}
spring.datasource.password={PWD}
spring.datasource.driverClassName=org.mariadb.jdbc.Driver
But I got this error: https://paste.ubuntu.com/p/YDtFKxF4Vv/
How to resolve this?
Might be a bit late, but basically the Hawkbit server has database migration scripts (Flyway). Within the HawkBit database, there is a table reserved for tracking these migrations for backwards compatibility. This is the schema_version table.
The problem that you see here is that Flyway is trying to migrate the state of the database, but fails because it detects a previous migration that failed.
Caused by: org.flywaydb.core.api.FlywayException: Validate failed: Detected failed migration to version 1.0.1 (init )
at org.flywaydb.core.Flyway.doValidate(Flyway.java:1482)
at org.flywaydb.core.Flyway.access$100(Flyway.java:85)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1364)
at org.flywaydb.core.Flyway$1.execute(Flyway.java:1356)
at org.flywaydb.core.Flyway.execute(Flyway.java:1711)
at org.flywaydb.core.Flyway.migrate(Flyway.java:1356)
at org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer.afterPropertiesSet(FlywayMigrationInitializer.java:66)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
... 98 common frames omitted
Easiest solution would be to start with a fresh database. But in the case that you have important data in the database, you could also truncate the schema_version table and rerun the Hawkbit server.
Related
Successfully I did my first JDBC program using MariaDB, Maven, Java-11.
Now I have to access MySQL and just exchanged the MariaDB dependency by
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
I figured out, that com.mysql.jdbc and com.mysql.cj and other modules are hosted in the mysql-connector-java-8.0.28.jar.
Hence, in module-info.java I exchanged
requires org.mariadb.jdbc;
by
requires com.mysql.jdbc;
I also tried
requires com.mysql.cj;
but still, the maven-compiler-plugin:3.9.0 complains
module not found
What did I miss, here?
khmarbaise has put me on the right track: I almost forgot that there are legacy jar files around not prepared for easy integration into JPMS. To include the jar file mysql-connector-java-8.0.28.jar, which comes without a module-info.class, I had to enter
requires java.sql;
requires mysql.connector.java;
to my module-info.java.
The module name mysql.connector.java is derived from the name of its jar file by omitting the version info and substituting the dashes by dots.
https://codelabs.developers.google.com/codelabs/cloud-bookshelf-java-cloud-kms/index.html#0
I'm getting following error after downloading additional Bookshelf app files ( Step 7)
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.3.8.v20160314:run-exploded (default-cli) on project bookshelf-3: Execution default-cli of goal org.eclipse.jetty:jetty-maven-plugin:9.3.8.v20160314:run-exploded failed: An API incompatibility was encountered while executing org.eclipse.jetty:jetty-maven-plugin:9.3.8.v20160314:run-exploded: java.lang.NoSuchMethodError: com.google.cloud.ServiceOptions.(Ljava/lang/Class;Ljava/lang/Class;Lcom/google/cloud/ServiceOptions$Builder;Lcom/google/cloud/ServiceDefaults;)
https://codelabs.developers.google.com/codelabs/cloud-bookshelf-java-cloud-kms/index.html#0
like Tim mentioned, you're getting this error because that codelab is currently instructing users to download an older version of the KMS library (v1beta1). You can see this in the pom.xml file in the GCS bucket downloaded, for the google-api-services-cloudkms artifact, whose version is v1beta1-rev1-1.22.0.
To fix the issue, edit the pom.xml file in the bucket to point to the current v1 version, you can find the current version here: https://mvnrepository.com/artifact/com.google.apis/google-api-services-cloudkms. At the time I'm writing this, its v1-rev41-1.23.0.
Current:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudkms</artifactId>
<version>v1beta1-rev1-1.22.0</version>
</dependency>
Fix
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-cloudkms</artifactId>
<version>v1-rev41-1.23.0</version>
</dependency>
You're also going to need to resolve all of the v1beta1 references inside src/main/java/com/example/getstarted/util/CloudKeyManagementServiceHelper.java
For more information and guides on how to use Google Cloud KMS Java, I'd suggest looking at our java samples.
Thanks
I want to run my project with active profile 'firza' But it gives me the following error. After searching on google I tried all the possible fixes but nothing worked :|
Can anybody help me?
application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/MySportsAcademy?createDatabaseIfNotExist=true
spring.datasource.username=admin
spring.datasource.password=ivl123
spring.data.rest.basePath=/api
#spring.profiles.active=firza
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect=com.ivl.MySportsAcademy.dbconfig.MySportsAcademyMysql57Dialect
spring.jpa.hibernate.ddl-auto=update
allowed.origins=http://localhost:9000
logging.level.org.springframework.security=DEBUG
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
logging.level.org.apache.tomcat.jdbc.pool=DEBUG
logging.level.com.reservos=DEBUG
logging.level.com.sendgrid=DEBUG
logging.level.org.hibernate.tool.hbm2ddl=debug
server.port=3000
application-firza.properties
spring.datasource.url=jdbc:mysql://localhost:3306/MySportsAcademy?createDatabaseIfNotExist=true
spring.datasource.username=root
spring.datasource.password=admin
spring.data.rest.basePath=/api
spring.jpa.hibernate.ddl-auto=update
allowed.origins=http://localhost:9000
logging.level.org.springframework.security=DEBUG
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.apache.tomcat.jdbc.pool=DEBUG
logging.level.com.reservos=DEBUG
logging.level.com.sendgrid=DEBUG
logging.level.org.hibernate.tool.hbm2ddl=debug
server.port=3000
admin.email.id=bilal.raza#indusvalleylabs.com
pom.xml
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
Error
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "firza" are currently active).
Make sure you have application.properties inside of resources folder with required database param
Here is example
spring.datasource.platform=mysql
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://vaquarkhan.com:3307/vk01?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username=xyz
spring.datasource.password=xyzwe
spring.datasource.initialization-mode=never
#spring.datasource.schema=schema.sql
logging.level.org.springframework.integration=DEBUG
I am trying to connect to google cloud SQL. I was able to successfully do that a couple of days ago but right now I am facing some issues with that.
The problem that is occurring is
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
since it automatically loads com.mysql.cj.jdbc.Driver I am getting the following error:
java.sql.SQLNonTransientConnectionException: Could not create connection to database server.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:676)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:663)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:653)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:638)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:606)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1837)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1653)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:662)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:221)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.example.endpoints.insertUser.doPost(insertUser.java:160)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:821)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:583)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1158)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:511)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1090)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:109)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119)
at org.eclipse.jetty.server.Server.handle(Server.java:517)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:306)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:261)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
**Caused by: java.lang.ClassCastException: com.google.cloud.sql.mysql.SocketFactory cannot be cast to com.mysql.cj.api.io.SocketFactory**
at com.mysql.cj.core.io.AbstractSocketConnection.createSocketFactory(AbstractSocketConnection.java:129)
at com.mysql.cj.mysqla.io.MysqlaSocketConnection.connect(MysqlaSocketConnection.java:56)
at com.mysql.cj.mysqla.MysqlaSession.connect(MysqlaSession.java:144)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1783)
... 33 more
check the bold part....
the url I am using to make connection is this:-
"jdbc:mysql://google/*****?cloudSqlInstance=******&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=****&password=****&useSSL=true"
I think the problem is that you are using mysql-socket-factory which have class com.google.cloud.sql.mysql.SocketFactory implements com.mysql.jdbc.SocketFactory
Try this one: mysql-socket-factory-connector-j-6
If you are using the following dependencies
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>*.*.*</version>
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>*.*.*</version>
</dependency>
use this starter instead
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-sql-mysql</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
I had a Very similar issue that may have the same root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create socket factory 'com.google.cloud.sql.mysql.SocketFactory' due to underlying exception:
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...
Caused by: java.lang.ClassCastException: com.google.cloud.sql.mysql.SocketFactory cannot be cast to com.mysql.jdbc.SocketFactory
at com.mysql.jdbc.MysqlIO.createSocketFactory(MysqlIO.java:3324)
... 80 more
Which was very strange since I had everything working previously.
Turns out that my wifi connection was on the wrong network and I had no connectivity. When I fixed my network connection, the DB connection worked again. Tried enabling and disabling wifi to be sure. Yep, very confusing error for the actual problem.
Hope this helps out someone with the same issue.
spring-data-couchbase 2.0.0.RELEASE
4.0.0-4047 Community Edition (build-4047)
At times I face connection timeout exception being thrown
Caused by: com.couchbase.client.deps.io.netty.channel.ConnectTimeoutException: connection timed out
I am using following environment configuration
#Override
protected CouchbaseEnvironment getEnvironment() {
return DefaultCouchbaseEnvironment.builder()
.connectTimeout(TimeUnit.SECONDS.toMillis(100))
.computationPoolSize(6).autoreleaseAfter(9000).build();
}
my databuckets are auto wired in my services and I in one particular use case, I update a few documents across two data bucket. In case of connection being a bit iffy I get this exception and I am left with corrupt data of not all docs getting updated. Is there any connection retry mechanism which I can use if in case of connection failure?
As a temporary attempt to fix, can you try forcing the Couchbase Java SDK to bump to version 2.2.4?
Add this to your pom.xml's <dependencies> section:
<dependency>
<groupId>com.couchbase.client</groupId>
<artifactId>java-client</artifactId>
<version>2.2.4</version>
</dependency>