Spring boot Apache Camel Quartz JDBC scheduler - java

I using spring boot with apache camel and I want to create quartz scheduler but when I using this configuration nothing has happened:
camel:
component:
quartz2:
properties:
org:
quartz:
scheduler:
instanceName: ClusteredSchedular
instanceId: AUTO
threadPool:
class: org.quartz.simpl.SimpleThreadPool
threadCount: 25
threadPriority: 5
jobStore:
class: org.quartz.impl.jdbcjobstore.JobStoreTX
driverDelegateClass: org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
dataSource: quartz
isClustered: true
clusterCheckinInterval: 20000
dataSource:
quartz:
driver: oracle.jdbc.driver.OracleDriver
URL: jdbc:oracle:thin:#localhost:1521:xe
user: test
password: test
maxConnections: 5
validationQuery: select 1 from dual
Does anyone have an idea why this configuration doesn't work? Camel only see this configuration from default config
org.quartz.scheduler.instanceName: DefaultQuartzScheduler
org.quartz.scheduler.rmi.export: false
org.quartz.scheduler.rmi.proxy: false
org.quartz.scheduler.wrapJobExecutionInUserTransaction: false
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 10
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true
org.quartz.jobStore.misfireThreshold: 60000
org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore

I would prefer to use springboot datasource to enable quartz clustering.
spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://127.0.0.1:5432/postgres
username: postgres
password: password
quartz:
scheduler-name: quartzSchedulernot work anymore
jobStoreType: jdbc
startup-delay: PT10S
wait-for-jobs-to-complete-on-shutdown: true
properties:
org.quartz.scheduler.instanceId: AUTO
org.quartz.scheduler.jmx.export: true
org.quartz.threadPool.threadCount: 15
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true
org.quartz.jobStore.driverDelegateClass: org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
org.quartz.jobStore.tablePrefix: QRTZ_
org.quartz.jobStore.isClustered: true
org.quartz.jobStore.clusterCheckinInterval: 1000

Related

test-on-borrow config in hikariCP

I have spring boot 2.0.2.RELEASE project and I want configure datasources with pool connection.
I use Spring data JPA + hibernate + HikariCP:
#DataBase properties
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.datasource.url=***
spring.datasource.username=*****
spring.datasource.password=*****
# Hikari
spring.datasource.hikari.minimumIdle=5
spring.datasource.hikari.maximumPoolSize=20
spring.datasource.hikari.idleTimeout=30000
spring.datasource.hikari.poolName=SpringBootJPAHikariCP
spring.datasource.hikari.maxLifetime=2000000
spring.datasource.hikari.connectionTimeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
#jpa config
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=true
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.data.jpa.repositories.enabled=true
In #DataBase properties - I think everything is fine
In #Hikari - I do not know how implement this:
in tomcat I can write spring.datasource.tomcat.test-on-borrow=true but how can I make like this with Hikari ?
And mayby I forgote some important configs?

java.lang.NoClassDefFoundError: org/springframework/beans/factory/config/EmbeddedValueResolver

I've recently managed to upgrade a jhipster generated app (Spring Boot + Angular)
Issue comes after cleaning code and adapting a few annotations, now I get success when doing a maven clean - install skipping tests but when I try to start the app I get the error mentioned in the title
I've checked pom for duplicated dependencies and had a clean out of the properties file, to no result
This is the full error:
2017-11-30 10:12:57.821 INFO 4320 --- [ restartedMain] o.w.d.DrugQualityDataManagerApp : Starting DrugQualityDataManagerApp on steven-OptiPlex-7040 with PID 4320 (/home/steven/Desktop/Upgraded_MQ/target/classes started by steven in /home/steven/Desktop/Upgraded_MQ)
2017-11-30 10:12:57.821 INFO 4320 --- [ restartedMain] o.w.d.DrugQualityDataManagerApp : The following profiles are active: swagger,dev
2017-11-30 10:12:57.874 ERROR 4320 --- [ restartedMain] o.s.boot.SpringApplication : Application startup failed
java.lang.NoClassDefFoundError: org/springframework/beans/factory/config/EmbeddedValueResolver
at org.springframework.context.support.ApplicationContextAwareProcessor.<init>(ApplicationContextAwareProcessor.java:72)
at org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:634)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:518)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.wwarn.drugquality.DrugQualityDataManagerApp.main(DrugQualityDataManagerApp.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.config.EmbeddedValueResolver
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 common frames omitted
2017-11-30 10:12:58.127 WARN 4320 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#350e9339: startup date [Thu Nov 30 10:12:57 GMT 2017]; root of context hierarchy
at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:427)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:999)
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:958)
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
at org.wwarn.drugquality.DrugQualityDataManagerApp.main(DrugQualityDataManagerApp.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Disconnected from the target VM, address: '127.0.0.1:43599', transport: 'socket'
Process finished with exit code 1
My pom.xml (I had to embed it in a jsFiddle as it's too long for the body of an SO post)
Properties file:
spring:
profiles:
active: dev
include: swagger
devtools:
restart:
enabled: true
livereload:
enabled: false # we use gulp + BrowserSync for livereload
jackson:
serialization.indent_output: true
datasource:
url: jdbc:mysql://localhost:3306/myDB?useUnicode=true&characterEncoding=utf8
username: myDB
password: myDB
h2:
console:
enabled: false
jpa:
database-platform: org.hibernate.dialect.MySQLDialect
database: MYSQL
show_sql: false
generate-ddl: true
hibernate:
ddl-auto: update
naming:
physical-strategy: org.wwarn.drugquality.config.HibernateAuditTablesNamingStrategy
properties:
hibernate.id.new_generator_mappings: true
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: true
hibernate.cache.region.factory_class: org.hibernate.cache.jcache.JCacheRegionFactory
data:
elasticsearch:
cluster-name:
cluster-nodes:
properties:
path:
logs: target/elasticsearch/log
data: target/elasticsearch/data
mail:
host: localhost
port: 25
username:
password:
messages:
cache-seconds: 1
thymeleaf:
cache: false
liquibase:
contexts: dev
server:
port: 8080
jhipster:
http:
version: V_1_1 # To use HTTP/2 you will need SSL support (see above the "server.ssl" configuration)
cache: # Cache configuration
ehcache: # Ehcache configuration
time-to-live-seconds: 3600 # By default objects stay 1 hour in the cache
max-entries: 100 # Number of objects in each cache entry
# CORS is only enabled by default with the "dev" profile, so BrowserSync can access the API
cors:
allowed-origins: "*"
allowed-methods: "*"
allowed-headers: "*"
allow-credentials: true
max-age: 1800
security:
remember-me:
# security key (this key should be unique for your application, and kept secret)
key: daKey
mail: # specific JHipster mail property, for standard properties see MailProperties
from: DrugQualityDataManager#localhost
base-url: http://127.0.0.1:8080
metrics: # DropWizard Metrics configuration, used by MetricsConfiguration
jmx.enabled: true
graphite: # Use the "graphite" Maven profile to have the Graphite dependencies
enabled: false
host: localhost
port: 2003
prefix: DrugQualityDataManager
prometheus: # Use the "prometheus" Maven profile to have the Prometheus dependencies
enabled: false
endpoint: /prometheusMetrics
logs: # Reports Dropwizard metrics in the logs
enabled: false
report-frequency: 60 # in seconds
logging:
logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
enabled: false
host: localhost
port: 5000
queue-size: 512
# ===================================================================
# Application specific properties
# Add your own application properties here, see the ApplicationProperties class
# to have type-safe configuration, like in the JHipsterProperties above
#
# More documentation is available at:
# http://www.jhipster.tech/common-application-properties/
# ===================================================================
application:
In your fiddled pom there is this dep:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.9.RELEASE</version>
</dependency>
The EmbeddedValueResolver was introduced in Spring 4.3
You might want to clean up your dependencies. Perhaps it's sufficient to pull spring-beans up to 4.3

Defining and Removing Spring Boot / Spring JPA Datasources Programmatically at Runtime?

I need to create Spring Boot Datasources dynamically at runtime. Anyone know how to do this. Effectively I need to do this on demand:
spring:
datasource:
url: jdbc:h2:mem:testdb1;
username: sa
password:
driver-class-name: org.h2.Driver
platform: h2
spring:
datasource:
url: jdbc:h2:mem:testdb2;
username: sa
password:
driver-class-name: org.h2.Driver
platform: h2
...
spring:
datasource:
url: jdbc:h2:mem:testdbN;
username: sa
password:
driver-class-name: org.h2.Driver
platform: h2
Thoughts?
Try below way to create data-source programmatically
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setUrl("jdbc:h2:mem:testdb1");
dataSource.setUsername("sa");
dataSource.setPassword("");
dataSource.setDriverClassName("org.h2.Driver");

Grails 3.0.4 deploying localhost but not remotely

Someone help please...I am able to run:
grails run-app
and access my application on localhost:8080. However, I have no luck deploying to Tomcat 7.052 on Ubuntu 14.04.1LTS. The war file uploads successfully using the Tomcat Web Manager but I get HTTP error 404 upon accessing via the browser. I am clicking on the application link on the Tomcat Web Manager to access the applications. I tried deploying the sample.war file from Tomcat examples and it works.
Here is what I have tried:
1) I changed my build.gradle file from:
...
compile "org.springframework.boot:spring-boot-starter-tomcat"
...
to:
...
provided "org.springframework.boot:spring-boot-starter-tomcat"
...
2) I ran:
grails war
to generate a war file in which I then uploaded successfully using Tomcat Web Manager.
3) I also tried restarting the tomcat service.
Here is my grails-app/conf/application.yml file:
---
grails:
profile: web
codegen:
defaultPackage: myApp
info:
app:
name: '#info.app.name#'
version: '#info.app.version#'
grailsVersion: '#info.app.grailsVersion#'
spring:
groovy:
template:
check-template-location: false
---
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
types:
all: '*/*'
atom: application/atom+xml
css: text/css
csv: text/csv
form: application/x-www-form-urlencoded
html:
- text/html
- application/xhtml+xml
js: text/javascript
json:
- application/json
- text/json
multipartForm: multipart/form-data
pdf: application/pdf
rss: application/rss+xml
text: text/plain
hal:
- application/hal+json
- application/hal+xml
xml:
- text/xml
- application/xml
urlmapping:
cache:
maxsize: 1000
controllers:
defaultScope: singleton
converters:
encoding: UTF-8
views:
default:
codec: html
gsp:
encoding: UTF-8
htmlcodec: xml
codecs:
expression: html
scriptlets: html
taglib: none
staticparts: none
---
hibernate:
cache:
queries: false
use_second_level_cache: true
use_query_cache: false
region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
dataSource:
pooled: true
jmxExport: true
driverClassName: org.h2.Driver
username: sa
password:
environments:
development:
dataSource:
dbCreate: create-drop
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
test:
dataSource:
dbCreate: update
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
production:
dataSource:
dbCreate: update
url: jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
properties:
jmxEnabled: true
initialSize: 5
maxActive: 50
minIdle: 5
maxIdle: 25
maxWait: 10000
maxAge: 600000
timeBetweenEvictionRunsMillis: 5000
minEvictableIdleTimeMillis: 60000
validationQuery: SELECT 1
validationQueryTimeout: 3
validationInterval: 15000
testOnBorrow: true
testWhileIdle: true
testOnReturn: false
jdbcInterceptors: ConnectionState
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
After digging into the log files (catalina.out) embedded below, I found out that Tomcat was using Java 7 whilst my grails application had used Java 8. Here is what I did:
1) I installed Java 8 on my server and set Tomcat to use it. This has significantly slowed down my Tomcat though.
2) I then configured my dataSource in grails-app/conf/application.yml to include the correct configurations for MySQL database. These configuration are in Grails 3.x documentation under dataSource.
3) Lastly, I included
runtime 'mysql:mysql-connector-java:5.1.29'
in my gradle.build dependencies.
Sep 09, 2015 2:47:32 AM org.apache.catalina.util.Introspection loadClass
FINE: Failed to load class [{0}]
java.lang.UnsupportedClassVersionError: myApp/ApplicationLoader : Unsupported major.minor version 52.0 (unable to load class myApp.ApplicationLoader)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2948)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1208)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1688)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1569)
at org.apache.catalina.util.Introspection.loadClass(Introspection.java:143)
at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:2117)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2056)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2030)
at org.apache.catalina.startup.ContextConfig.processAnnotationsFile(ContextConfig.java:2023)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1288)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:873)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:371)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Spring Boot 1.2.1.RELEASE and JNDI Errors

I receive an error when I deploy my web application, using IntelliJ 14.0, to a local Apache Tomcat instance. I am using Spring Boot 1.2.1.RELEASE and with a JNDI connection.
The contents of my application.yaml file looks like this:
spring:
profiles:
active: production
---
spring:
profiles: development
datasource:
platform: h2
---
spring:
profiles: production
datasource:
jndi-name: java:/comp/env/jdbc/teams
platform: mysql
jpa:
hibernate:
ddl-auto: create-drop
My configuration file, Application.java, looks like this:
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
I am using Apache Tomcat 8.0.15 and have configured a JNDI connection in the context.xml file.
<Resource name="jdbc/teams" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="***" password="***" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/teams"/>
I am using IntelliJ 14.0 to deploy my application locally to Apache Tomcat using the production profile.
The error I receive when when I attempt to deploy the application is as follows:
org.springframework.jmx.export.UnableToRegisterMBeanException: Unable to register MBean [org.apache.tomcat.dbcp.dbcp2.BasicDataSource#4f83492a] with key 'dataSource'; nested exception is javax.management.InstanceAlreadyExistsException: Catalina:type=DataSource,host=localhost,context=/project,class=javax.sql.DataSource,name="jdbc/teams"
What could be wrong with the way the application is configured?
I modified the application.yaml file and the application is now working. I added spring.jmx.enabled and spring.jpa.database-platform properties to the application.yaml file.
spring:
profiles:
active: production
spring:
profiles: development
datasource:
platform: h2
spring:
profiles: production
datasource:
jndi-name: java:/comp/env/jdbc/teams
platform: mysql
jpa:
hibernate:
ddl-auto: create-drop
database-platform: org.hibernate.dialect.MySQL5Dialect
jmx:
enabled: false

Categories

Resources