i'm trying to follow the exact same steps on this
Spring Boot Drools Rule Engine Example
but I have this error at compilation time :
Error creating bean with name 'kieContainer' defined in class path resource [.../DroolsConfig.class]: Failed to instantiate [org.kie.api.runtime.KieContainer]: Factory method 'kieContainer' threw exception with message: Cannot invoke "org.drools.compiler.compiler.Dialect.getBuilder(java.lang.Class)" because the return value of "org.drools.compiler.rule.builder.RuleBuildContext.getDialect()" is null ...................
those are the dependencies added to my pom.xml
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>8.33.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>8.33.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-decisiontables</artifactId>
<version>8.33.0.Final</version>
</dependency>```
I'm using spring boot 3
Thank you for your help!
I'm using java Records instead of normal class
I fixed it by adding this dependency to pom.xml
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-mvel</artifactId>
<version>version...</version>
</dependency>
Related
I have a problem with proper configure mongock for my project.
I have added to pom.xml dependencies:
<dependencies>
<dependency>
<groupId>io.mongock</groupId>
<artifactId>mongock-springboot</artifactId>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>io.mongock</groupId>
<artifactId>mongodb-springdata-v3-driver</artifactId>
<version>5.2.2</version>
</dependency>
...
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.mongock</groupId>
<artifactId>mongock-driver-mongodb-bom</artifactId>
<version>5.2.2</version>
<type>pom</type>
</dependency>
...
</dependencies>
</dependencyManagement>
I have added annotation on ApplicationClass: #EnableMongock
In application.yml I have added configuration:
mongock:
migration-scan-package:
- com.test.project.config.dbmigrations
enabled: true
Documentation says that this setup should be enough, but when I run app I have got error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method getBuilder in io.mongock.runner.springboot.config.MongockContext required a bean of type 'io.mongock.driver.api.driver.ConnectionDriver' that could not be found.
Action:
Consider defining a bean of type 'io.mongock.driver.api.driver.ConnectionDriver' in your configuration.
Do you know how to fix it? Thanks in advance.
You can try by making a setup bean.
#Bean
public MongockApplicationRunner mongockApplicationRunner(
ApplicationContext springContext,
MongoTemplate mongoTemplate) {
return MongockSpringboot.builder()
.setDriver(SpringDataMongoV3Driver.withDefaultLock(mongoTemplate))
.addMigrationScanPackage("your_changeLog_package_path")
.setSpringContext(springContext)
.buildApplicationRunner();
}
I want to access an oracle sql database using spring jpa since it's a remote server, and apache camel.
This is a code sample:
RouteBuilder
rest("/getfromdb")
.get()
.to("direct:getfromdb");
from("direct:getfromdb")
.transform().simple("SELECT PERSON_ID FROM XXISF_LEAVE_TEMP;")
.to("jdbc:dataSource") //spring boot starter jdbc creates the bean in the registry
.log("${body}");
application.properties file
server.port=9085
camel.servlet.mapping.context-path=/*
spring.datasource.url=jdbc:oracle:thin:#server:port/serviceName
spring.datasource.username=apps
spring.datasource.password=OneTeam2020
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle12cDialect
pom, dependencies related to jdbc and jpa:
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>orai18n</artifactId>
<version>19.3.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jdbc-starter</artifactId>
<version>${camel.version}</version>
<!-- use the same version as your Camel core version -->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.3.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jdbc</artifactId>
<version>${camel.version}</version>
</dependency>
Note that my oracle database is 19c, and I am getting the following errors:
1- java.sql.SQLException: Numeric Overflow
2- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory;
3- nested exception is org.hibernate.exception.GenericJDBCException: Unable to build DatabaseInformation
So any idea how to solve this issue? because I did not find anything that could help. Thank you
no Hibernate Bean Validator could be found even though it's added to the classpath.
I have a simple web application in Spring Boot. I am trying to test the Hibernate Validator with this simple function:
public void validateUser(User user) {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<User>> violations = validator.validate(user);
}
But it throws an exception:
javax.validation.NoProviderFoundException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
I tried using different libraries but they all don't work.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>7.0.1.Final</version>
</dependency>
I am using Java 17.
For a Spring Boot project you would want to add the spring-boot-starter-validation starter dependency.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
All the Spring Boot started projects can be found in the official documentation: spring.io
After you add a new dependency to your pom.xml file, I recommend running mwnv clean package (or mvn clean package) to fetch the dependencies and build a clean project.
Also, for bootstrapping/generating Spring Boot projects you may want to use Spring Initializr.
After an upgrade to Apache Camel 2.21.1, my application is failing to start. Specifically, the upgrade to camel-aws causes the application to throw this error on startup:
Error creating bean with name 'incomingEndpoint': FactoryBean threw
exception on object creation; nested exception is
java.lang.NoClassDefFoundError:
org/apache/camel/component/extension/ComponentExtension
Here are my related dependencies:
<properties>
<apache.camel.version>2.21.1</apache.camel.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${apache.camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-aws</artifactId>
<version>${apache.camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<version>${apache.camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http4</artifactId>
<version>${apache.camel.version}</version>
</dependency>
</dependencies>
Has anyone else experienced this recently? My application works when I switch the camel-aws dependency to version to 2.19.2.
As #burki mentioned in the comments, it looked like a transitive dependency issue (classic problem in my experience with large maven projects).
I used mvn dependency:tree to determine which dependencies were clashing and upgraded the dependency that needed to match the latest version.
I would like to setup a simple example of Java Spring and MongoDB but I have not been able yet. In this case, I am following the example in Spring web.
I have installed Maven, Mongo DB and Java JDK 1.8 with JRE8. Furthermore, in the pom.xml file, I have had to include this dependency due to a compilation error:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-core</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
Finally, following the mentioned web instructions, I type:
mvn spring-boot:run
or
java -jar target/gs-accessing-data-mongodb-0.1.0.jar
In the first case, spring-boot, I obtain the following error:
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.2.5.RELEASE:run (default-cli) on project gs-accessing-data-mongodb: An exception occured while running. null: InvocationTargetException: Error creating bean with name 'messageConverters' defined in class path resource [org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.web.HttpMessageConverters]: Factory method 'messageConverters' threw exception; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException: com.fasterxml.jackson.core.JsonProcessingException -> [Help 1]
Any ideas of what to do? Thanks in advance.
Not it works and my dependencies look like this:
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-core</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
</dependencies>
And the result in console:
Customers found with findAll():
-------------------------------
Customer[id=55b52943dac11e2ab8262f16, firstName='Alice', lastName='Smith']
Customer[id=55b52944dac11e2ab8262f17, firstName='Bob', lastName='Smith']
Customer found with findByFirstName('Alice'):
--------------------------------
Customer[id=55b52943dac11e2ab8262f16, firstName='Alice', lastName='Smith']
Customers found with findByLastName('Smith'):
--------------------------------
Customer[id=55b52943dac11e2ab8262f16, firstName='Alice', lastName='Smith']
Customer[id=55b52944dac11e2ab8262f17, firstName='Bob', lastName='Smith']
2015-07-26 20:39:00.438 INFO 1884 --- [lication.main()] hello.Application : Started Application in 4.726 seconds (JVM running for 7.57)