MySQL changes to Kafka Using Debezium - Capturing only DDL stmts - mysql

Configured MySQL-Debezium for CDC. It was capturing DDL changes like create/Drop table, but not capturing DML events.
Using MySQL 8.0.11 and Embedded debezium version 0.8.3.Final.
No additional configurations were done in MySQL server while creating table.
Configuration bean is created with below code
#Bean
public io.debezium.config.Configuration customerConnector() {
return io.debezium.config.Configuration.create()
.with(EmbeddedEngine.CONNECTOR_CLASS, "io.debezium.connector.mysql.MySqlConnector")
.with(EmbeddedEngine.OFFSET_STORAGE, "org.apache.kafka.connect.storage.FileOffsetBackingStore")
.with(EmbeddedEngine.OFFSET_STORAGE_FILE_FILENAME, "path-to-file")
.with("offset.flush.interval.ms", 60000)
.with(EmbeddedEngine.ENGINE_NAME, "customer-mysql-connector")
.with(MySqlConnectorConfig.SERVER_NAME, databaseServer)
.with(MySqlConnectorConfig.HOSTNAME, databaseServer)
.with(MySqlConnectorConfig.PORT, databasePort)
.with(MySqlConnectorConfig.USER, databaseUser)
.with(MySqlConnectorConfig.PASSWORD, databasePassword)
.with(MySqlConnectorConfig.DATABASE_WHITELIST, databaseSchemaName)
.with(MySqlConnectorConfig.TABLE_WHITELIST, databaseTable)
.with(MySqlConnectorConfig.DATABASE_HISTORY,
MemoryDatabaseHistory.class.getName()).build();
}
Below is the log when starting it as Springboot application
2020-05-29 21:24:28.028 INFO 5576 --- [pool-1-thread-1] i.d.connector.mysql.MySqlConnectorTask : MySQL has the binlog file 'binlog.000009' required by the connector
2020-05-29 21:24:28.072 INFO 5576 --- [pool-1-thread-1] io.debezium.util.Threads : Requested thread factory for connector MySqlConnector, id = localhost named = binlog-client
2020-05-29 21:24:28.074 INFO 5576 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-05-29 21:24:28.074 INFO 5576 --- [pool-1-thread-1] io.debezium.util.Threads : Creating thread debezium-mysqlconnector-localhost-binlog-client
2020-05-29 21:24:28.090 INFO 5576 --- [-localhost:3306] io.debezium.util.Threads : Creating thread debezium-mysqlconnector-localhost-binlog-client
2020-05-29 21:24:28.121 INFO 5576 --- [-localhost:3306] c.g.shyiko.mysql.binlog.BinaryLogClient : Connected to localhost:3306 at binlog.000009/3786 (sid:6293, cid:36)
2020-05-29 21:24:28.121 INFO 5576 --- [-localhost:3306] i.debezium.connector.mysql.BinlogReader : Connected to MySQL binlog at localhost:3306, starting at binlog file 'binlog.000009', pos=3786, skipping 8 events plus 0 rows
2020-05-29 21:24:28.121 INFO 5576 --- [-localhost:3306] io.debezium.util.Threads : Creating thread debezium-mysqlconnector-localhost-binlog-client
2020-05-29 21:24:28.183 INFO 5576 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Context refreshed
2020-05-29 21:24:28.199 INFO 5576 --- [ main] d.s.w.p.DocumentationPluginsBootstrapper : Found 1 custom documentation plugin(s)
2020-05-29 21:24:28.199 INFO 5576 --- [ main] s.d.s.w.s.ApiListingReferenceScanner : Scanning for api listing references
Any Clue?
Thanks!

table.whitelist should be set to to <schema>.<table> so in your case source.customer

Related

Springboot - Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled

I have just created the spring boot application from spring initializer and execute it in intellij.But I am facing some error. Can anyone please help me to solve the error?
package com.demo.grocery;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class GroceryApplication {
public static void main(String[] args) {
SpringApplication.run(GroceryApplication.class, args);
}
}
And this is the error I am facing
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.7.2)
2022-07-29 22:12:46.331 INFO 14136 --- [ main] com.demo.grocery.GroceryApplication : Starting GroceryApplication using Java 11.0.13 on DESKTOP-MQ2O3FR with PID 14136 (C:\Users\keerthi\Downloads\grocery\target\classes started by keerthi in C:\Users\keerthi\Downloads\grocery)
2022-07-29 22:12:46.336 INFO 14136 --- [ main] com.demo.grocery.GroceryApplication : No active profile set, falling back to 1 default profile: "default"
2022-07-29 22:12:47.288 INFO 14136 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2022-07-29 22:12:47.306 INFO 14136 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 7 ms. Found 0 JPA repository interfaces.
2022-07-29 22:12:48.437 INFO 14136 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2022-07-29 22:12:48.463 INFO 14136 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-07-29 22:12:48.463 INFO 14136 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.65]
2022-07-29 22:12:48.721 INFO 14136 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2022-07-29 22:12:48.721 INFO 14136 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2267 ms
2022-07-29 22:12:48.832 WARN 14136 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' 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$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
2022-07-29 22:12:48.839 INFO 14136 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-07-29 22:12:48.868 INFO 14136 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-07-29 22:12:48.897 ERROR 14136 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Process finished with exit code 1
I have tried most of the solutions from stackoverflow, help me to solve this error
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_example
spring.datasource.username=springuser
spring.datasource.password=ThePassword
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.jpa.show-sql: true
Paste this in your application properties file in the resource folder.
Change the database name in the second line and also change the username and password according to your database.

spring boot mysql application issues using docker compose

OS details
Mint version 19,
Code name : Tara,
PackageBase : Ubuntu Bionic
Cinnamon (64-bit)
I followed this URL to install mysql 5.7 and workbench 6.3
I can check mysql service running
xxxxxxxxx:~$ sudo netstat -nlpt | grep 3306
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1547/mysqld
I also checked bind-address inside file: mysqld.cnf under directory : /etc/mysql/mysql.conf.d/
bind-address = 127.0.0.1
I have written a simple spring application using mysql
Here are all classes written
SpringBootDataJpaExampleApplication
#EnableJpaRepositories(basePackages = "com.springbootdev.examples.repository")
#SpringBootApplication
public class SpringBootDataJpaExampleApplication
{
public static void main(String[] args) {
SpringApplication.run(SpringBootDataJpaExampleApplication.class, args);
}
}
UserController
#RestController
#RequestMapping("/api")
public class UserController {
#Autowired
private UserRepository userRepository;
#GetMapping("/create")
public List<User> users() {
User users = new User();
users.setId(new Long(1));
users.setName("Sam");
users.setCountry("Development");
userRepository.save(users);
return userRepository.findAll();
}
#GetMapping("/users")
public List<User> findAll()
{
return userRepository.findAll();
}
}
UserRepository
public interface UserRepository extends JpaRepository<User, Long>
{
}
User
#Entity
#Table(name = "user")
public class User {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String country;
//getters and setters
}
partial pom.xml file. Please see I am using spring boot 1.5.9 and jdk 1.8
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
application.properties
spring.datasource.url = jdbc:mysql://mysql-standalone:3306/test
spring.datasource.username = testuser
spring.datasource.password = testpassword
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto = create
Dockerfile
FROM openjdk:8
VOLUME /tmp
EXPOSE 8080
ADD target/spring-boot-app.jar spring-boot-app.jar
ENTRYPOINT ["java","-jar","spring-boot-app.jar"]
When I run this application locally using IDE it works fine and I can access:
http://localhost:8080/api/users/
and http://localhost:8080/api/create/
I build image out of my application using command
docker build . -t spring-boot-app
I can see image is being built.
xxxxxxxxxx:$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
spring-boot-app latest 069e53a7c389 27 minutes ago 652MB
mysql 5.7 1b30b36ae96a 8 days ago 372MB
Now I run Command to run the mysql container
docker run --name mysql-standalone -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=test -e MYSQL_USER=testuser -e MYSQL_PASSWORD=testpassword -d mysql:5.7
Then I connect to mysql-standalone container from my application(spring-boot-app) (referencing this)
docker run --name spring-boot-app-container --link mysql-standalone:mysql -d spring-boot-app
With this, I can see my application working fine from docker using
http://(docker-container-ip):8080/api/users/ and http://(docker-container-ip):8080/api/create/
Here I wanted to make the same thing work with docker-compose.
Referenced this to install docker compose.
xxxxxxxxxx:~$ docker-compose --version
docker-compose version 1.22.0, build f46880fe
Then I created file docker-compose.yml in my project directory.
version: '3'
services:
mysql-docker-container:
image: mysql:5.7
environment:
- MYSQL_ROOT_PASSWORD=adminpassword
- MYSQL_DATABASE=test
- MYSQL_USER=testuser
- MYSQL_PASSWORD=testpassword
volumes:
- /data/mysql
spring-boot-app-container:
image: spring-boot-app
build:
context: .
dockerfile: Dockerfile
depends_on:
- mysql-docker-container
ports:
- 8087:8080
volumes:
- /data/spring-boot-app
Changed one line in my application.properties and commented earlier datasource url as below.
spring.datasource.url = jdbc:mysql://mysql-docker-container:3306/test
#spring.datasource.url = jdbc:mysql://mysql-standalone:3306/test
Did clean install so new target jar gets created. I also deleted images and containers from docker.
Then ran below command:
docker-compose up
This is what I see in logs
Creating spring-boot-data-jpa-mysql-docker-no-composer-master_mysql-docker-container_1 ... done
Creating spring-boot-data-jpa-mysql-docker-no-composer-master_spring-boot-app-container_1 ... done
Attaching to spring-boot-data-jpa-mysql-docker-no-composer-master_mysql-docker-container_1, spring-boot-data-jpa-mysql-docker-no-composer-master_spring-boot-app-container_1
spring-boot-app-container_1 |
spring-boot-app-container_1 | . ____ _ __ _ _
spring-boot-app-container_1 | /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
spring-boot-app-container_1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
spring-boot-app-container_1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
spring-boot-app-container_1 | ' |____| .__|_| |_|_| |_\__, | / / / /
spring-boot-app-container_1 | =========|_|==============|___/=/_/_/_/
spring-boot-app-container_1 | :: Spring Boot :: (v1.5.9.RELEASE)
spring-boot-app-container_1 |
spring-boot-app-container_1 | 2018-10-26 01:24:48.748 INFO 1 --- [ main] .s.e.SpringBootDataJpaExampleApplication : Starting SpringBootDataJpaExampleApplication v0.0.1-SNAPSHOT on 582c035536e4 with PID 1 (/spring-boot-app.jar started by root in /)
spring-boot-app-container_1 | 2018-10-26 01:24:48.752 INFO 1 --- [ main] .s.e.SpringBootDataJpaExampleApplication : No active profile set, falling back to default profiles: default
spring-boot-app-container_1 | 2018-10-26 01:24:48.875 INFO 1 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#28c97a5: startup date [Fri Oct 26 01:24:48 UTC 2018]; root of context hierarchy
spring-boot-app-container_1 | 2018-10-26 01:24:51.022 INFO 1 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
spring-boot-app-container_1 | 2018-10-26 01:24:51.063 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
spring-boot-app-container_1 | 2018-10-26 01:24:51.065 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.23
spring-boot-app-container_1 | 2018-10-26 01:24:51.218 INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
spring-boot-app-container_1 | 2018-10-26 01:24:51.218 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2399 ms
spring-boot-app-container_1 | 2018-10-26 01:24:51.335 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
spring-boot-app-container_1 | 2018-10-26 01:24:51.340 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
spring-boot-app-container_1 | 2018-10-26 01:24:51.341 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
spring-boot-app-container_1 | 2018-10-26 01:24:51.341 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
spring-boot-app-container_1 | 2018-10-26 01:24:51.341 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
spring-boot-app-container_1 | 2018-10-26 01:24:51.895 ERROR 1 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
spring-boot-app-container_1 |
spring-boot-app-container_1 | com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
spring-boot-app-container_1 |
spring-boot-app-container_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
spring-boot-app-container_1 | at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_181]
How to fix this error:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
I can see lot of answers on this forum for this similar error message. Tried bunch of those options/answers, but that didn't work.
No answer talks about this combination (linux + spring boot + mysql + docker compose)
Note: This has worked fine without using docker-compose. Have already mentioned the same in above description. Am I making any mistake in docker-compose file or application properties file?
I did see lot of people posting about adding hikari dependency in pom.xml if you are using any spring-boot version < 2.0
<!-- Spring Boot Data 2.0 includes HikariCP by default -->
<!-- <dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>3.1.0</version>
</dependency> -->
With that I thought of using same application but made changes to my pom.xml as below
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Then I followed exact same things as mentioned in description of issue. With that I saw bit more clear error as below:
spring-boot-app-container_1 | 2018-10-27 18:51:47.259 INFO 1 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
spring-boot-app-container_1 | 2018-10-27 18:51:48.464 ERROR 1 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization.
spring-boot-app-container_1 |
spring-boot-app-container_1 | com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
spring-boot-app-container_1 |
spring-boot-app-container_1 | The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
That confirms spring-boot 2.0 uses hikari datasource default.
Now coming back to how I solved the issue.
I changed connection string in application.properties like below:
spring.datasource.url = jdbc:mysql://mysql-docker-container:3306/test?autoReconnect=true&failOverReadOnly=false&maxReconnects=10&useSSL=false
instead of earlier used:
spring.datasource.url = jdbc:mysql://mysql-docker-container:3306/test
The answer was simple. Below change worked for me in Spring-boot 2.0 as well as Spring-boot 1.5.9: (Add this to your connection string)
?autoReconnect=true&failOverReadOnly=false&maxReconnects=10
Some handy commands:
Once containers are up, you can check ip addresses of containers using command:
docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)
========================================
UPDATE: some additional handy information...
Below is DEPRECATED
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
This needs to be replaced by
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
To fix HikariCP Pool initialization issue/exception, please set HikariCP’s initializationFailTimeout property to 0 (zero), or a negative number.
# HikaryCP Properties
spring.datasource.hikari.initialization-fail-timeout=0
This property controls whether the pool will "fail fast" if the pool cannot be seeded with an initial connection successfully. Any positive number is taken to be the number of milliseconds to attempt to acquire an initial connection; the application thread will be blocked during this period. If a connection cannot be acquired before this timeout occurs, an exception will be thrown. This timeout is applied after the connectionTimeout period. If the value is zero (0), HikariCP will attempt to obtain and validate a connection. If a connection is obtained, but fails validation, an exception will be thrown and the pool not started. However, if a connection cannot be obtained, the pool will start, but later efforts to obtain a connection may fail. A value less than zero will bypass any initial connection attempt, and the pool will start immediately while trying to obtain connections in the background. Consequently, later efforts to obtain a connection may fail. Default: 1

Liquibase runs changeset again when starting Spring boot application in debug in idea

when i start my spring boot application in the default run mode it executes the liquibase statement as normal.
Stopping and running again skips the changeset as normal, since it was already executed.
starting in debug mode however tries to execute the changeset again even though it ran already.
I turned it around and first executed the change in debug which neatly creates the entry in the databasechangelog
and when running it a second time in non debug mode the same happens
My changes are in native sql format, the database is mariadb with the mysql connector
I compared the md5 sum of both databasechangelog (run first vs debug first) entries and they are the same.
liquibase version is 3.5.4 I also tested 3.5.5 with the same result
mysql Ver 15.1 Distrib 10.0.34-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
here is also the logging part where liquibase fails
2018-05-01 13:54:00.610 DEBUG 27486 --- [ main] liquibase : Connected to xxx#localhost#jdbc:mysql://localhost:3306/project1_db?nullNamePatternMatchesAll=true
2018-05-01 13:54:00.610 DEBUG 27486 --- [ main] liquibase : Setting auto commit to false from true
2018-05-01 13:54:00.642 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: select count(*) from project1_db.DATABASECHANGELOGLOCK
2018-05-01 13:54:00.647 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: select count(*) from project1_db.DATABASECHANGELOGLOCK
2018-05-01 13:54:00.648 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: SELECT LOCKED FROM project1_db.DATABASECHANGELOGLOCK WHERE ID=1
2018-05-01 13:54:00.649 DEBUG 27486 --- [ main] liquibase : Lock Database
2018-05-01 13:54:00.655 DEBUG 27486 --- [ main] liquibase : Executing UPDATE database command: UPDATE project1_db.DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)', LOCKGRANTED = '2018-05-01 13:54:00.650' WHERE ID = 1 AND LOCKED = 0
2018-05-01 13:54:00.657 INFO 27486 --- [ main] liquibase : Successfully acquired change log lock
2018-05-01 13:54:00.672 DEBUG 27486 --- [ main] liquibase : Opening file:/home/xxx/project1-connector/project1-backend/target/classes/db/changelog/db.changelog-master.yaml as classpath:/db/changelog/db.changelog-master.yaml
2018-05-01 13:54:00.687 DEBUG 27486 --- [ main] liquibase : includeAll for db/changelog/changes/
2018-05-01 13:54:00.687 DEBUG 27486 --- [ main] liquibase : Using file opener for includeAll: liquibase.integration.spring.SpringLiquibase$SpringResourceOpener(jdk.internal.loader.ClassLoaders$AppClassLoader)
2018-05-01 13:54:00.690 DEBUG 27486 --- [ main] liquibase : Opening file:/home/xxx/project1-connector/project1-backend/target/classes/db/changelog/changes/db.change.sql as db/changelog/changes/db.change.sql
2018-05-01 13:54:00.690 DEBUG 27486 --- [ main] liquibase : Opening file:/home/xxx/project1-connector/project1-backend/target/classes/db/changelog/changes/db.change.sql as db/changelog/changes/db.change.sql
2018-05-01 13:54:00.694 DEBUG 27486 --- [ main] liquibase : Computed checksum for 1525175640693 as 422ae5f56810de3fc5eeb17bb4af5afe
2018-05-01 13:54:00.710 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: SELECT MD5SUM FROM project1_db.DATABASECHANGELOG WHERE MD5SUM IS NOT NULL LIMIT 1
2018-05-01 13:54:00.711 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: select count(*) from project1_db.DATABASECHANGELOG
2018-05-01 13:54:00.712 INFO 27486 --- [ main] liquibase : Reading from project1_db.DATABASECHANGELOG
2018-05-01 13:54:00.712 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: SELECT * FROM project1_db.DATABASECHANGELOG ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC
2018-05-01 13:54:00.716 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Computed checksum for inputStream as 0c73ccd0174246a5a7fab00d26cc30d2
2018-05-01 13:54:00.720 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Computed checksum for 7:0c73ccd0174246a5a7fab00d26cc30d2: as 22c8e24ae058e8e523819972d470a98a
2018-05-01 13:54:00.721 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Running Changeset:db/changelog/changes/db.change.sql::basicdata::xxx
2018-05-01 13:54:00.721 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Changeset db/changelog/changes/db.change.sql::basicdata::xxx
2018-05-01 13:54:00.721 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Reading ChangeSet: db/changelog/changes/db.change.sql::basicdata::xxx
2018-05-01 13:54:00.727 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Executing Statement: insert into company (id, name, created_at, created_by)
values (1, 'mycompany', now(), 'xxx')
2018-05-01 13:54:00.728 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Executing EXECUTE database command: insert into company (id, name, created_at, created_by)
values (1, 'mycompany', now(), 'xxx')
2018-05-01 13:54:00.733 ERROR 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Change Set db/changelog/changes/db.change.sql::basicdata::xxx failed. Error: Duplicate entry '1' for key 'PRIMARY' [Failed SQL: insert into company (id, name, created_at, created_by)
values (1, 'mycompany', now(), 'xxx')]
I guess that it could be the problem with logicalFilePath. Maybe your classpath is slightnly different in debug and in normal run. Try to specify it in your sql files. look here for info.

org.hibernate.HibernateException: Missing column: auth_password in Spring Boot application

I am working with a Spring Boot application . I have faced some issue related to org.hibernate.HibernateException: Missing column: auth_password in medxlabpro.appsettings
I have column in my PoJo class authpassword not auth_password. So why this type of issue coming in my application . Anyone can help me please. I have added JPA configuration and Log.
As per my concern i guess it is coming due to configuration mistake.
generate-ddl: false
hibernate:
ddl-auto: validate
:: Spring Boot :: (v1.2.1.RELEASE)
2016-06-21 19:31:52.733 INFO 8196 --- [ main] org.sam.application.Application : Starting Application on DESKTOP-JIBLNR1 with PID 8196 (C:\LabSystem\Scheduler\target\classes started by Sitansu in C:\LabSystem\Scheduler)
2016-06-21 19:31:52.805 INFO 8196 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#bd4dc25: startup date [Tue Jun 21 19:31:52 IST 2016]; root of context hierarchy
2016-06-21 19:31:53.912 INFO 8196 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.scheduling.annotation.SchedulingConfiguration' of type [class org.springframework.scheduling.annotation.SchedulingConfiguration$$EnhancerBySpringCGLIB$$960de3bc] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-06-21 19:31:53.948 INFO 8196 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.scheduling.annotation.ProxyAsyncConfiguration' of type [class org.springframework.scheduling.annotation.ProxyAsyncConfiguration$$EnhancerBySpringCGLIB$$3cdcd8e2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2016-06-21 19:31:54.435 INFO 8196 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2016-06-21 19:31:54.463 INFO 8196 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2016-06-21 19:31:54.560 INFO 8196 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.7.Final}
2016-06-21 19:31:54.561 INFO 8196 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2016-06-21 19:31:54.563 INFO 8196 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2016-06-21 19:31:54.900 INFO 8196 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2016-06-21 19:31:55.677 INFO 8196 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
2016-06-21 19:31:55.687 INFO 8196 --- [ main] o.h.e.jdbc.internal.LobCreatorBuilder : HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
2016-06-21 19:31:56.056 INFO 8196 --- [ main] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2016-06-21 19:31:56.592 INFO 8196 --- [ main] o.h.tool.hbm2ddl.SchemaValidator : HHH000229: Running schema validator
2016-06-21 19:31:56.593 INFO 8196 --- [ main] o.h.tool.hbm2ddl.SchemaValidator : HHH000102: Fetching database metadata
2016-06-21 19:31:56.628 INFO 8196 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000261: Table found: medxlabpro.appsettings
2016-06-21 19:31:56.629 INFO 8196 --- [ main] o.hibernate.tool.hbm2ddl.TableMetadata : HHH000037: Columns: [hl7ftphostname, hl7ftppassword, clientcode, desktopheight1, desktopheight2, newordereligipdfneeded, billingdays, receiptno, defaultpagesize, desktopheight3, postingbatchno, desktopheight4, desktopheight5, id, edibatchno, desktopheight6, datarootfolder, desktopheight7, desktopheight8, claimno, hl7ftpfolder, hl7ftpusername, neworderorderpdfneeded, authpassword, desktoppagesize8, hl7ftpport, desktoppagesize6, neworderresultpdfneeded, desktoppagesize7, desktoppagesize4, desktoppagesize5, versionno, desktoppagesize2, desktoppagesize3, desktoppagesize1, invoiceno]
2016-06-21 19:31:56.636 WARN 8196 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Missing column: auth_password in abcdpro.appsettings
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:961)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:950)
at org.sam.application.Application.main(Application.java:33)
Caused by: org.hibernate.HibernateException: Missing column: auth_password in abcdpro.appsettings
at org.hibernate.mapping.Table.validateColumns(Table.java:365)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1338)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:525)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
JPA configuration:
jpa:
generate-ddl: false
hibernate:
ddl-auto: validate
database: MYSQL
show-sql: true
How can i fix this anyone can help me please ?
Thanks
Sitansu
By default Spring Boot uses SpringNamingStrategy. This strategy generates underscores in table and field names. So for field authPassword the strategy generates auth_password column name.
If you want to map entity fields to camel case column names you can use org.hibernate.cfg.EJB3NamingStrategy or implement your own.
You can specify a naming strategy in application.properties
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
I have column in my PoJo class authpassword not auth_password.
Easy solution could be:
add #Column(name="auth_password") to your authpassword field.
Then it should work

Simple Spring/AngularJS Rest Consumption Tutorial Won't Get/Display Data

I'm following this tutorial exactly, but I can't seem to get the JSON content to load successfully.
Here are the files that I've created per the tutorial:
index.html:
<!doctype html>
<html ng-app>
<head>
<title>Hello AngularJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="hello.js"></script>
</head>
<body>
<div ng-controller="Hello">
<p>The ID is {{greeting.id}}</p>
<p>The content is {{greeting.content}}</p>
</div>
</body>
</html>
hello.js:
function Hello($scope, $http) {
$http.get('http://rest-service.guides.spring.io/greeting').
success(function(data) {
$scope.greeting = data;
});
}
app.groovy:
#Controller class JsApp { }
Here is the output from my running of the command spring run app.groovy:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Dev\rest-test>spring run app.groovy
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.2.5.RELEASE)
2015-09-02 22:52:00.032 INFO 1968 --- [ runner-0] o.s.boot.SpringApplicat
ion : Starting application on asbs-dev with PID 1968 (C:\Users\me\.m2\repository\org\springframework\boot\spring-boot\1.2.5.RELEASE\spring-b
oot-1.2.5.RELEASE.jar started by me in C:\Dev\rest-test)
2015-09-02 22:52:00.513 INFO 1968 --- [ runner-0] ationConfigEmbeddedWebA
pplicationContext : Refreshing org.springframework.boot.context.embedded.Annotat
ionConfigEmbeddedWebApplicationContext#1336a56: startup date [Wed Sep 02 22:52:0
0 EDT 2015]; root of context hierarchy
2015-09-02 22:52:03.049 INFO 1968 --- [ runner-0] o.s.b.f.s.DefaultListab
leBeanFactory : Overriding bean definition for bean 'beanNameViewResolver':
replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; auto
wireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBea
nName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$White
labelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodN
ame=null; destroyMethodName=(inferred); defined in class path resource [org/spri
ngframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorView
Configuration.class]] with [Root bean: class [null]; scope=; abstract=false; laz
yInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=
false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConf
iguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver
; initMethodName=null; destroyMethodName=(inferred); defined in class path resou
rce [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAu
toConfigurationAdapter.class]]
2015-09-02 22:52:05.578 INFO 1968 --- [ runner-0] s.b.c.e.t.TomcatEmbedde
dServletContainer : Tomcat initialized with port(s): 8080 (http)
2015-09-02 22:52:05.983 INFO 1968 --- [ runner-0] o.apache.catalina.core.
StandardService : Starting service Tomcat
2015-09-02 22:52:05.987 INFO 1968 --- [ runner-0] org.apache.catalina.cor
e.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.23
2015-09-02 22:52:06.200 INFO 1968 --- [ost-startStop-1] org.apache.catalina.loa
der.WebappLoader : Unknown loader org.springframework.boot.cli.compiler.Extende
dGroovyClassLoader$DefaultScopeParentClassLoader#1adac6c class org.springframewo
rk.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader
2015-09-02 22:52:06.279 INFO 1968 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[loc
alhost].[/] : Initializing Spring embedded WebApplicationContext
2015-09-02 22:52:06.279 INFO 1968 --- [ost-startStop-1] o.s.web.context.Context
Loader : Root WebApplicationContext: initialization completed in 5769
ms
2015-09-02 22:52:08.356 INFO 1968 --- [ost-startStop-1] o.s.b.c.e.ServletRegist
rationBean : Mapping servlet: 'dispatcherServlet' to [/]
2015-09-02 22:52:08.370 INFO 1968 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-09-02 22:52:08.371 INFO 1968 --- [ost-startStop-1] o.s.b.c.embedded.Filter
RegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-09-02 22:52:09.236 INFO 1968 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.cont
ext.embedded.AnnotationConfigEmbeddedWebApplicationContext#1336a56: startup date
[Wed Sep 02 22:52:00 EDT 2015]; root of context hierarchy
2015-09-02 22:52:09.453 INFO 1968 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.Res
ponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframewo
rk.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServ
letRequest)
2015-09-02 22:52:09.455 INFO 1968 --- [ runner-0] s.w.s.m.m.a.RequestMapp
ingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.spr
ingframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web
.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2015-09-02 22:52:09.474 INFO 1968 --- [ runner-0] o.s.w.s.c.a.WebMvcConfi
gurerAdapter : Adding welcome page: file:/C:/Dev/rest-test/public/index.htm
l
2015-09-02 22:52:09.525 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Root mapping to handler of type [class org.springframework.w
eb.servlet.mvc.ParameterizableViewController]
2015-09-02 22:52:09.556 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class or
g.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:09.557 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.spring
framework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:09.723 INFO 1968 --- [ runner-0] o.s.w.s.handler.SimpleU
rlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [clas
s org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-09-02 22:52:11.165 INFO 1968 --- [ runner-0] o.s.j.e.a.AnnotationMBe
anExporter : Registering beans for JMX exposure on startup
2015-09-02 22:52:11.428 INFO 1968 --- [ runner-0] s.b.c.e.t.TomcatEmbedde
dServletContainer : Tomcat started on port(s): 8080 (http)
2015-09-02 22:52:11.429 INFO 1968 --- [ runner-0] o.s.boot.SpringApplicat
ion : Started application in 12.111 seconds (JVM running for 17.50
4)
2015-09-02 22:52:17.615 INFO 1968 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[loc
alhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2015-09-02 22:52:17.616 INFO 1968 --- [nio-8080-exec-1] o.s.web.servlet.Dispatc
herServlet : FrameworkServlet 'dispatcherServlet': initialization started
2015-09-02 22:52:17.721 INFO 1968 --- [nio-8080-exec-1] o.s.web.servlet.Dispatc
herServlet : FrameworkServlet 'dispatcherServlet': initialization complet
ed in 102 ms
Additional details:
Windows 7
Google Chrome
Any thoughts as to why the JSON won't display in the HTML file?
When I tried your example in Firefox, I got the following in my browser console:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://rest-service.guides.spring.io/greeting. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
I presume this is because your Groovy server is running in localhost or somewhere other than rest-service.guides.spring.io? By default, web browsers will block $http response that comes from different domain. You need to make sure that the remote server allows cross-origin request, which will in turn tell your browser that the response is a valid cross-origin request which will not be blocked.
The tutorial that you linked seems to be pointing to another tutorial on how to enable CORS in your groovy server, although the URL is dead. I looked around in github and seems like the tutorial is moved to https://github.com/spring-guides/gs-rest-service-cors