Spring LdapTemplate org.slf4j.impl.StaticLoggerBinder problem - spring

I would like to create LdapTemplate:
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(ldapUrl);
contextSource.setUserDn(ldapPrincipal);
contextSource.setPassword(ldapPassword);
contextSource.setAuthenticationSource(new BasicAuthenticationSource(ldapPrincipal, ldapPassword));
contextSource.setReferral(LDAP_REFFERAL);
contextSource.setCacheEnvironmentProperties(false);
this.ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.setDefaultCountLimit(LDAP_RESULTS_LIMIT);
ldapTemplate.setDefaultSearchScope(SearchControls.SUBTREE_SCOPE);
ldapTemplate.setDefaultTimeLimit(LDAP_TIME_LIMIT);
I have LdapTemplate dependency in pom:
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
The problem is that during LdapContextSource contextSource = new LdapContextSource()
invocation there is slsf4j problem:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".|#] SLF4J: Defaulting to no-operation (NOP) logger implementation|#] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.|#]
I see that slf4j-api-1.7.21.jar is on depenedencies list

Related

No qualifying bean of type 'javax.persistence.EntityManagerFactory' available whike upgrading SpringBoot from 2.1.18.RELEASE to 2.6.2

No qualifying bean of type 'javax.persistence.EntityManagerFactory' available whike upgrading SpringBoot from 2.1.18.RELEASE to 2.6.2
#ConditionalOnProperty("spring.datasource.url")
#Configuration("databaseConfiguration")
#Service
public class DatabaseConfiguration {
/*Used both #Autowired and #PersistenceUnit but still giving same exception*/
#PersistenceUnit
private EntityManagerFactory entityManagerFactory;
#Autowired
ApplicationContext context;
#PostConstruct
public void initSessionFactory() {
SessionFactory sessionFactory = entityManagerFactory.unwrap(SessionFactory.class);
EventListenerRegistry registry = ((SessionFactoryImpl) sessionFactory).getServiceRegistry()
.getService(EventListenerRegistry.class);
registry.getEventListenerGroup(EventType.PERSIST).prependListener(new EntityListener());
registry.getEventListenerGroup(EventType.SAVE).prependListener(new EntityListener());
registry.getEventListenerGroup(EventType.SAVE_UPDATE).prependListener(new EntityListener());
registry.getEventListenerGroup(EventType.PERSIST_ONFLUSH).prependListener(new EntityListener());
ConfigurableListableBeanFactory beanFactory =
((ConfigurableApplicationContext) context).getBeanFactory();
beanFactory.registerSingleton("sessionFactory",
sessionFactory);
}
}
Could someone help me to resolve this issue.
Thanks.
Are you sure that you have an implementation of that interface in your project?
If you're using Spring Boot then maybe this Maven dependency could help:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
For configuration have a look at some tutorial, e.g. https://www.bezkoder.com/jpa-entitymanager-spring-boot/

intellij show “Could not autowire. No beans of 'JavaMailSender' type found.” while code still run correctly

I'm trying to autowire JavaMailSender
#Autowired
private JavaMailSender javaMailSender;
I have add these to pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
and these to application properties:
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=xxx
spring.mail.password=xxx
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
and the project run correctly (i successed send a mail). but intellij show error on javaMailSender variable. and when i hover my mouse to the error it show
"Could not autowire. No beans of 'JavaMailSender' type found."
How can I fix this error?
You need to create a bean for Javamailsender. If my guess is right, you have a spring security in your dependencies.
You can do it like this:
#Configuration
public class MailConfiguration {
#Bean
public JavaMailSender getJavaMailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost("smtp.gmail.com");
mailSender.setPort(587);
mailSender.setUsername("my#gmail.com");
mailSender.setPassword("mypassword");
Properties props = mailSender.getJavaMailProperties();
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
return mailSender;
}
}

Adding a dependency to a working Spring Boot project invalidates all JUnit

I have 2 Eclipse projects and each one is has services managed by Spring. I use Spring Boot starter dependencies for each of them. Each one works properly, and can be tested with JUnit launched via SpringRunner.class and #SpringBootTest.
Now, I want to call some services from project 1 in project 2, so I add a dependency in project 2 pom.xml and I add
#ComponentScan(basePackages="com.project1")
From then on, I can't launch any JUnit, it complains about dataSource not being set, like if configs where mixing randomly.
My question is : what are the recommended practices when you create a Spring Boot App and you want to isolate some features in a separate project (here XML features) ? If u can't have 2 spring boot app with one dependant of the other, what are the spring dependencies you need so the spring boot project can deal with the non spring boot dependency, and so that u can still launch JUnit using Spring runner locally ?
Do I need to pick Spring dependencies one by one (core, bean, context, test, log4j, slf4j, junit, hamcrest, ...) like before Spring boot exist to do this ?
See my comment on why the possible duplicate is different.
After removing all Spring boot dependencies from my module project, I still have the error as soon as I add the "ComponentScan" to scan the module services.
Here is my DB config (main project depending on a xml module) to be clear on the package config. This config WORKS perfectly until I add the ComponentScan on a package from the module project :
#Configuration
#EnableTransactionManagement
#EnableJpaRepositories(basePackages="fr.my.project.repository")
class PersistenceContext {
private static final String[] ENTITY_PACKAGES = { "fr.my.project.model" };
private static final String PROP_DB_DRIVER_CLASS = "db.driver";
private static final String PROP_DB_PASSWORD = "db.password";
private static final String PROP_DB_URL = "db.url";
private static final String PROP_DB_USER = "db.username";
private static final String PROP_HIBERNATE_DIALECT = "hibernate.dialect";
private static final String PROP_HIBERNATE_FORMAT_SQL = "hibernate.format_sql";
private static final String PROP_HIBERNATE_HBM2DDL_AUTO = "hibernate.hbm2ddl.auto";
private static final String PROP_HIBERNATE_SHOW_SQL = "hibernate.show_sql";
/**
* Creates and configures the HikariCP datasource bean.
*
* #param env
* The runtime environment of our application.
* #return
*/
#Bean(destroyMethod = "close")
DataSource dataSource(Environment env) {
HikariConfig dataSourceConfig = new HikariConfig();
dataSourceConfig.setDriverClassName(env.getRequiredProperty(PROP_DB_DRIVER_CLASS));
dataSourceConfig.setJdbcUrl(env.getRequiredProperty(PROP_DB_URL));
dataSourceConfig.setUsername(env.getRequiredProperty(PROP_DB_USER));
dataSourceConfig.setPassword(env.getRequiredProperty(PROP_DB_PASSWORD));
return new HikariDataSource(dataSourceConfig);
}
/**
* Creates the bean that creates the JPA entity manager factory.
*
* #param dataSource
* The datasource that provides the database connections.
* #param env
* The runtime environment of our application.
* #return
*/
#Bean
LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, Environment env) {
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource);
entityManagerFactoryBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
entityManagerFactoryBean.setPackagesToScan(ENTITY_PACKAGES);
Properties jpaProperties = new Properties();
// Configures the used database dialect. This allows Hibernate to create SQL
// that is optimized for the used database.
jpaProperties.put(PROP_HIBERNATE_DIALECT, env.getRequiredProperty(PROP_HIBERNATE_DIALECT));
// Specifies the action that is invoked to the database when the Hibernate
// SessionFactory is created or closed.
jpaProperties.put(PROP_HIBERNATE_HBM2DDL_AUTO, env.getRequiredProperty(PROP_HIBERNATE_HBM2DDL_AUTO));
// If the value of this property is true, Hibernate writes all SQL
// statements to the console.
jpaProperties.put(PROP_HIBERNATE_SHOW_SQL, env.getRequiredProperty(PROP_HIBERNATE_SHOW_SQL));
// If the value of this property is true, Hibernate will use prettyprint
// when it writes SQL to the console.
jpaProperties.put(PROP_HIBERNATE_FORMAT_SQL, env.getRequiredProperty(PROP_HIBERNATE_FORMAT_SQL));
entityManagerFactoryBean.setJpaProperties(jpaProperties);
return entityManagerFactoryBean;
}
/**
* Creates the transaction manager bean that integrates the used JPA provider with the Spring transaction mechanism.
*
* #param entityManagerFactory
* The used JPA entity manager factory.
* #return
*/
#Bean
JpaTransactionManager transactionManager(EntityManagerFactory entityManagerFactory) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(entityManagerFactory);
return transactionManager;
}
}
and after adding :
#ComponentScan(basePackages="fr.my.module.xml.service")
I get this error when launching any Junit :
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. 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 (no profiles are currently active).
Here is a temporary answer on how to configure the dependency project, but I hope some easier way benefiting of Spring Boot shortcuts for all app modules exist.
pom.xml with manual minimal dependencies :
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.14.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>4.3.14.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.11</version>
</dependency>
Manual test config :
#RunWith(SpringRunner.class)
#ContextConfiguration(loader=AnnotationConfigContextLoader.class, classes=AppConfig.class)
public class XmlTest {
Manual app config :
#Configuration
#ComponentScan(basePackages="my.package.xml")
public class AppConfig {
}
Sooooooo after doing all these tries, Spring Boot may not be the cause of this problem at all.
The thing is I was adding #ComponentScan(basePackages="fr.package.xml") hoping to complete the default package scanning, but it was overriding it.
The proper way to add a package, is to redeclare explicitely the default package before adding the new package :
#ComponentScan(basePackages={"fr.package.xml", "fr.package.persistence"})
My other answer was about setting up manual minimal dependencies for a module in a Spring Boot app. But here is an example of using Spring boot special dependencies in the module which is not the main app :
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Then, you don't declare "#SpringBootApplication" in a main class in src/main/java where it may break the global packaging, but you set it up inside your test class :
#RunWith(SpringRunner.class)
#SpringBootTest("service.message=Hello")
public class MyServiceTest {
#Autowired
private MyService myService;
#Test
public void contextLoads() {
assertThat(myService.message()).isNotNull();
}
#SpringBootApplication
static class TestConfiguration {
}
}
source : https://github.com/spring-guides/gs-multi-module/tree/master/complete

How to link database in mongodb through spring

I really need some help, I have gone through an entire day of searching and still did not find anything that works.
Note : My database has username and password
And these two are the dependencies that i am working with.
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.7.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
This is my xml config file :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<mongo:mongo-client host="address" port="27017 credentials="username:password#databasename" />
</beans>
This is my main class which loads this xml:
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import model.user;
//import org.springframework.context.support.GenericXmlApplicationContext;
public class App {
public static void main(String[] args) {
/*
ApplicationContext ctx = new AnnotationConfigApplicationContext(appConfig.class);
MongoOperations mongoOperation = (MongoOperations) ctx.getBean("mongoTemplate");
*/
ApplicationContext ctx = new GenericXmlApplicationContext("config.xml");
MongoOperations mongoOperation = (MongoOperations)ctx.getBean("mongoTemplate");
user user = new user();
// save
// mongoOperation.save(user);
// now user object got the created id.
System.out.println("1. user : " + user);
// query to search user
Query searchUserQuery = new Query(Criteria.where("age").is(26));
mongoOperation.findOne(searchUserQuery, user.class);
}
}
This is the error message I get:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongo': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: com.mongodb.MongoCredential.createCredential(Ljava/lang/String;Ljava/lang/String;[C)Lcom/mongodb/MongoCredential;
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:547)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:687)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.context.support.GenericXmlApplicationContext.<init>(GenericXmlApplicationContext.java:70)
at core.App.main(App.java:20)
Caused by: java.lang.NoSuchMethodError: com.mongodb.MongoCredential.createCredential(Ljava/lang/String;Ljava/lang/String;[C)Lcom/mongodb/MongoCredential;
at org.springframework.data.mongodb.config.MongoCredentialPropertyEditor.setAsText(MongoCredentialPropertyEditor.java:108)
at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:430)
at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:403)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:181)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:460)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:512)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:506)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1503)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1462)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1198)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
... 10 more
Okay finally I was able to connect to the database, I did it using MongoClient. This is the code snippet:
MongoCredential credential = MongoCredential.createMongoCRCredential("username", "database", password);
MongoClient mongoClient = new MongoClient(new ServerAddress("address", 27017), Arrays.asList(credential));
// get handle to "mydb"
DB db = mongoClient.getDB("IODS");
// get a list of the collections in this database and print them out
Set<String> collectionNames = db.getCollectionNames();
for (final String s : collectionNames) {
System.out.println(s);
}
// get a collection object to work with
DBCollection coll = db.getCollection("try_vishal");

SpringBoot with Quartz and Tomcat datasource: Driver's Blob representation is of an unsupported type: oracle.sql.BLOB

I am using SpringBoot 1.4.5 and quartz for scheduling with a DataSource configured in Tomcat's context.xml which is injected as a bean via JndiDataSource for connecting to a Oracle 10g DB.
Here are the relevant dependencies, including the Oracle driver, I am using the dependency management provided by SpringBoot:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz-jobs</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>oracle-ojdbc7</artifactId>
<version>12.1.0-2</version>
</dependency>
This is the DataSource configured in Tomcat in context.xml (the placeholder properties are defined in catalina.properties) :
<Resource name="${tomcat.dbpool.ups.quartz.resourcename}" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="${tomcat.dbpool.ups.quartz.connectionurl}"
username="${tomcat.dbpool.ups.quartz.username}"
password="${tomcat.dbpool.ups.quartz.password}"
maxTotal="${tomcat.dbpool.ups.quartz.maxTotal}"
maxIdle="${tomcat.dbpool.ups.quartz.maxIdle}"
minIdle="${tomcat.dbpool.ups.quartz.minIdle}"
maxWaitMillis="${tomcat.dbpool.ups.quartz.maxWaitMillis}"
validationQueryTimeout="${tomcat.dbpool.ups.quartz.validationQueryTimeout}"
testWhileIdle="true"
removeAbandonedOnMaintenance="true"
timeBetweenEvictionRunsMillis="${tomcat.dbpool.ups.quartz.timeBetweenEvictionRunsMillis}"
minEvictableIdleTimeMillis="${tomcat.dbpool.ups.quartz.minEvictableIdleTimeMillis}"
/>
The datasource bean configuration and quartz necessary beans:
#Bean
public JobFactory jobFactory(final ApplicationContext applicationContext) {
final AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
jobFactory.setApplicationContext(applicationContext);
return jobFactory;
}
#Bean
public SchedulerFactoryBean schedulerFactoryBean(#Qualifier("quartzDataSource") final DataSource quartzDS,
final JobFactory jobFactory,
#Qualifier("loansAppTrigger") final Trigger jobTrigger) throws IOException {
final SchedulerFactoryBean factory = new SchedulerFactoryBean();
// this allows to update triggers in DB when updating settings in config file:
factory.setOverwriteExistingJobs(true);
factory.setDataSource(quartzDS);
factory.setJobFactory(jobFactory);
factory.setQuartzProperties(quartzProperties());
factory.setTriggers(jobTrigger);
return factory;
}
#Bean(name = "quartzDataSource")
#Profile("!local")
public DataSource jndiDataSource() {
JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
DataSource dataSource = dataSourceLookup.getDataSource("java:comp/env/jdbc/QUARTZ");
return dataSource;
}
#Bean
public Properties quartzProperties() throws IOException {
final PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
#Bean
public JobDetailFactoryBean checkUnconfirmedApplicationsJobDetail() {
return createJobDetail(CheckUnconfirmedApplicationsJob.class);
}
#Bean(name = "loansAppTrigger")
public SimpleTriggerFactoryBean unconfirmedLoansApplicationsTrigger(
#Qualifier("checkUnconfirmedApplicationsJobDetail") final JobDetail jobDetail,
#Value("${ups.loan.check.pending.apps.frequency}") final long frequency) {
return createTrigger(jobDetail, frequency);
}
private static JobDetailFactoryBean createJobDetail(final Class jobClass) {
final JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
factoryBean.setJobClass(jobClass);
// job has to be durable to be stored in DB:
factoryBean.setDurability(true);
return factoryBean;
}
private static SimpleTriggerFactoryBean createTrigger(final JobDetail jobDetail, final long pollFrequencyMs) {
final SimpleTriggerFactoryBean factoryBean = new SimpleTriggerFactoryBean();
factoryBean.setJobDetail(jobDetail);
factoryBean.setStartDelay(0L);
factoryBean.setRepeatInterval(pollFrequencyMs);
factoryBean.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
// in case of misfire, ignore all missed triggers and continue :
factoryBean.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT);
return factoryBean;
}
And the following properties in quartz.properties file:
org.quartz.scheduler.instanceName=scheduler
org.quartz.scheduler.instanceId=AUTO
org.quartz.threadPool.threadCount=5
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
org.quartz.jobStore.tablePrefix=QRTZ_
org.quartz.jobStore.useProperties=true
org.quartz.jobStore.misfireThreshold=60000
org.quartz.jobStore.isClustered=true
org.quartz.jobStore.clusterCheckinInterval=20000
When I deploy this on Tomcat 8 I get the following error :
org.quartz.JobPersistenceException: Couldn't store job: Driver's Blob representation is of an usupported type: oracle.sql.BLOB
In Tomcat's lib folder I have the oracle-ojdbc7-12.1.0-2.jar driver.
Can you please check if you have any duplicate oracle-ojdbc JAR files present? The JAR should be in only one location: either in WEB-INF/lib or under tomcat/lib

Resources