spring-data-jpa | Simplifies the development of creating a JPA-based data access layer | Object-Relational Mapping library
kandi X-RAY | spring-data-jpa Summary
Support
Quality
Security
License
Reuse
- Registers all beans for root
- Prepare and register shared entity manager
- Creates a bean definition for the entity manager
- PostProcesses bean factory
- Gets all bean definitions for the given bean factory
- Registers an entity manager factory with the given name
- Returns a count query string for this parse
- Detects an alias from a JPA query
- Executes the given example using the given example
- Executes the query using the specified criteria
- Extract the output value from a given stored procedure query
- Get the SELECT projection
- Detects the SQL type of the query
- Returns the QueryRewriter for the given method
- Determines whether the access type should be used
- Post process persistence unit info
- Retrieves multiple entities
- Gets the id of the given entity
- Creates the count query
- Parses the given XML element
- Checks if an entity exists
- Apply sorting and sort operations
- Gets the first search by predicate
- Returns the order clause for a given sort
- Render the query if possible
- Deletes all entities in the database
spring-data-jpa Key Features
spring-data-jpa Examples and Code Snippets
Trending Discussions on spring-data-jpa
Trending Discussions on spring-data-jpa
QUESTION
I use Spring-Data-JDBC (not JPA) and want to set the fetch-size.
I know that the the classic org.springframwork.jdbc.core.JdbcTemplate
has a setFetchSize(int)
method, but I have Spring-Data-JDBC repository:
org.springframework.data.repository.Repository;
org.springframework.data.jdbc.repository.query.Query;
/** This is a Spring Data JDBC (JDBC not JPA!). */
public interface UserDao extends Repository {
@Query(value = UserRowMapper.SELECT_BY_NAME_STATEMENT
rowMapperClass = UserRowMapper.class)
Optional findByName(String name);
}
and this is the relevant part of the configuration:
@Configuration
@EnableJdbcRepositories
public class AppConfigSpringDataJdbc extends AbstractJdbcConfiguration {
@Autowired
private DataSource dataSource;
@Bean
public NamedParameterJdbcTemplate namedParameterJdbcTemplate() {
return new NamedParameterJdbcTemplate(this.dataSource);
}
}
So my question is: How/Where to set the sql query fetch-size when using Spring-Data-JDBC, either by query or in general?
(The common solutions for Spring-Data-JPA will not work, because there is no persistence.xml
or javax.persistence.QueryHint
annotation because it is JDBC)
ANSWER
Answered 2022-Apr-15 at 14:09You can create NamedParameterJdbcTemplate
using custom JdbcTemplate
.
@Bean
JdbcOperations jdbcOperations(DataSource dataSource) {
final var jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.setFetchSize(100);
return jdbcTemplate;
}
@Bean
NamedParameterJdbcOperations namedParameterJdbcOperations(JdbcOperations operations) {
return new NamedParameterJdbcTemplate(operations);
}
QUESTION
I have configured Spring JPA to work with multiple data sources following this example. Spring JPA – Multiple Databases
It works as expected but since I want to use different data sources but with the same repositories there is an issue. When I try to use "Declarative Transaction Management" on my services and specify which transaction I am going to use the primary transaction or secondary one the transaction annotation is ignoring it. So in this case it is using the second one. However, both of the beans "PlatformTransactionManager" are created but when it comes to using in "@Transactional" I am not able to make the transaction work with the bean I have specified. So it seems that @Transactional is ignoring the bean name since they have the same repositories. Is there any way how can I use declarative transactions as I am trying to do it? As I have seen it can be done with Programmatic Transaction Management but it will cost me to change the whole code on my services since I have been using only declarative transactions.
ANSWER
Answered 2022-Mar-30 at 12:44In our case, we also have two databases, both using JPA and repositories. However, they do use different repositories, but I think our approach should also work in your case. We define an EntityManagerFactory
and a TransactionManager
per database. I cannot confirm this works, but I believe it should.
Primary Datasource:
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(
basePackages = {"ch.sac.data.primary.repository"},
entityManagerFactoryRef = "entityManagerFactory",
transactionManagerRef = "transactionManager")
public class ImporterPrimaryDataSourceConfiguration {
@Primary
@Bean(name = "dataSourceProperties")
@ConfigurationProperties("spring.datasource")
public DataSourceProperties dataSourceProperties() {
return new DataSourceProperties();
}
@Primary
@Bean(name = "primaryDataSource")
public DataSource dataSource(final DataSourceProperties dataSourceProperties) {
return dataSourceProperties
.initializeDataSourceBuilder()
.type(HikariDataSource.class)
.build();
}
@Primary
@Bean
public Flyway primaryFlyway(
final DataSource dataSource,
@Value("${spring.flyway.locations}") final String[] flywayLocations,
@Value("${spring.flyway.validate-on-migrate:true}")
final boolean flywayValidateOnMigrate) {
final var flyway =
Flyway.configure()
.dataSource(dataSource)
.locations(flywayLocations)
.validateOnMigrate(flywayValidateOnMigrate)
.load();
flyway.migrate();
return flyway;
}
@Primary
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(
final EntityManagerFactoryBuilder entityManagerFactoryBuilder,
final DataSource dataSource) {
final var jpaProperties =
Map.ofEntries(
Map.entry(
"hibernate.dialect",
"org.hibernate.spatial.dialect.postgis.PostgisDialect"));
return entityManagerFactoryBuilder
.dataSource(dataSource)
.packages("ch.sac.model.primary.entity")
.persistenceUnit("dataSource")
.properties(jpaProperties)
.build();
}
@Primary
@Bean
public PlatformTransactionManager transactionManager(
final EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
}
Secondary Datasource (SQLite Database, created in-memory, adjust to your use-case):
@Configuration
@EnableJpaRepositories(
basePackages = {"ch.sac.data.sqlite.repository"},
entityManagerFactoryRef = "sqliteEntityManagerFactory",
transactionManagerRef = "sqliteTransactionManager")
public class ImporterSQLiteDataSourceConfiguration {
@Bean(name = "sqliteDBFilePath")
public String sqliteDBFilePath() throws IOException {
return TempFileManager.createEmptyTempFile("metadata.sqlite").toString();
}
@Bean(name = "sqliteDataSourceProperties")
public DataSourceProperties sqliteDataSourceProperties() {
return new DataSourceProperties();
}
@Bean(name = "sqliteDataSource")
public DataSource sqliteDataSource(
@Qualifier("sqliteDataSourceProperties")
final DataSourceProperties sqliteDataSourceProperties,
final String sqliteDBFilePath) {
return sqliteDataSourceProperties
.initializeDataSourceBuilder()
.driverClassName("org.sqlite.JDBC")
.url("jdbc:sqlite:" + sqliteDBFilePath)
.type(HikariDataSource.class)
.build();
}
@Bean
public Flyway sqliteFlyway(
@Qualifier("sqliteDataSource") final DataSource sqliteDataSource,
@Value("${sqlite.flyway.locations}") final String[] flywayLocations) {
final var flyway =
Flyway.configure().dataSource(sqliteDataSource).locations(flywayLocations).load();
flyway.migrate();
return flyway;
}
@Bean(name = "sqliteEntityManagerFactory")
public LocalContainerEntityManagerFactoryBean sqliteEntityManagerFactory(
final EntityManagerFactoryBuilder sqliteEntityManagerFactoryBuilder,
@Qualifier("sqliteDataSource") final DataSource sqliteDataSource) {
final var sqliteJpaProperties =
Map.ofEntries(
Map.entry(
"hibernate.dialect", "org.sqlite.hibernate.dialect.SQLiteDialect"));
return sqliteEntityManagerFactoryBuilder
.dataSource(sqliteDataSource)
.packages("ch.sac.model.sqlite.entity")
.persistenceUnit("sqliteDataSource")
.properties(sqliteJpaProperties)
.build();
}
@Bean(name = "sqliteTransactionManager")
public PlatformTransactionManager sqliteTransactionManager(
@Qualifier("sqliteEntityManagerFactory")
final EntityManagerFactory sqliteEntityManagerFactory) {
return new JpaTransactionManager(sqliteEntityManagerFactory);
}
}
QUESTION
I have seen various post describing that JPA EntityGraph allows to choose the graph at run time. And I am not entirely clear what this refers to.
Out of good faith and respect I would like to take this helpful article for reference: https://www.baeldung.com/jpa-entity-graph. (Most of JPA users might have gone through it already.)
The article quotes -
EntityGraph allows grouping the related persistence fields which we want to retrieve and lets us choose the graph type at runtime.
and again solidifies above statement in conclusion section.
In this article, we've explored using the JPA Entity Graph to dynamically fetch an Entity and its associations.
The decision is made at runtime in which we choose to load or not the related association.
As we see in the article (5.1) - EntityGraphs are defined as below using Annotations-
5.1. Defining an Entity Graph with Annotations
@NamedEntityGraph(
name = "post-entity-graph",
attributeNodes = {
@NamedAttributeNode("subject"),
@NamedAttributeNode("user"),
@NamedAttributeNode("comments"),
}
)
@Entity
public class Post {
@OneToMany(mappedBy = "post")
private List comments = new ArrayList<>();
//...
}
The @NameEntityGraph annotation is defined at compile time and I don't see anything runtime or dynamic here.
But in 5.2 - entity graphs are defined using api or programmatically -
5.2. Defining an Entity Graph with the JPA API
EntityGraph entityGraph = entityManager.createEntityGraph(Post.class);
entityGraph.addAttributeNodes("subject");
entityGraph.addAttributeNodes("user");
In 5.2 approach, I see nodes can be chosen dynamically using some logic. So is this approach is what is refered to "dynamically fetch" and "runtime based". Or am i missing something and do i have more to understand.
Further the approaches given in 6. Using the Entity Graph
ex:
EntityGraph entityGraph = entityManager.getEntityGraph("post-entity-graph");
Map properties = new HashMap<>();
properties.put("javax.persistence.fetchgraph", entityGraph);
Post post = entityManager.find(Post.class, id, properties);
are all programmatic and so can be changed during runtime i.e they can be said as dynamic.
But one approach missed in above article, but mentioned here - https://www.baeldung.com/spring-data-jpa-named-entity-graphs, as below, does not seem to fit in to dynamic criteria.
public interface ItemRepository extends JpaRepository {
@EntityGraph(value = "Item.characteristics")
Item findByName(String name);
}
So does the dynamic approach just refer to 5.2 style or it implies even 5.1 style too.
ANSWER
Answered 2022-Feb-18 at 15:54In the Baeldung article, Section 5 is only about various ways to define a graph with not much emphasis on the dynamic/non-dynamic nature of the definition itself.
In Section 5.1 the definition of the graph is static but this section is only about demonstrating how to define a graph which then will be used in typical cases when building the graph dynamically is not really necessary. This section shows an alternative to the older way of building HQL / JPA-QL queries with JOIN FETCH sections.
@NamedEntityGraph(
name = "post-entity-graph",
attributeNodes = {
@NamedAttributeNode("subject"),
@NamedAttributeNode("user"),
@NamedAttributeNode("comments"),
}
)
@Entity
public class Post {
@OneToMany(mappedBy = "post")
private List comments = new ArrayList<>();
//...
}
Then, Section 6 tells you how to use the entity graphs defined earlier in various ways.
// Getting the "statically" defined graph (from annotation)
EntityGraph entityGraph = entityManager.getEntityGraph("post-entity-graph");
// Then using the graph
Map properties = new HashMap<>();
properties.put("javax.persistence.fetchgraph", entityGraph);
Post post = entityManager.find(Post.class, id, properties);
Naturally, you can swap this first line to the fully dynamically built graph demonstrated in Section 5.2:
// Building the graph dynamically
EntityGraph entityGraph = entityManager.createEntityGraph(Post.class);
entityGraph.addAttributeNodes("subject");
entityGraph.addAttributeNodes("user");
// Then using the graph
Map properties = new HashMap<>();
properties.put("javax.persistence.fetchgraph", entityGraph);
Post post = entityManager.find(Post.class, id, properties);
In both cases you supply an EntityGraph object to the query.
QUESTION
In my application config i have defined the following properties:
logging.file.name = application.logs
When i run my application it's creating two files application.logs.0
and application.logs.0.lck
and the content of file as follow
2022-02-16T12:55:05.656986Z
1645016105656
986000
0
org.apache.catalina.core.StandardService
INFO
org.apache.catalina.core.StandardService
startInternal
1
Starting service [Tomcat]
2022-02-16T12:55:05.671696Z
1645016105671
696000
1
org.apache.catalina.core.StandardEngine
INFO
org.apache.catalina.core.StandardEngine
startInternal
1
Starting Servlet engine: [Apache Tomcat/9.0.48]
It's not properly printing logs and don't want to output in the xml format
My Dependency Tree:
[INFO] com.walmart.uss:trigger:jar:0.0.1-SNAPSHOT
[INFO] +- com.google.cloud:google-cloud-logging:jar:3.0.0:compile
[INFO] | +- com.google.guava:guava:jar:31.0.1-jre:compile
[INFO] | +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] | +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] | +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] | +- org.checkerframework:checker-qual:jar:3.8.0:compile
[INFO] | +- com.google.errorprone:error_prone_annotations:jar:2.8.1:compile
[INFO] | +- com.google.j2objc:j2objc-annotations:jar:1.3:compile
[INFO] | +- io.grpc:grpc-api:jar:1.41.0:compile
[INFO] | +- io.grpc:grpc-context:jar:1.41.0:compile
[INFO] | +- io.grpc:grpc-stub:jar:1.41.0:compile
[INFO] | +- io.grpc:grpc-protobuf:jar:1.41.0:compile
[INFO] | +- io.grpc:grpc-protobuf-lite:jar:1.41.0:compile
[INFO] | +- com.google.api:api-common:jar:2.0.5:compile
[INFO] | +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
[INFO] | +- com.google.auto.value:auto-value-annotations:jar:1.8.2:compile
[INFO] | +- com.google.protobuf:protobuf-java:jar:3.18.1:compile
[INFO] | +- com.google.protobuf:protobuf-java-util:jar:3.18.1:compile
[INFO] | +- com.google.code.gson:gson:jar:2.8.7:compile
[INFO] | +- com.google.api.grpc:proto-google-common-protos:jar:2.6.0:compile
[INFO] | +- com.google.api.grpc:proto-google-cloud-logging-v2:jar:0.92.0:compile
[INFO] | +- com.google.api:gax:jar:2.6.1:compile
[INFO] | +- io.opencensus:opencensus-api:jar:0.28.0:compile
[INFO] | +- com.google.api:gax-grpc:jar:2.6.1:compile
[INFO] | +- io.grpc:grpc-auth:jar:1.41.0:compile
[INFO] | +- com.google.auth:google-auth-library-credentials:jar:1.2.1:compile
[INFO] | +- io.grpc:grpc-netty-shaded:jar:1.41.0:compile
[INFO] | +- io.grpc:grpc-alts:jar:1.41.0:compile
[INFO] | +- io.grpc:grpc-grpclb:jar:1.41.0:compile
[INFO] | +- org.conscrypt:conscrypt-openjdk-uber:jar:2.5.1:compile
[INFO] | +- org.threeten:threetenbp:jar:1.5.1:compile
[INFO] | +- com.google.cloud:google-cloud-core-grpc:jar:2.2.0:compile
[INFO] | +- com.google.auth:google-auth-library-oauth2-http:jar:1.2.1:compile
[INFO] | +- com.google.http-client:google-http-client-gson:jar:1.40.1:compile
[INFO] | +- com.google.http-client:google-http-client:jar:1.40.1:compile
[INFO] | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | +- commons-codec:commons-codec:jar:1.15:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.14:compile
[INFO] | +- io.opencensus:opencensus-contrib-http-util:jar:0.28.0:compile
[INFO] | +- io.grpc:grpc-core:jar:1.41.0:compile
[INFO] | +- com.google.android:annotations:jar:4.1.1.4:runtime
[INFO] | +- org.codehaus.mojo:animal-sniffer-annotations:jar:1.20:runtime
[INFO] | +- io.perfmark:perfmark-api:jar:0.23.0:runtime
[INFO] | +- com.google.cloud:google-cloud-core:jar:2.2.0:compile
[INFO] | \- com.google.api.grpc:proto-google-iam-v1:jar:1.1.6:compile
[INFO] +- org.springframework.boot:spring-boot-starter:jar:2.5.2:compile
[INFO] | +- org.springframework.boot:spring-boot:jar:2.5.2:compile
[INFO] | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.5.2:compile
[INFO] | +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
[INFO] | +- org.springframework:spring-core:jar:5.3.8:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.3.8:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.28:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.5.2:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.5.2:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.5.2:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.5.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.4.7:compile
[INFO] | | \- net.minidev:accessors-smart:jar:2.4.7:compile
[INFO] | +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] | | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] | +- org.assertj:assertj-core:jar:3.19.0:test
[INFO] | +- org.hamcrest:hamcrest:jar:2.2:test
[INFO] | +- org.junit.jupiter:junit-jupiter:jar:5.7.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-api:jar:5.7.2:test
[INFO] | | | +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] | | | +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] | | | \- org.junit.platform:junit-platform-commons:jar:1.7.2:test
[INFO] | | +- org.junit.jupiter:junit-jupiter-params:jar:5.7.2:test
[INFO] | | \- org.junit.jupiter:junit-jupiter-engine:jar:5.7.2:test
[INFO] | | \- org.junit.platform:junit-platform-engine:jar:1.7.2:test
[INFO] | +- org.mockito:mockito-core:jar:3.9.0:test
[INFO] | | +- net.bytebuddy:byte-buddy:jar:1.10.22:compile
[INFO] | | +- net.bytebuddy:byte-buddy-agent:jar:1.10.22:test
[INFO] | | \- org.objenesis:objenesis:jar:3.2:compile
[INFO] | +- org.mockito:mockito-junit-jupiter:jar:3.9.0:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-test:jar:5.3.8:test
[INFO] | \- org.xmlunit:xmlunit-core:jar:2.8.2:test
[INFO] +- org.springframework.boot:spring-boot-starter-thymeleaf:jar:2.5.2:compile
[INFO] | +- org.thymeleaf:thymeleaf-spring5:jar:3.0.12.RELEASE:compile
[INFO] | | \- org.thymeleaf:thymeleaf:jar:3.0.12.RELEASE:compile
[INFO] | | +- org.attoparser:attoparser:jar:2.0.5.RELEASE:compile
[INFO] | | \- org.unbescape:unbescape:jar:1.1.6.RELEASE:compile
[INFO] | \- org.thymeleaf.extras:thymeleaf-extras-java8time:jar:3.0.4.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:5.3.8:compile
[INFO] | +- org.springframework:spring-aop:jar:5.3.8:compile
[INFO] | +- org.springframework:spring-beans:jar:5.3.8:compile
[INFO] | +- org.springframework:spring-context:jar:5.3.8:compile
[INFO] | +- org.springframework:spring-expression:jar:5.3.8:compile
[INFO] | \- org.springframework:spring-web:jar:5.3.8:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.5.2:compile
[INFO] | +- org.springframework.security:spring-security-config:jar:5.5.1:compile
[INFO] | | \- org.springframework.security:spring-security-core:jar:5.5.1:compile
[INFO] | | \- org.springframework.security:spring-security-crypto:jar:5.5.1:compile
[INFO] | \- org.springframework.security:spring-security-web:jar:5.5.1:compile
[INFO] +- org.springframework.data:spring-data-jpa:jar:2.5.2:compile
[INFO] | +- org.springframework.data:spring-data-commons:jar:2.5.2:compile
[INFO] | +- org.springframework:spring-orm:jar:5.3.8:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:5.3.8:compile
[INFO] | +- org.springframework:spring-tx:jar:5.3.8:compile
[INFO] | +- org.aspectj:aspectjrt:jar:1.9.6:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.31:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.5.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:2.5.2:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.9.6:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.5.2:compile
[INFO] | | \- com.zaxxer:HikariCP:jar:4.0.3:compile
[INFO] | +- jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile
[INFO] | +- jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile
[INFO] | +- org.hibernate:hibernate-core:jar:5.4.32.Final:compile
[INFO] | | +- org.jboss.logging:jboss-logging:jar:3.4.2.Final:compile
[INFO] | | +- org.javassist:javassist:jar:3.27.0-GA:compile
[INFO] | | +- antlr:antlr:jar:2.7.7:compile
[INFO] | | +- org.jboss:jandex:jar:2.2.3.Final:compile
[INFO] | | +- com.fasterxml:classmate:jar:1.5.1:compile
[INFO] | | +- org.dom4j:dom4j:jar:2.1.3:compile
[INFO] | | +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:compile
[INFO] | | \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.4:compile
[INFO] | | +- org.glassfish.jaxb:txw2:jar:2.3.4:compile
[INFO] | | +- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile
[INFO] | | \- com.sun.activation:jakarta.activation:jar:1.2.2:runtime
[INFO] | \- org.springframework:spring-aspects:jar:5.3.8:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.12:provided
[INFO] +- com.h2database:h2:jar:1.4.190:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.5.2:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.5.2:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.12.3:compile
[INFO] | | +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.12.3:compile
[INFO] | | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.12.3:compile
[INFO] | \- org.springframework.boot:spring-boot-starter-tomcat:jar:2.5.2:compile
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.48:compile
[INFO] | +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.48:compile
[INFO] | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.48:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.5.12:compile
[INFO] +- org.springframework.integration:spring-integration-core:jar:5.5.3:compile
[INFO] | +- org.springframework:spring-messaging:jar:5.3.8:compile
[INFO] | +- org.springframework.retry:spring-retry:jar:1.3.1:compile
[INFO] | \- io.projectreactor:reactor-core:jar:3.4.7:compile
[INFO] | \- org.reactivestreams:reactive-streams:jar:1.0.3:compile
[INFO] +- org.apache.commons:commons-text:jar:1.9:compile
[INFO] | \- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.12.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.12.3:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.5.2:compile
[INFO] | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.5.2:compile
[INFO] | | \- org.springframework.boot:spring-boot-actuator:jar:2.5.2:compile
[INFO] | \- io.micrometer:micrometer-core:jar:1.7.1:compile
[INFO] | +- org.hdrhistogram:HdrHistogram:jar:2.1.12:compile
[INFO] | \- org.latencyutils:LatencyUtils:jar:2.0.3:runtime
[INFO] +- org.apache.maven.plugins:maven-compiler-plugin:jar:3.8.1:compile
[INFO] | +- org.apache.maven:maven-plugin-api:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-model:jar:3.0:compile
[INFO] | | \- org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile
[INFO] | | \- org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile
[INFO] | | \- org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile
[INFO] | +- org.apache.maven:maven-artifact:jar:3.0:compile
[INFO] | | \- org.codehaus.plexus:plexus-utils:jar:2.0.4:compile
[INFO] | +- org.apache.maven:maven-core:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-settings:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-settings-builder:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-repository-metadata:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-model-builder:jar:3.0:compile
[INFO] | | +- org.apache.maven:maven-aether-provider:jar:3.0:runtime
[INFO] | | +- org.sonatype.aether:aether-impl:jar:1.7:compile
[INFO] | | | \- org.sonatype.aether:aether-spi:jar:1.7:compile
[INFO] | | +- org.sonatype.aether:aether-api:jar:1.7:compile
[INFO] | | +- org.sonatype.aether:aether-util:jar:1.7:compile
[INFO] | | +- org.codehaus.plexus:plexus-interpolation:jar:1.14:compile
[INFO] | | +- org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile
[INFO] | | +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile
[INFO] | | \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] | | \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] | +- org.apache.maven.shared:maven-shared-utils:jar:3.2.1:compile
[INFO] | | \- commons-io:commons-io:jar:2.5:compile
[INFO] | +- org.apache.maven.shared:maven-shared-incremental:jar:1.1:compile
[INFO] | +- org.codehaus.plexus:plexus-java:jar:0.9.10:compile
[INFO] | | +- org.ow2.asm:asm:jar:6.2:compile
[INFO] | | \- com.thoughtworks.qdox:qdox:jar:2.0-M8:compile
[INFO] | +- org.codehaus.plexus:plexus-compiler-api:jar:2.8.4:compile
[INFO] | +- org.codehaus.plexus:plexus-compiler-manager:jar:2.8.4:compile
[INFO] | \- org.codehaus.plexus:plexus-compiler-javac:jar:2.8.4:runtime
[INFO] +- org.postgresql:postgresql:jar:42.2.23:compile
[INFO] +- junit:junit:jar:4.12:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:2.2:test
[INFO] +- org.springframework.boot:spring-boot-loader:jar:2.5.6:compile
[INFO] +- com.google.cloud:google-cloud-dataproc:jar:2.2.2:compile
[INFO] | \- com.google.api.grpc:proto-google-cloud-dataproc-v1:jar:2.2.2:compile
[INFO] +- mysql:mysql-connector-java:jar:8.0.25:compile
[INFO] +- com.google.cloud:google-cloud-bigquery:jar:2.3.3:compile
[INFO] | +- com.google.cloud:google-cloud-core-http:jar:2.2.0:compile
[INFO] | +- com.google.api-client:google-api-client:jar:1.32.2:compile
[INFO] | +- com.google.oauth-client:google-oauth-client:jar:1.32.1:compile
[INFO] | +- com.google.http-client:google-http-client-apache-v2:jar:1.40.1:compile
[INFO] | +- com.google.http-client:google-http-client-appengine:jar:1.40.1:compile
[INFO] | +- com.google.api:gax-httpjson:jar:0.91.1:compile
[INFO] | +- com.google.http-client:google-http-client-jackson2:jar:1.40.1:compile
[INFO] | +- org.checkerframework:checker-compat-qual:jar:2.5.5:compile
[INFO] | \- com.google.apis:google-api-services-bigquery:jar:v2-rev20211017-1.32.1:compile
[INFO] +- org.apache.spark:spark-core_2.12:jar:3.1.0:compile
[INFO] | +- com.thoughtworks.paranamer:paranamer:jar:2.8:compile
[INFO] | +- org.apache.avro:avro:jar:1.8.2:compile
[INFO] | | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | | +- org.apache.commons:commons-compress:jar:1.8.1:compile
[INFO] | | \- org.tukaani:xz:jar:1.5:compile
[INFO] | +- org.apache.avro:avro-mapred:jar:hadoop2:1.8.2:compile
[INFO] | | \- org.apache.avro:avro-ipc:jar:1.8.2:compile
[INFO] | +- com.twitter:chill_2.12:jar:0.9.5:compile
[INFO] | | \- com.esotericsoftware:kryo-shaded:jar:4.0.2:compile
[INFO] | | \- com.esotericsoftware:minlog:jar:1.3.0:compile
[INFO] | +- com.twitter:chill-java:jar:0.9.5:compile
[INFO] | +- org.apache.xbean:xbean-asm7-shaded:jar:4.15:compile
[INFO] | +- org.apache.hadoop:hadoop-client:jar:3.2.0:compile
[INFO] | | +- org.apache.hadoop:hadoop-common:jar:3.2.0:compile
[INFO] | | | +- commons-cli:commons-cli:jar:1.2:compile
[INFO] | | | +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | | | +- org.eclipse.jetty:jetty-servlet:jar:9.4.42.v20210604:compile
[INFO] | | | | +- org.eclipse.jetty:jetty-security:jar:9.4.42.v20210604:compile
[INFO] | | | | \- org.eclipse.jetty:jetty-util-ajax:jar:9.4.42.v20210604:compile
[INFO] | | | +- javax.servlet.jsp:jsp-api:jar:2.1:runtime
[INFO] | | | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] | | | +- org.apache.commons:commons-configuration2:jar:2.1.1:compile
[INFO] | | | +- com.google.re2j:re2j:jar:1.1:compile
[INFO] | | | +- org.apache.hadoop:hadoop-auth:jar:3.2.0:compile
[INFO] | | | | \- com.nimbusds:nimbus-jose-jwt:jar:9.10:compile
[INFO] | | | | \- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[INFO] | | | +- org.apache.curator:curator-client:jar:2.12.0:compile
[INFO] | | | +- org.apache.htrace:htrace-core4:jar:4.1.0-incubating:compile
[INFO] | | | +- org.apache.kerby:kerb-simplekdc:jar:1.0.1:compile
[INFO] | | | | +- org.apache.kerby:kerb-client:jar:1.0.1:compile
[INFO] | | | | | +- org.apache.kerby:kerby-config:jar:1.0.1:compile
[INFO] | | | | | +- org.apache.kerby:kerb-core:jar:1.0.1:compile
[INFO] | | | | | | \- org.apache.kerby:kerby-pkix:jar:1.0.1:compile
[INFO] | | | | | | +- org.apache.kerby:kerby-asn1:jar:1.0.1:compile
[INFO] | | | | | | \- org.apache.kerby:kerby-util:jar:1.0.1:compile
[INFO] | | | | | +- org.apache.kerby:kerb-common:jar:1.0.1:compile
[INFO] | | | | | | \- org.apache.kerby:kerb-crypto:jar:1.0.1:compile
[INFO] | | | | | +- org.apache.kerby:kerb-util:jar:1.0.1:compile
[INFO] | | | | | \- org.apache.kerby:token-provider:jar:1.0.1:compile
[INFO] | | | | \- org.apache.kerby:kerb-admin:jar:1.0.1:compile
[INFO] | | | | +- org.apache.kerby:kerb-server:jar:1.0.1:compile
[INFO] | | | | | \- org.apache.kerby:kerb-identity:jar:1.0.1:compile
[INFO] | | | | \- org.apache.kerby:kerby-xdr:jar:1.0.1:compile
[INFO] | | | +- org.codehaus.woodstox:stax2-api:jar:3.1.4:compile
[INFO] | | | +- com.fasterxml.woodstox:woodstox-core:jar:5.0.3:compile
[INFO] | | | \- dnsjava:dnsjava:jar:2.1.7:compile
[INFO] | | +- org.apache.hadoop:hadoop-hdfs-client:jar:3.2.0:compile
[INFO] | | | \- com.squareup.okhttp:okhttp:jar:2.7.5:compile
[INFO] | | | \- com.squareup.okio:okio:jar:1.6.0:compile
[INFO] | | +- org.apache.hadoop:hadoop-yarn-api:jar:3.2.0:compile
[INFO] | | | \- javax.xml.bind:jaxb-api:jar:2.3.1:compile
[INFO] | | | \- javax.activation:javax.activation-api:jar:1.2.0:compile
[INFO] | | +- org.apache.hadoop:hadoop-yarn-client:jar:3.2.0:compile
[INFO] | | +- org.apache.hadoop:hadoop-mapreduce-client-core:jar:3.2.0:compile
[INFO] | | | \- org.apache.hadoop:hadoop-yarn-common:jar:3.2.0:compile
[INFO] | | | +- javax.servlet:javax.servlet-api:jar:4.0.1:compile
[INFO] | | | +- org.eclipse.jetty:jetty-util:jar:9.4.42.v20210604:compile
[INFO] | | | +- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.12.3:compile
[INFO] | | | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.12.3:compile
[INFO] | | | \- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.12.3:compile
[INFO] | | +- org.apache.hadoop:hadoop-mapreduce-client-jobclient:jar:3.2.0:compile
[INFO] | | | \- org.apache.hadoop:hadoop-mapreduce-client-common:jar:3.2.0:compile
[INFO] | | \- org.apache.hadoop:hadoop-annotations:jar:3.2.0:compile
[INFO] | +- org.apache.spark:spark-launcher_2.12:jar:3.1.0:compile
[INFO] | +- org.apache.spark:spark-kvstore_2.12:jar:3.1.0:compile
[INFO] | | \- org.fusesource.leveldbjni:leveldbjni-all:jar:1.8:compile
[INFO] | +- org.apache.spark:spark-network-common_2.12:jar:3.1.0:compile
[INFO] | +- org.apache.spark:spark-network-shuffle_2.12:jar:3.1.0:compile
[INFO] | +- org.apache.spark:spark-unsafe_2.12:jar:3.1.0:compile
[INFO] | +- javax.activation:activation:jar:1.1.1:compile
[INFO] | +- org.apache.curator:curator-recipes:jar:2.13.0:compile
[INFO] | | \- org.apache.curator:curator-framework:jar:2.13.0:compile
[INFO] | +- org.apache.zookeeper:zookeeper:jar:3.4.14:compile
[INFO] | | \- org.apache.yetus:audience-annotations:jar:0.5.0:compile
[INFO] | +- jakarta.servlet:jakarta.servlet-api:jar:4.0.4:compile
[INFO] | +- org.apache.commons:commons-math3:jar:3.4.1:compile
[INFO] | +- org.slf4j:jul-to-slf4j:jar:1.7.31:compile
[INFO] | +- org.slf4j:jcl-over-slf4j:jar:1.7.31:compile
[INFO] | +- com.ning:compress-lzf:jar:1.0.3:compile
[INFO] | +- org.xerial.snappy:snappy-java:jar:1.1.8.2:compile
[INFO] | +- org.lz4:lz4-java:jar:1.7.1:compile
[INFO] | +- com.github.luben:zstd-jni:jar:1.4.8-1:compile
[INFO] | +- org.roaringbitmap:RoaringBitmap:jar:0.9.0:compile
[INFO] | | \- org.roaringbitmap:shims:jar:0.9.0:runtime
[INFO] | +- commons-net:commons-net:jar:3.1:compile
[INFO] | +- org.scala-lang.modules:scala-xml_2.12:jar:1.2.0:compile
[INFO] | +- org.scala-lang:scala-library:jar:2.12.10:compile
[INFO] | +- org.scala-lang:scala-reflect:jar:2.12.10:compile
[INFO] | +- org.json4s:json4s-jackson_2.12:jar:3.7.0-M5:compile
[INFO] | | \- org.json4s:json4s-core_2.12:jar:3.7.0-M5:compile
[INFO] | | +- org.json4s:json4s-ast_2.12:jar:3.7.0-M5:compile
[INFO] | | \- org.json4s:json4s-scalap_2.12:jar:3.7.0-M5:compile
[INFO] | +- org.glassfish.jersey.core:jersey-client:jar:2.33:compile
[INFO] | | +- jakarta.ws.rs:jakarta.ws.rs-api:jar:2.1.6:compile
[INFO] | | \- org.glassfish.hk2.external:jakarta.inject:jar:2.6.1:compile
[INFO] | +- org.glassfish.jersey.core:jersey-common:jar:2.33:compile
[INFO] | | \- org.glassfish.hk2:osgi-resource-locator:jar:1.0.3:compile
[INFO] | +- org.glassfish.jersey.core:jersey-server:jar:2.33:compile
[INFO] | | \- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
[INFO] | +- org.glassfish.jersey.containers:jersey-container-servlet:jar:2.33:compile
[INFO] | +- org.glassfish.jersey.containers:jersey-container-servlet-core:jar:2.33:compile
[INFO] | +- org.glassfish.jersey.inject:jersey-hk2:jar:2.33:compile
[INFO] | | \- org.glassfish.hk2:hk2-locator:jar:2.6.1:compile
[INFO] | | +- org.glassfish.hk2.external:aopalliance-repackaged:jar:2.6.1:compile
[INFO] | | +- org.glassfish.hk2:hk2-api:jar:2.6.1:compile
[INFO] | | \- org.glassfish.hk2:hk2-utils:jar:2.6.1:compile
[INFO] | +- io.netty:netty-all:jar:4.1.65.Final:compile
[INFO] | +- com.clearspring.analytics:stream:jar:2.9.6:compile
[INFO] | +- io.dropwizard.metrics:metrics-core:jar:4.1.24:compile
[INFO] | +- io.dropwizard.metrics:metrics-jvm:jar:4.1.24:compile
[INFO] | +- io.dropwizard.metrics:metrics-json:jar:4.1.24:compile
[INFO] | +- io.dropwizard.metrics:metrics-graphite:jar:4.1.24:compile
[INFO] | +- io.dropwizard.metrics:metrics-jmx:jar:4.1.24:compile
[INFO] | +- com.fasterxml.jackson.module:jackson-module-scala_2.12:jar:2.12.3:compile
[INFO] | +- org.apache.ivy:ivy:jar:2.4.0:compile
[INFO] | +- oro:oro:jar:2.0.8:compile
[INFO] | +- net.razorvine:pyrolite:jar:4.30:compile
[INFO] | +- net.sf.py4j:py4j:jar:0.10.9:compile
[INFO] | +- org.apache.spark:spark-tags_2.12:jar:3.1.0:compile
[INFO] | +- org.apache.commons:commons-crypto:jar:1.1.0:compile
[INFO] | \- org.spark-project.spark:unused:jar:1.0.0:compile
[INFO] +- org.apache.spark:spark-streaming_2.12:jar:3.1.0:compile
[INFO] +- org.apache.spark:spark-streaming-kafka-0-10_2.12:jar:3.1.0:compile
[INFO] | +- org.apache.spark:spark-token-provider-kafka-0-10_2.12:jar:3.1.0:compile
[INFO] | \- org.apache.kafka:kafka-clients:jar:2.7.1:compile
[INFO] +- org.apache.spark:spark-avro_2.12:jar:3.1.0:compile
[INFO] +- org.apache.spark:spark-sql-kafka-0-10_2.12:jar:3.1.0:compile
[INFO] | \- org.apache.commons:commons-pool2:jar:2.9.0:compile
[INFO] +- org.codehaus.janino:janino:jar:3.0.8:compile
[INFO] +- org.codehaus.janino:commons-compiler:jar:3.0.8:compile
[INFO] +- org.apache.spark:spark-sql_2.12:jar:3.1.0:compile
[INFO] | +- com.univocity:univocity-parsers:jar:2.9.0:compile
[INFO] | +- org.apache.spark:spark-sketch_2.12:jar:3.1.0:compile
[INFO] | +- org.apache.spark:spark-catalyst_2.12:jar:3.1.0:compile
[INFO] | | +- org.scala-lang.modules:scala-parser-combinators_2.12:jar:1.1.2:compile
[INFO] | | +- org.antlr:antlr4-runtime:jar:4.8-1:compile
[INFO] | | +- org.apache.arrow:arrow-vector:jar:2.0.0:compile
[INFO] | | | +- org.apache.arrow:arrow-format:jar:2.0.0:compile
[INFO] | | | +- org.apache.arrow:arrow-memory-core:jar:2.0.0:compile
[INFO] | | | \- com.google.flatbuffers:flatbuffers-java:jar:1.9.0:compile
[INFO] | | \- org.apache.arrow:arrow-memory-netty:jar:2.0.0:compile
[INFO] | +- org.apache.orc:orc-core:jar:1.5.12:compile
[INFO] | | +- org.apache.orc:orc-shims:jar:1.5.12:compile
[INFO] | | +- commons-lang:commons-lang:jar:2.6:compile
[INFO] | | +- io.airlift:aircompressor:jar:0.10:compile
[INFO] | | \- org.threeten:threeten-extra:jar:1.5.0:compile
[INFO] | +- org.apache.orc:orc-mapreduce:jar:1.5.12:compile
[INFO] | +- org.apache.hive:hive-storage-api:jar:2.7.2:compile
[INFO] | +- org.apache.parquet:parquet-column:jar:1.10.1:compile
[INFO] | | +- org.apache.parquet:parquet-common:jar:1.10.1:compile
[INFO] | | \- org.apache.parquet:parquet-encoding:jar:1.10.1:compile
[INFO] | \- org.apache.parquet:parquet-hadoop:jar:1.10.1:compile
[INFO] | +- org.apache.parquet:parquet-format:jar:2.4.0:compile
[INFO] | \- org.apache.parquet:parquet-jackson:jar:1.10.1:compile
[INFO] +- org.springframework.kafka:spring-kafka:jar:2.8.2:compile
[INFO] +- com.google.cloud:google-cloud-storage:jar:2.1.9:compile
[INFO] | \- com.google.apis:google-api-services-storage:jar:v1-rev20210918-1.32.1:compile
[INFO] \- za.co.absa:abris_2.12:jar:6.0.0:compile
[INFO] +- io.confluent:kafka-avro-serializer:jar:6.2.1:compile
[INFO] | +- io.confluent:kafka-schema-serializer:jar:6.2.1:compile
[INFO] | \- io.confluent:common-utils:jar:6.2.1:compile
[INFO] +- io.confluent:kafka-schema-registry-client:jar:6.2.1:compile
[INFO] | +- io.swagger:swagger-annotations:jar:1.6.2:compile
[INFO] | \- io.swagger:swagger-core:jar:1.6.2:compile
[INFO] | +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.12.3:compile
[INFO] | \- io.swagger:swagger-models:jar:1.6.2:compile
[INFO] \- za.co.absa.commons:commons_2.12:jar:1.0.0:compile
My Spark Integration with Spring boot is causing the issue, i am not able to dependency which is causing it
ANSWER
Answered 2022-Feb-16 at 13:12Acording to this answer: https://stackoverflow.com/a/51236918/16651073 tomcat falls back to default logging if it can resolve the location
Can you try to save the properties without the spaces.
Like this: logging.file.name=application.logs
QUESTION
Calling mvn clean compile -X
shows the following (few dependencies omitted to stay in question max char size):
[DEBUG] (f) compileSourceRoots = [/Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/src/main/java]
[DEBUG] (f) compilerId = javac
[DEBUG] (f) debug = true
[DEBUG] (f) encoding = UTF-8
[DEBUG] (f) failOnError = true
[DEBUG] (f) failOnWarning = false
[DEBUG] (f) forceJavacCompilerUse = false
[DEBUG] (f) fork = false
[DEBUG] (f) generatedSourcesDirectory = /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/target/generated-sources/annotations
[DEBUG] (f) mojoExecution = org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile {execution: default-compile}
[DEBUG] (f) optimize = false
[DEBUG] (f) outputDirectory = /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/target/classes
[DEBUG] (f) parameters = false
[DEBUG] (f) project = MavenProject: it.u1.u2:stockapp:1.2.2-SNAPSHOT @ /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/pom.xml
[DEBUG] (f) projectArtifact = it.u1.u2:stockapp:jar:1.2.2-SNAPSHOT
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@633a2e99
[DEBUG] (f) showDeprecation = false
[DEBUG] (f) showWarnings = false
[DEBUG] (f) skipMultiThreadWarning = false
[DEBUG] (f) source = 11
[DEBUG] (f) staleMillis = 0
[DEBUG] (s) target = 11
[DEBUG] (f) useIncrementalCompilation = true
[DEBUG] (f) verbose = false
[DEBUG] -- end configuration --
[DEBUG] Using compiler 'javac'.
and also
[DEBUG] Command line options:
[DEBUG] -d /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/target/classes -classpath /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/target/classes:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.6.2/spring-boot-starter-web-2.6.2.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter/2.6.2/spring-boot-starter-2.6.2.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot/2.6.2/spring-boot-2.6.2.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.6.2/spring-boot-autoconfigure-2.6.2.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.6.2/spring-boot-starter-logging-2.6.2.jar:/Users/u/.m2/repository/ch/qos/logback/logback-classic/1.2.9/logback-classic-1.2.9.jar:/Users/u/.m2/repository/ch/qos/logback/logback-core/1.2.9/logback-core-1.2.9.jar:/Users/u/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.17.0/log4j-to-slf4j-2.17.0.jar:/Users/u/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.0/log4j-api-2.17.0.jar:/Users/u/.m2/repository/org/slf4j/jul-to-slf4j/1.7.32/jul-to-slf4j-1.7.32.jar:/Users/u/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/u/.m2/repository/org/yaml/snakeyaml/1.29/snakeyaml-1.29.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.6.2/spring-boot-starter-json-2.6.2.jar:/Users/u/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.13.1/jackson-datatype-jdk8-2.13.1.jar:/Users/u/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.1/jackson-datatype-jsr310-2.13.1.jar:/Users/u/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.13.1/jackson-module-parameter-names-2.13.1.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.6.2/spring-boot-starter-tomcat-2.6.2.jar:/Users/u/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.56/tomcat-embed-core-9.0.56.jar:/Users/u/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.56/tomcat-embed-websocket-9.0.56.jar:/Users/u/.m2/repository/org/springframework/spring-web/5.3.14/spring-web-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-beans/5.3.14/spring-beans-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-webmvc/5.3.14/spring-webmvc-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-context/5.3.14/spring-context-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-expression/5.3.14/spring-expression-5.3.14.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-security/2.6.2/spring-boot-starter-security-2.6.2.jar:/Users/u/.m2/repository/org/springframework/spring-aop/5.3.14/spring-aop-5.3.14.jar:/Users/u/.m2/repository/org/springframework/security/spring-security-config/5.6.1/spring-security-config-5.6.1.jar:/Users/u/.m2/repository/org/springframework/security/spring-security-core/5.6.1/spring-security-core-5.6.1.jar:/Users/u/.m2/repository/org/springframework/security/spring-security-crypto/5.6.1/spring-security-crypto-5.6.1.jar:/Users/u/.m2/repository/org/springframework/security/spring-security-web/5.6.1/spring-security-web-5.6.1.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/2.6.2/spring-boot-starter-data-jpa-2.6.2.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.6.2/spring-boot-starter-aop-2.6.2.jar:/Users/u/.m2/repository/org/aspectj/aspectjweaver/1.9.7/aspectjweaver-1.9.7.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.6.2/spring-boot-starter-jdbc-2.6.2.jar:/Users/u/.m2/repository/com/zaxxer/HikariCP/4.0.3/HikariCP-4.0.3.jar:/Users/u/.m2/repository/org/springframework/spring-jdbc/5.3.14/spring-jdbc-5.3.14.jar:/Users/u/.m2/repository/org/springframework/data/spring-data-jpa/2.6.0/spring-data-jpa-2.6.0.jar:/Users/u/.m2/repository/org/springframework/data/spring-data-commons/2.6.0/spring-data-commons-2.6.0.jar:/Users/u/.m2/repository/org/springframework/spring-orm/5.3.14/spring-orm-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-tx/5.3.14/spring-tx-5.3.14.jar:/Users/u/.m2/repository/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar:/Users/u/.m2/repository/org/springframework/spring-aspects/5.3.14/spring-aspects-5.3.14.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-validation/2.6.2/spring-boot-starter-validation-2.6.2.jar:/Users/u/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.56/tomcat-embed-el-9.0.56.jar:/Users/u/.m2/repository/org/hibernate/validator/hibernate-validator/6.2.0.Final/hibernate-validator-6.2.0.Final.jar:/Users/u/.m2/repository/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.jar:/Users/u/.m2/repository/org/liquibase/liquibase-core/4.5.0/liquibase-core-4.5.0.jar:/Users/u/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar:/Users/u/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar:/Users/u/.m2/repository/com/fasterxml/jackson/module/jackson-module-jaxb-annotations/2.13.1/jackson-module-jaxb-annotations-2.13.1.jar:/Users/u/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.1/jackson-annotations-2.13.1.jar:/Users/u/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.1/jackson-core-2.13.1.jar:/Users/u/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.1/jackson-databind-2.13.1.jar:/Users/u/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar:/Users/u/.m2/repository/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar:/Users/u/.m2/repository/org/springframework/spring-core/5.3.14/spring-core-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-jcl/5.3.14/spring-jcl-5.3.14.jar:/Users/u/.m2/repository/org/projectlombok/lombok/1.18.22/lombok-1.18.22.jar:/Users/u/.m2/repository/org/mapstruct/mapstruct-processor/1.3.1.Final/mapstruct-processor-1.3.1.Final.jar:/Users/u/.m2/repository/org/mapstruct/mapstruct/1.3.1.Final/mapstruct-1.3.1.Final.jar: -sourcepath /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/src/main/java:/Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/target/generated-sources/annotations: -s /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/target/generated-sources/annotations -g -nowarn -target 11 -source 11 -encoding UTF-8
So I was under the impression that Maven makes this call using javac:
javac -d /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/target/classes -classpath /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/target/classes:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-web/2.6.2/spring-boot-starter-web-2.6.2.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter/2.6.2/spring-boot-starter-2.6.2.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot/2.6.2/spring-boot-2.6.2.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/2.6.2/spring-boot-autoconfigure-2.6.2.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-logging/2.6.2/spring-boot-starter-logging-2.6.2.jar:/Users/u/.m2/repository/ch/qos/logback/logback-classic/1.2.9/logback-classic-1.2.9.jar:/Users/u/.m2/repository/ch/qos/logback/logback-core/1.2.9/logback-core-1.2.9.jar:/Users/u/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.17.0/log4j-to-slf4j-2.17.0.jar:/Users/u/.m2/repository/org/apache/logging/log4j/log4j-api/2.17.0/log4j-api-2.17.0.jar:/Users/u/.m2/repository/org/slf4j/jul-to-slf4j/1.7.32/jul-to-slf4j-1.7.32.jar:/Users/u/.m2/repository/jakarta/annotation/jakarta.annotation-api/1.3.5/jakarta.annotation-api-1.3.5.jar:/Users/u/.m2/repository/org/yaml/snakeyaml/1.29/snakeyaml-1.29.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-json/2.6.2/spring-boot-starter-json-2.6.2.jar:/Users/u/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.13.1/jackson-datatype-jdk8-2.13.1.jar:/Users/u/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.1/jackson-datatype-jsr310-2.13.1.jar:/Users/u/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.13.1/jackson-module-parameter-names-2.13.1.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/2.6.2/spring-boot-starter-tomcat-2.6.2.jar:/Users/u/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.56/tomcat-embed-core-9.0.56.jar:/Users/u/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/9.0.56/tomcat-embed-websocket-9.0.56.jar:/Users/u/.m2/repository/org/springframework/spring-web/5.3.14/spring-web-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-beans/5.3.14/spring-beans-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-webmvc/5.3.14/spring-webmvc-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-context/5.3.14/spring-context-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-expression/5.3.14/spring-expression-5.3.14.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-security/2.6.2/spring-boot-starter-security-2.6.2.jar:/Users/u/.m2/repository/org/springframework/spring-aop/5.3.14/spring-aop-5.3.14.jar:/Users/u/.m2/repository/org/springframework/security/spring-security-config/5.6.1/spring-security-config-5.6.1.jar:/Users/u/.m2/repository/org/springframework/security/spring-security-core/5.6.1/spring-security-core-5.6.1.jar:/Users/u/.m2/repository/org/springframework/security/spring-security-crypto/5.6.1/spring-security-crypto-5.6.1.jar:/Users/u/.m2/repository/org/springframework/security/spring-security-web/5.6.1/spring-security-web-5.6.1.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-data-jpa/2.6.2/spring-boot-starter-data-jpa-2.6.2.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-aop/2.6.2/spring-boot-starter-aop-2.6.2.jar:/Users/u/.m2/repository/org/aspectj/aspectjweaver/1.9.7/aspectjweaver-1.9.7.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-jdbc/2.6.2/spring-boot-starter-jdbc-2.6.2.jar:/Users/u/.m2/repository/com/zaxxer/HikariCP/4.0.3/HikariCP-4.0.3.jar:/Users/u/.m2/repository/org/springframework/spring-jdbc/5.3.14/spring-jdbc-5.3.14.jar:/Users/u/.m2/repository/jakarta/transaction/jakarta.transaction-api/1.3.3/jakarta.transaction-api-1.3.3.jar:/Users/u/.m2/repository/jakarta/persistence/jakarta.persistence-api/2.2.3/jakarta.persistence-api-2.2.3.jar:/Users/u/.m2/repository/org/hibernate/hibernate-core/5.6.3.Final/hibernate-core-5.6.3.Final.jar:/Users/u/.m2/repository/org/jboss/logging/jboss-logging/3.4.2.Final/jboss-logging-3.4.2.Final.jar:/Users/u/.m2/repository/net/bytebuddy/byte-buddy/1.11.22/byte-buddy-1.11.22.jar:/Users/u/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar:/Users/u/.m2/repository/org/jboss/jandex/2.2.3.Final/jandex-2.2.3.Final.jar:/Users/u/.m2/repository/com/fasterxml/classmate/1.5.1/classmate-1.5.1.jar:/Users/u/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.1.2.Final/hibernate-commons-annotations-5.1.2.Final.jar:/Users/u/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.3.5/jaxb-runtime-2.3.5.jar:/Users/u/.m2/repository/org/glassfish/jaxb/txw2/2.3.5/txw2-2.3.5.jar:/Users/u/.m2/repository/com/sun/istack/istack-commons-runtime/3.0.12/istack-commons-runtime-3.0.12.jar:/Users/u/.m2/repository/org/springframework/data/spring-data-jpa/2.6.0/spring-data-jpa-2.6.0.jar:/Users/u/.m2/repository/org/springframework/data/spring-data-commons/2.6.0/spring-data-commons-2.6.0.jar:/Users/u/.m2/repository/org/springframework/spring-orm/5.3.14/spring-orm-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-tx/5.3.14/spring-tx-5.3.14.jar:/Users/u/.m2/repository/org/slf4j/slf4j-api/1.7.32/slf4j-api-1.7.32.jar:/Users/u/.m2/repository/org/springframework/spring-aspects/5.3.14/spring-aspects-5.3.14.jar:/Users/u/.m2/repository/org/springframework/boot/spring-boot-starter-validation/2.6.2/spring-boot-starter-validation-2.6.2.jar:/Users/u/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/9.0.56/tomcat-embed-el-9.0.56.jar:/Users/u/.m2/repository/org/hibernate/validator/hibernate-validator/6.2.0.Final/hibernate-validator-6.2.0.Final.jar:/Users/u/.m2/repository/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.jar:/Users/u/.m2/repository/org/liquibase/liquibase-core/4.5.0/liquibase-core-4.5.0.jar:/Users/u/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar:/Users/u/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar:/Users/u/.m2/repository/com/fasterxml/jackson/module/jackson-module-jaxb-annotations/2.13.1/jackson-module-jaxb-annotations-2.13.1.jar:/Users/u/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.1/jackson-annotations-2.13.1.jar:/Users/u/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.1/jackson-core-2.13.1.jar:/Users/u/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.1/jackson-databind-2.13.1.jar:/Users/u/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.3/jakarta.xml.bind-api-2.3.3.jar:/Users/u/.m2/repository/jakarta/activation/jakarta.activation-api/1.2.2/jakarta.activation-api-1.2.2.jar:/Users/u/.m2/repository/org/springframework/spring-core/5.3.14/spring-core-5.3.14.jar:/Users/u/.m2/repository/org/springframework/spring-jcl/5.3.14/spring-jcl-5.3.14.jar:/Users/u/.m2/repository/org/projectlombok/lombok/1.18.22/lombok-1.18.22.jar:/Users/u/.m2/repository/org/mapstruct/mapstruct-processor/1.3.1.Final/mapstruct-processor-1.3.1.Final.jar:/Users/u/.m2/repository/org/mapstruct/mapstruct/1.3.1.Final/mapstruct-1.3.1.Final.jar: -sourcepath /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/src/main/java:/Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/target/generated-sources/annotations: -s /Users/u/Desktop/java_dev/projects/stockapp-spring-boot/stockapp/target/generated-sources/annotations -g -nowarn -target 11 -source 11 -encoding UTF-8
But calling it on command line shows:
error: no source files
any help on what it's wrong ?
ANSWER
Answered 2022-Jan-17 at 19:13I've tried your example:
stockapp-spring-boot (master)$ mvn clean compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] stockapp-spring-boot [pom]
[INFO] stockapp [jar]
[INFO]
[INFO] -------------< it.raffaele.esposito:stockapp-spring-boot >--------------
[INFO] Building stockapp-spring-boot 1.2.2-SNAPSHOT [1/2]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ stockapp-spring-boot ---
...
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ stockapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 14 resources
[INFO] The encoding used to copy filtered properties files have not been set. This means that the same encoding will be used to copy filtered properties files as when copying other filtered resources. This might not be what you want! Run your build with --debug to see which files might be affected. Read more at https://maven.apache.org/plugins/maven-resources-plugin/examples/filtering-properties-files.html
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:copy-resources (Copy Vue frontend into Spring Boot target static folder) @ stockapp ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 8 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ stockapp ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 27 source files to stockapp-spring-boot/stockapp/target/classes
[INFO] stockapp-spring-boot/stockapp/src/main/java/it/raffaele/esposito/app/service/MappingFunctions.java: stockapp-spring-boot/stockapp/src/main/java/it/raffaele/esposito/app/service/MappingFunctions.java uses or overrides a deprecated API.
[INFO] stockapp-spring-boot/stockapp/src/main/java/it/raffaele/esposito/app/service/MappingFunctions.java: Recompile with -Xlint:deprecation for details.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for stockapp-spring-boot 1.2.2-SNAPSHOT:
[INFO]
[INFO] stockapp-spring-boot ............................... SUCCESS [ 0.090 s]
[INFO] stockapp ........................................... SUCCESS [ 21.988 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.339 s
[INFO] Finished at: 2022-01-17T20:12:05+01:00
[INFO] ------------------------------------------------------------------------
and no problems at all...
QUESTION
Problem when mapping an entity with a geometric field Geometry Point. When accessing the table repository, using the standard function findAll() getting "null" , although there are records in the database.When configuring, I used the official manual Hybernate Spatial. I get an error when requesting a controller: " exception is org.geolatte.geom.codec.WkbDecodeException: Expected geometryKeyword starting at position: 0] with root cause" Help me please , I do not know how to act and what is the reason
My config:
- Hibernate (5.4.32.Final)
- Hibernate Spatial (5.4.32.Final)
- Posgis (version 2.5)
- PostgreSQL 10.17
Entity:
import lombok.Data;
import org.locationtech.jts.geom.Point;
import javax.persistence.*;
@Data
@Entity
@Table (name = "region",
indexes = { @Index(name = "description_index",columnList = "description"),
@Index(name = "region_name_key",columnList = "name",unique = true),
@Index(name = "region_pkey", columnList = "region_id",unique = true) } )
public class Region {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "region_id")
private Integer region_id;
@Column(name = "state_id")
private Integer state_id;
@Column(name = "name")
private String name;
@Column(name = "location") // problem field mapping, causing the problem
private Point location ;
@Column(name = "description")
private String description;
}
Service:
import java.util.List;
@Service
@AllArgsConstructor
public class RegionService implements RegionServiceImpl {
private final RegionRepository regionRepository;
private final RegionMappingUtils regionMappingUtils;
@Override
public List findAll() {
ArrayList convert_objects = new ArrayList<>();
RegionDTO conv_object;
List objects = regionRepository.findAll();
for (int i = 0; i < objects.size(); i++) {
conv_object = regionMappingUtils.mapToRegionDto(objects.get(i));
convert_objects.add(conv_object);
}
return convert_objects;
}}
Repository:
@Repository
public interface RegionRepository extends JpaRepository {
}
Pom.xml:
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.5.2
com.xxx
service
0.0.1-SNAPSHOT
service
Table access service
16
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-starter-web
org.postgresql
postgresql
runtime
org.springframework.boot
spring-boot-starter-test
test
org.projectlombok
lombok
com.jayway.jsonpath
json-path
org.hibernate
hibernate-core
5.4.32.Final
org.checkerframework
checker-qual
3.5.0
com.jayway.jsonpath
json-path
2.5.0
net.postgis
postgis-jdbc-jtsparser
2.3.0
com.vividsolutions
jts
1.13
net.postgis
postgis-jdbc
2.3.0
org.locationtech.jts
jts-core
1.15.0
javax.validation
validation-api
2.0.1.Final
org.hibernate
hibernate-spatial
5.4.32.Final
org.springframework.boot
spring-boot-maven-plugin
Aplication.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=**********
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database=postgresql
spring.jpa.show-sql=false
spring.jpa.generate-ddl=false
spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.postgis.PostgisDialect
Error occurred:
2021-07-27 10:19:05.634 INFO 10280 --- [ main] org.hibernate.tuple.PojoInstantiator : HHH000182: No default (no-argument) constructor for class: com.axsoft.service.entity.Server_interface$Server_interface_pkey (class must be instantiated by Interceptor)
2021-07-27 10:19:05.903 INFO 10280 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-07-27 10:19:05.903 INFO 10280 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-07-27 10:19:06.335 WARN 10280 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2021-07-27 10:19:06.582 INFO 10280 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2021-07-27 10:19:06.588 INFO 10280 --- [ main] com.axsoft.service.ServiceApplication : Started ServiceApplication in 2.88 seconds (JVM running for 3.611)
2021-07-27 10:19:21.676 INFO 10280 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-07-27 10:19:21.681 INFO 10280 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-07-27 10:19:21.681 INFO 10280 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 0 ms
2021-07-27 10:19:22.293 ERROR 10280 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.geolatte.geom.codec.WkbDecodeException: Expected geometryKeyword starting at position: 0] with root cause
org.geolatte.geom.codec.WkbDecodeException: Expected geometryKeyword starting at position: 0
at org.geolatte.geom.codec.BaseWktParser.matchesGeometryKeyword(BaseWktParser.java:103) ~[geolatte-geom-1.8.0.jar:na]
at org.geolatte.geom.codec.BaseWktParser.matchesGeometryTaggedText(BaseWktParser.java:64) ~[geolatte-geom-1.8.0.jar:na]
at org.geolatte.geom.codec.BaseWktParser.parse(BaseWktParser.java:54) ~[geolatte-geom-1.8.0.jar:na]
at org.geolatte.geom.codec.PostgisWktDecoder.decode(PostgisWktDecoder.java:42) ~[geolatte-geom-1.8.0.jar:na]
at org.geolatte.geom.codec.WktDecoder.decode(WktDecoder.java:44) ~[geolatte-geom-1.8.0.jar:na]
at org.hibernate.spatial.dialect.postgis.PGGeometryTypeDescriptor.parseWkt(PGGeometryTypeDescriptor.java:76) ~[hibernate-spatial-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.spatial.dialect.postgis.PGGeometryTypeDescriptor.toGeometry(PGGeometryTypeDescriptor.java:67) ~[hibernate-spatial-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.spatial.dialect.postgis.PGGeometryTypeDescriptor$2.doExtract(PGGeometryTypeDescriptor.java:146) ~[hibernate-spatial-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:257) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:243) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:329) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:3131) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1863) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.hydrateEntityState(Loader.java:1791) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1764) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.getRow(Loader.java:1616) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:740) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.getRowsFromResultSet(Loader.java:1039) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.processResultSet(Loader.java:990) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:959) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2843) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2825) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2657) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.Loader.list(Loader.java:2652) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1414) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1636) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1604) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.query.Query.getResultList(Query.java:165) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:76) ~[hibernate-core-5.4.32.Final.jar:5.4.32.Final]
at org.springframework.data.jpa.repository.support.SimpleJpaRepository.findAll(SimpleJpaRepository.java:396) ~[spring-data-jpa-2.5.2.jar:2.5.2]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:289) ~[spring-data-commons-2.5.2.jar:2.5.2]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137) ~[spring-data-commons-2.5.2.jar:2.5.2]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121) ~[spring-data-commons-2.5.2.jar:2.5.2]
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:529) ~[spring-data-commons-2.5.2.jar:2.5.2]
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:285) ~[spring-data-commons-2.5.2.jar:2.5.2]
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:599) ~[spring-data-commons-2.5.2.jar:2.5.2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:163) ~[spring-data-commons-2.5.2.jar:2.5.2]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138) ~[spring-data-commons-2.5.2.jar:2.5.2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.5.2.jar:2.5.2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) ~[spring-tx-5.3.8.jar:5.3.8]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) ~[spring-tx-5.3.8.jar:5.3.8]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-5.3.8.jar:5.3.8]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137) ~[spring-tx-5.3.8.jar:5.3.8]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:174) ~[spring-data-jpa-2.5.2.jar:2.5.2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.8.jar:5.3.8]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) ~[spring-aop-5.3.8.jar:5.3.8]
at jdk.proxy2/jdk.proxy2.$Proxy103.findAll(Unknown Source) ~[na:na]
at com.axsoft.service.service.RegionService.findAll(RegionService.java:29) ~[classes/:na]
at com.axsoft.service.controllers.regionController.gettingTable(regionController.java:26) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197) ~[spring-web-5.3.8.jar:5.3.8]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141) ~[spring-web-5.3.8.jar:5.3.8]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106) ~[spring-webmvc-5.3.8.jar:5.3.8]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894) ~[spring-webmvc-5.3.8.jar:5.3.8]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.8.jar:5.3.8]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.8.jar:5.3.8]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1063) ~[spring-webmvc-5.3.8.jar:5.3.8]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.8.jar:5.3.8]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.8.jar:5.3.8]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.8.jar:5.3.8]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[tomcat-embed-core-9.0.48.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.8.jar:5.3.8]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.48.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:228) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.48.jar:9.0.48]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.8.jar:5.3.8]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.8.jar:5.3.8]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.8.jar:5.3.8]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.8.jar:5.3.8]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.8.jar:5.3.8]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.8.jar:5.3.8]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:190) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:163) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1723) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.48.jar:9.0.48]
at java.base/java.lang.Thread.run(Thread.java:831) ~[na:na]
ANSWER
Answered 2021-Jul-24 at 21:30Try switching the column in database for location from type of point
to type geometry
Also use all the following properties
spring:
jpa:
properties.hibernate.dialect: org.hibernate.spatial.dialect.postgis.PostgisDialect
database-platform: org.hibernate.spatial.dialect.postgis.PostgisDialect
hibernate:
dialect: org.hibernate.spatial.dialect.postgis.PostgisDialect
QUESTION
I am trying to create a simple Spring project where restaurants can add menu items to shared database and users can use a html form to search the dishes based on a range of criteria- especially dietary requirements
Form example:
Restaurant Name: Chez Hans
Gluten Free: (X)
Egg Free: (X)
Vegan: ()
Example SQL command
Select all FROM "dishes" Dish WHERE restaurant_name = "Chez Hans" AND egg_free = TRUE AND
gluten_Free = TRUE;
A list of dishes that fit their criteria would then be returned to the user.
Any field in the form can be left blank, and not checking a box for example, "vegan" does not mean that criteria should be set as 'false', but rather not included within the query. Because of this it seemed the best way to handle the issue was using JpaSpecificationExecutor to create dynamic SQL queries (similar to the implementation in the answer to the problem below)
Filtering database rows with spring-data-jpa and spring-mvc
I have created a solution based on my research and prior knowledge. However, when I implement my solution, no dishes are returned- even though there are dishes in the database that fit the search criteria. No errors are being produced, but simply a blank table, so I am not sure where I am going wrong.
I have researched countless articles/videos regarding JpaSpecificationExecutor/dynamic queries but there are parts of the that theory I am still unsure about. This is what I gather about JpaSpecificationExecutor/dynamic queries (but I may be wrong)
The meta model is not need to create dynamic queries but to verify the correctness of database query statements
To create queries using meta-model classes a wrapper class is required (In my example- DishSearch)
The following lines are to cast metamodel SingularAttribute class back to the original class value.
Path dname = root.get(Dish_.dname); Path vegan= root.get(Dish_.vegan);
I am quite new to Spring and still finding it pretty difficult. Any help or advice would be very much appreciated!
Please see below my DishSpecification class:
package com.bron.demoJPA.specification;
public class DishSpecification implements Specification {
private final DishSearch criteria;
public DishSpecification(DishSearch ds) {
criteria =ds;
}
@Override
public Predicate toPredicate(Root root, CriteriaQuery query,
CriteriaBuilder cb) {
Path dname = root.get(Dish_.dname);
Path vegan= root.get(Dish_.vegan);
Path eggFree= root.get(Dish_.eggFree);
Path glutenFree= root.get(Dish_.glutenFree);
final List predicates = new ArrayList();
if(criteria.getDname()!=null) {
predicates.add(cb.equal(dname, criteria.getDname()));
}
if(criteria.isVegan()!=false) {
predicates.add(cb.equal(vegan, criteria.isVegan()));
}
if(criteria.isEggFree()!=false) {
predicates.add(cb.equal(eggFree, criteria.isEggFree()));
}
if(criteria.isGlutenFree()!=false) {
predicates.add(cb.equal(glutenFree, criteria.isGlutenFree()));
}
return cb.and(predicates.toArray(new Predicate[predicates.size()]));
}
}
Please see my DishSearch Class:
package com.bron.demoJPA.specification;
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
public class DishSearch {
private Long dishId;
private String dname;
private String description;
private double price;
private boolean vegan;
private boolean glutenFree;
private boolean eggFree;
private AppUser app;
}
Please see my SearchController Class:
@Controller
public class SearchController {
@Autowired
DishRepository drep;
@GetMapping("/showSearchForm")
public String showNewDishForm(Model model) {
// Create model attribute to bind form data
DishSearch dishSearch = new DishSearch();
model.addAttribute("dishSearch", dishSearch);
return "search_Dish";
}
@PostMapping("/showDishList")
public String saveUser(@ModelAttribute("dishSearch")DishSearch dishSearch) {
Specification spec = new DishSpecification(dishSearch);
drep.findAll(spec);
return "show_dish_List";
}
}
Please see my DishRepository Class:
@Repository
public interface DishRepository extends JpaRepository, JpaSpecificationExecutor{
@Transactional
@Modifying
List findAll(Specification spec);
}
Please see my search_Dish.html Thymeleaf Template:
Dish Management System
Manage Dishes
Vegan?
Gluten Free?
Egg Free?
Search Database
Please see my show_dish_List.html Thymeleaf Template:
Search Results
Dish List
Dish Name
Dish description
Dish Price
Restaurant
Search Again
----------------------------Update------------------------------
In addition to the answer provided below, in the Dish Specification Class I changed
if(criteria.getDname()!=null) {
predicates.add(cb.equal(dname, criteria.getDname()));
}
to
if(criteria.getDname()!="") {
predicates.add(cb.equal(dname, criteria.getDname()));
}
and the search is working fine now!
ANSWER
Answered 2021-Dec-20 at 19:15I believe the issue is that you are not adding the result in the Model
which is being used to render the page show_dish_List.html
, therefore nothing is being populated in the UI. Your UI is expecting the data to be in listDishSearch
and there is nothing in that variable.
Update your code to:
@PostMapping("/showDishList")
public String saveUser(@ModelAttribute("dishSearch") DishSearch dishSearch, Model model) {
Specification spec = new DishSpecification(dishSearch);
model.addAttribute("listDishSearch", drep.findAll(spec));
return "show_dish_List";
}
and everything should be working fine.
Remove the method findAll
from your DishRepository
repository. It is already being provided by the interface JpaSpecificationExecutor
.
QUESTION
I'm doing a house rental application with Spring, React and MySQL. I have a class which is like a transaction. What I'm trying to do is to get all entries for the class sweetholiday_user_house, but I only want the fields start_rent_date and end_rent_date. The table is called sweet_holiday_user_house. For that I have created a SQL query in my repository:
package ch.ak.sweetholiday.sweetholidaybe.repository;
import ch.ak.sweetholiday.sweetholidaybe.model.SweetholidayUserHouse;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface SweetholidayUserHouseRepository extends JpaRepository {
@Query(value = "SELECT sweetholiday_user_house.start_rent_date, sweetholiday_user_house.end_rent_date FROM sweetholiday_user_house", nativeQuery = true)
List findAllReserved();
}
As soon as the method "findAllReserved" gets called, I get the following error message:
TransactionSafe called.
2021-12-25 21:44:28.711 WARN 57746 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: S0022
2021-12-25 21:44:28.711 ERROR 57746 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : Column 'id' not found.
2021-12-25 21:44:28.760 ERROR 57746 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [SELECT sweetholiday_user_house.start_rent_date, sweetholiday_user_house.end_rent_date FROM sweetholiday_user_house]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query] with root cause
java.sql.SQLException: Column 'id' not found.
I tried it with the JPQL query, but it still doesn't work. I'm writing because I couldn't find a solution for it anywhere. I also don't want to use @JSONIgnore because I need the id and the foreign ids like house_id for another API call. I'm doing this because I don't want to send all information to everyone. Because when I send the foreign ids like user_id, everyone will have access to every user data.
The class in my Spring application:
package ch.ak.sweetholiday.sweetholidaybe.model;
import javax.persistence.*;
import java.time.LocalDateTime;
@Entity
@Table(name = "sweetholiday_user_house")
public class SweetholidayUserHouse {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name = "sweetholiday_user_id", referencedColumnName = "id")
private SweetholidayUser sweetholidayUser;
@ManyToOne
@JoinColumn(name = "house_id", referencedColumnName = "id")
private House house;
@Column(name = "transaction_date")
private LocalDateTime transaction_date;
@Column(name = "start_rent_date")
private LocalDateTime start_rent_date;
@Column(name = "end_rent_date")
private LocalDateTime end_rent_date;
@Column(name = "options")
private String options;
@Column(name = "payment")
private String payment;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public SweetholidayUser getSweetholidayUser() {
return sweetholidayUser;
}
public void setSweetholidayUser(SweetholidayUser sweetholidayUser) {
this.sweetholidayUser = sweetholidayUser;
}
public House getHouse() {
return house;
}
public void setHouse(House house) {
this.house = house;
}
public LocalDateTime getTransaction_date() {
return transaction_date;
}
public void setTransaction_date(LocalDateTime transaction_date) {
this.transaction_date = transaction_date;
}
public LocalDateTime getStart_rent_date() {
return start_rent_date;
}
public void setStart_rent_date(LocalDateTime start_rent_date) {
this.start_rent_date = start_rent_date;
}
public LocalDateTime getEnd_rent_date() {
return end_rent_date;
}
public void setEnd_rent_date(LocalDateTime end_rent_date) {
this.end_rent_date = end_rent_date;
}
public String getOptions() {
return options;
}
public void setOptions(String options) {
this.options = options;
}
public String getPayment() {
return payment;
}
public void setPayment(String payment) {
this.payment = payment;
}
}
The method gets called like that:
@Override
public List findAllTransactionsSafe() {
return sweetholidayUserHouseRepository.findAllReserved();
}
Here is the full error message if you need it:
TransactionSafe called.
2021-12-25 21:44:28.711 WARN 57746 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: S0022
2021-12-25 21:44:28.711 ERROR 57746 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : Column 'id' not found.
2021-12-25 21:44:28.760 ERROR 57746 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; SQL [SELECT sweetholiday_user_house.start_rent_date, sweetholiday_user_house.end_rent_date FROM sweetholiday_user_house]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query] with root cause
java.sql.SQLException: Column 'id' not found.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.27.jar:8.0.27]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.27.jar:8.0.27]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[mysql-connector-java-8.0.27.jar:8.0.27]
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[mysql-connector-java-8.0.27.jar:8.0.27]
at com.mysql.cj.jdbc.result.ResultSetImpl.findColumn(ResultSetImpl.java:581) ~[mysql-connector-java-8.0.27.jar:8.0.27]
at com.mysql.cj.jdbc.result.ResultSetImpl.getLong(ResultSetImpl.java:854) ~[mysql-connector-java-8.0.27.jar:8.0.27]
at com.zaxxer.hikari.pool.HikariProxyResultSet.getLong(HikariProxyResultSet.java) ~[HikariCP-4.0.3.jar:na]
at org.hibernate.type.descriptor.sql.BigIntTypeDescriptor$2.doExtract(BigIntTypeDescriptor.java:63) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:257) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:243) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:329) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.Loader.extractKeysFromResultSet(Loader.java:811) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:735) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.Loader.getRowsFromResultSet(Loader.java:1047) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.Loader.processResultSet(Loader.java:998) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:967) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2868) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2850) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2682) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.Loader.list(Loader.java:2677) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:2195) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.internal.AbstractSharedSessionContract.list(AbstractSharedSessionContract.java:1190) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.query.internal.NativeQueryImpl.doList(NativeQueryImpl.java:177) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.hibernate.query.Query.getResultList(Query.java:165) ~[hibernate-core-5.6.1.Final.jar:5.6.1.Final]
at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:128) ~[spring-data-jpa-2.6.0.jar:2.6.0]
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:90) ~[spring-data-jpa-2.6.0.jar:2.6.0]
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:155) ~[spring-data-jpa-2.6.0.jar:2.6.0]
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:143) ~[spring-data-jpa-2.6.0.jar:2.6.0]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137) ~[spring-data-commons-2.6.0.jar:2.6.0]
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121) ~[spring-data-commons-2.6.0.jar:2.6.0]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159) ~[spring-data-commons-2.6.0.jar:2.6.0]
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138) ~[spring-data-commons-2.6.0.jar:2.6.0]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.6.0.jar:2.6.0]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) ~[spring-tx-5.3.13.jar:5.3.13]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) ~[spring-tx-5.3.13.jar:5.3.13]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-5.3.13.jar:5.3.13]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137) ~[spring-tx-5.3.13.jar:5.3.13]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:145) ~[spring-data-jpa-2.6.0.jar:2.6.0]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) ~[spring-aop-5.3.13.jar:5.3.13]
at jdk.proxy4/jdk.proxy4.$Proxy116.findAllReserved(Unknown Source) ~[na:na]
at ch.ak.sweetholiday.sweetholidaybe.service.SweetholidayUserHouseServiceImpl.findAllTransactionsSafe(SweetholidayUserHouseServiceImpl.java:48) ~[classes/:na]
at ch.ak.sweetholiday.sweetholidaybe.service.SweetholidayUserHouseServiceImpl$$FastClassBySpringCGLIB$$376f23f9.invoke() ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.13.jar:5.3.13]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) ~[spring-tx-5.3.13.jar:5.3.13]
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) ~[spring-tx-5.3.13.jar:5.3.13]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-5.3.13.jar:5.3.13]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753) ~[spring-aop-5.3.13.jar:5.3.13]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698) ~[spring-aop-5.3.13.jar:5.3.13]
at ch.ak.sweetholiday.sweetholidaybe.service.SweetholidayUserHouseServiceImpl$$EnhancerBySpringCGLIB$$a6cbff5.findAllTransactionsSafe() ~[classes/:na]
at ch.ak.sweetholiday.sweetholidaybe.controller.UserController.getSafeTransaction(UserController.java:104) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.13.jar:5.3.13]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.13.jar:5.3.13]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[tomcat-embed-core-9.0.55.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.13.jar:5.3.13]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.55.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:327) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:115) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:81) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:122) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:116) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:126) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:81) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:109) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:149) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilterInternal(BasicAuthenticationFilter.java:150) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at ch.ak.sweetholiday.sweetholidaybe.jwt.JWTAuthorizationFilter.doFilterInternal(JWTAuthorizationFilter.java:40) ~[classes/:na]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:219) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:213) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:103) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:89) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:91) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.header.HeaderWriterFilter.doHeadersAfter(HeaderWriterFilter.java:90) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:75) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:110) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:80) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:55) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:336) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:211) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:183) ~[spring-security-web-5.6.0.jar:5.6.0]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271) ~[spring-web-5.3.13.jar:5.3.13]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.13.jar:5.3.13]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) ~[spring-web-5.3.13.jar:5.3.13]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:540) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:382) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1722) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.55.jar:9.0.55]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
ANSWER
Answered 2021-Dec-25 at 22:09You are selecting a subset (start_rent_date and end_rent_date
) of the columns of the table sweetholiday_user_house
. However the results are being mapped to the managed entity SweetholidayUserHouse
. So the mapping fails when it looks for the id column in the resultset, which is missing.
You can avoid this exception by either of these two approaches. There are several more. Here is a good discussion of this - Spring JPA selecting specific columns
Option 1: Keep the existing query and change the return type of the findAllReserved() method to Object[]
. Here for each Object[], Object[0] is start_rent_date and Object[1] is end_rent_date.
@Query(value = "SELECT sweetholiday_user_house.start_rent_date, sweetholiday_user_house.end_rent_date FROM sweetholiday_user_house", nativeQuery = true)
List findAllReserved();
Option 2: Keep the return type and change the query to JPA query (non-native) to return all the columns. This will map all the columns to the Hibernate Object.
@Query(value = "SELECT user FROM sweetholiday_user_house user")
List findAllReserved();
QUESTION
When upgrading my app from Spring Boot 2.2 with JDK 11 to Spring Boot 2.5.5 with JDK 17, Mockito gives this error:
Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
In other posts the solution is to use the right Mockito-core. I use even a newer one: 4.2.0.
The other solution is to remove the Mockito core from the spring-boot-test-starter. Done as well, no solution.
Again another solution is to use the newest net.buddy (after excluding in other packages). I did, no solution.
net.bytebuddy
byte-buddy
1.12.3
test
net.bytebuddy
byte-buddy-agent
1.12.3
test
Using mock( ) was another option, alas, that gave the same error.
Working with a @MockBean resulted gave no solution.
Finally I also ported all tests to a JUnit 5 version. Still the same error is given.
This is the simplified class I want to test:
@Service
public class ForTestingChild {
public String getExternalStuff( String input) {
return "Get that external input";
}
}
The is the simplified class using the previous class:
@Service
public class ForTestingThisIsParent {
private ForTestingChild forTestingChild;
public ForTestingThisIsParent( ForTestingChild forTestingChild) {
this.forTestingChild = forTestingChild;
}
public String getValueFromChild( String input) {
return forTestingChild.getExternalStuff( input);
}
}
This is the test class:
@RunWith(MockitoJUnitRunner.class)
public class ForTestingThisIsParentTest {
@Mock
ForTestingChild forTestingChild;
@InjectMocks
ForTestingThisIsParent forTestingThisIsParent;
@Test
public void testBasic() {
when( forTestingChild.getExternalStuff( any())).thenReturn( "Simulated external stuff");
assertEquals( "Simulated external stuff", forTestingThisIsParent.getValueFromChild( "Nonesense stuff"));
}
}
This is the message and the stacktrace:
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class nl.*****.fortesting.ForTestingChild.
Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.
Java : 17
JVM vendor name : Oracle Corporation
....
Underlying exception : java.lang.UnsupportedOperationException: Cannot define class using reflection
at org.mockito.internal.runners.DefaultInternalRunner$1.withBefores(DefaultInternalRunner.java:39)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:276)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:79)
at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:85)
at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:163)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: java.lang.UnsupportedOperationException: Cannot define class using reflection
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$Unavailable.defineClass(ClassInjector.java:821)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.inject(ClassInjector.java:185)
at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:187)
at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:79)
at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4457)
at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:121)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:138)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:346)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:161)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:355)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:65)
at org.mockito.Mockito.mock(Mockito.java:1855)
at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:36)
at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16)
at org.mockito.internal.configuration.IndependentAnnotationEngine.createMockFor(IndependentAnnotationEngine.java:38)
at org.mockito.internal.configuration.IndependentAnnotationEngine.process(IndependentAnnotationEngine.java:62)
at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:57)
at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:41)
at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:69)
... 21 more
Caused by: java.lang.IllegalStateException: Could not find sun.misc.Unsafe
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$Disabled.initialize(ClassInjector.java:1366)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe.inject(ClassInjector.java:1202)
at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$ForUnsafeInjection.load(ClassLoadingStrategy.java:458)
at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:79)
at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:4457)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$Indirect.make(ClassInjector.java:684)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$CreationAction.run(ClassInjector.java:302)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$CreationAction.run(ClassInjector.java:290)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.(ClassInjector.java:70)
at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:184)
... 44 more
Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
at java.base/java.lang.Class.getMethod(Class.java:2227)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$CreationAction.run(ClassInjector.java:1269)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$CreationAction.run(ClassInjector.java:1257)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe.(ClassInjector.java:1136)
... 53 more
The dependency tree is:
+- org.springframework.boot:spring-boot-starter:jar:2.5.5:compile
| +- org.springframework.boot:spring-boot:jar:2.5.5:compile
| | \- org.springframework:spring-context:jar:5.3.10:compile
| +- org.springframework.boot:spring-boot-autoconfigure:jar:2.5.5:compile
| +- jakarta.annotation:jakarta.annotation-api:jar:1.3.5:compile
| +- org.springframework:spring-core:jar:5.3.10:compile
| | \- org.springframework:spring-jcl:jar:5.3.10:compile
| \- org.yaml:snakeyaml:jar:1.28:compile
+- org.springframework.boot:spring-boot-starter-log4j2:jar:2.5.5:compile
| +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.14.1:compile
| | \- org.apache.logging.log4j:log4j-api:jar:2.14.1:compile
| +- org.apache.logging.log4j:log4j-core:jar:2.14.1:compile
| +- org.apache.logging.log4j:log4j-jul:jar:2.14.1:compile
| \- org.slf4j:jul-to-slf4j:jar:1.7.32:compile
+- org.springframework.boot:spring-boot-starter-web:jar:2.5.5:compile
| +- org.springframework.boot:spring-boot-starter-json:jar:2.5.5:compile
| | +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.12.5:compile
| | \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.12.5:compile
| +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.5.5:compile
| | +- org.apache.tomcat.embed:tomcat-embed-core:jar:9.0.53:compile
| | \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.53:compile
| +- org.springframework:spring-web:jar:5.3.10:compile
| | \- org.springframework:spring-beans:jar:5.3.10:compile
| \- org.springframework:spring-webmvc:jar:5.3.10:compile
| +- org.springframework:spring-aop:jar:5.3.10:compile
| \- org.springframework:spring-expression:jar:5.3.10:compile
+- org.springframework.boot:spring-boot-starter-data-rest:jar:2.5.5:compile
| \- org.springframework.data:spring-data-rest-webmvc:jar:3.5.5:compile
| \- org.springframework.data:spring-data-rest-core:jar:3.5.5:compile
| +- org.springframework.hateoas:spring-hateoas:jar:1.3.4:compile
| +- org.springframework.plugin:spring-plugin-core:jar:2.0.0.RELEASE:compile
| \- org.atteo:evo-inflector:jar:1.2.2:compile
+- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.5.5:compile
| +- org.springframework.boot:spring-boot-starter-aop:jar:2.5.5:compile
| | \- org.aspectj:aspectjweaver:jar:1.9.7:compile
| +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.5.5:compile
| | +- com.zaxxer:HikariCP:jar:4.0.3:compile
| | \- org.springframework:spring-jdbc:jar:5.3.10:compile
| +- jakarta.transaction:jakarta.transaction-api:jar:1.3.3:compile
| +- jakarta.persistence:jakarta.persistence-api:jar:2.2.3:compile
| +- org.hibernate:hibernate-core:jar:5.4.32.Final:compile
| | +- org.jboss.logging:jboss-logging:jar:3.4.2.Final:compile
| | +- org.javassist:javassist:jar:3.27.0-GA:compile
| | +- net.bytebuddy:byte-buddy:jar:1.10.22:compile
| | +- antlr:antlr:jar:2.7.7:compile
| | +- org.jboss:jandex:jar:2.2.3.Final:compile
| | +- com.fasterxml:classmate:jar:1.5.1:compile
| | +- org.dom4j:dom4j:jar:2.1.3:compile
| | +- org.hibernate.common:hibernate-commons-annotations:jar:5.1.2.Final:compile
| | \- org.glassfish.jaxb:jaxb-runtime:jar:2.3.5:compile
| | +- org.glassfish.jaxb:txw2:jar:2.3.5:compile
| | +- com.sun.istack:istack-commons-runtime:jar:3.0.12:compile
| | \- com.sun.activation:jakarta.activation:jar:1.2.2:runtime
| +- org.springframework.data:spring-data-jpa:jar:2.5.5:compile
| | +- org.springframework.data:spring-data-commons:jar:2.5.5:compile
| | +- org.springframework:spring-orm:jar:5.3.10:compile
| | \- org.springframework:spring-tx:jar:5.3.10:compile
| \- org.springframework:spring-aspects:jar:5.3.10:compile
+- org.springframework.boot:spring-boot-starter-validation:jar:2.5.5:compile
| +- org.apache.tomcat.embed:tomcat-embed-el:jar:9.0.53:compile
| \- org.hibernate.validator:hibernate-validator:jar:6.2.0.Final:compile
| \- jakarta.validation:jakarta.validation-api:jar:2.0.2:compile
+- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.12.5:compile
| +- com.fasterxml.jackson.core:jackson-annotations:jar:2.12.5:compile
| +- com.fasterxml.jackson.core:jackson-core:jar:2.12.5:compile
| \- com.fasterxml.jackson.core:jackson-databind:jar:2.12.5:compile
+- mysql:mysql-connector-java:jar:8.0.25:compile
+- io.jsonwebtoken:jjwt:jar:0.9.1:compile
+- com.jayway.jsonpath:json-path:jar:2.6.0:compile
| +- net.minidev:json-smart:jar:2.4.7:compile
| | \- net.minidev:accessors-smart:jar:2.4.7:compile
| \- org.slf4j:slf4j-api:jar:1.7.32:compile
+- org.apache.httpcomponents:httpclient:jar:4.5.13:compile
| \- org.apache.httpcomponents:httpcore:jar:4.4.14:compile
+- commons-codec:commons-codec:jar:1.15:compile
+- org.springframework.security:spring-security-crypto:jar:5.5.2:compile
+- com.squareup.okhttp3:okhttp:jar:4.9.3:compile
| +- com.squareup.okio:okio:jar:2.8.0:compile
| | \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.5.31:compile
| \- org.jetbrains.kotlin:kotlin-stdlib:jar:1.5.31:compile
| \- org.jetbrains:annotations:jar:13.0:compile
+- com.squareup.okhttp3:okhttp-urlconnection:jar:4.9.3:compile
| \- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.5.31:compile
| \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.5.31:compile
+- org.springframework.boot:spring-boot-starter-test:jar:2.5.5:test
| +- org.springframework.boot:spring-boot-test:jar:2.5.5:test
| +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.5.5:test
| +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
| | \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
| +- org.assertj:assertj-core:jar:3.19.0:test
| +- org.hamcrest:hamcrest:jar:2.2:test
| +- org.junit.jupiter:junit-jupiter:jar:5.8.2:test
| | \- org.junit.jupiter:junit-jupiter-params:jar:5.8.2:test
| +- org.skyscreamer:jsonassert:jar:1.5.0:test
| | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
| +- org.springframework:spring-test:jar:5.3.10:test
| \- org.xmlunit:xmlunit-core:jar:2.8.2:test
+- org.junit.jupiter:junit-jupiter-engine:jar:5.8.2:test
| +- org.junit.platform:junit-platform-engine:jar:1.8.2:test
| | +- org.opentest4j:opentest4j:jar:1.2.0:test
| | \- org.junit.platform:junit-platform-commons:jar:1.8.2:test
| +- org.junit.jupiter:junit-jupiter-api:jar:5.8.2:test
| \- org.apiguardian:apiguardian-api:jar:1.1.2:test
+- org.mockito:mockito-junit-jupiter:jar:4.1.0:test
| \- org.mockito:mockito-core:jar:2.24.0:test
| +- net.bytebuddy:byte-buddy-agent:jar:1.10.22:test
| \- org.objenesis:objenesis:jar:2.6:test
+- org.springframework.boot:spring-boot-devtools:jar:2.5.5:compile (optional)
+- net.bytebuddy:byte-buddy-dep:jar:1.12.3:compile
| +- org.ow2.asm:asm:jar:9.2:compile
| \- org.ow2.asm:asm-commons:jar:9.2:compile
\- com.google.code.gson:gson:jar:2.8.9:compile
ANSWER
Answered 2021-Dec-20 at 13:30It was an Intelli-J issue!
So, cleaning the Intelli-J dependency spaghetti up solved it!
- File > Invalidate cache ... and restart. Helped a bit.
- Closing the Intelli-J project. Then removed manually the ".idea" folder and any *.iml file.
Yes, I did option 1 previously. Especially doing action 2 solved it within a minute.
QUESTION
I am trying to use the RestResponse
object from org.jboss.resteasy.reactive
on the return of my application resources since the javax.ws.rs.core.Response
doesn't provide the generic type.
I am getting the error when I call this endpoint:
public RestResponse> findAll() {
return ResponseBuilder.ok(sampleService.findAll()).build();
}
The error:
Request failed: java.lang.ClassCastException: class org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl cann
ot be cast to class org.jboss.resteasy.reactive.common.jaxrs.RuntimeDelegateImpl (org.jboss.resteasy.core.providerfactory.ResteasyProviderFactoryImpl and org.jboss.resteasy.reactive.common.jaxrs.RuntimeDelegateImpl are in unnamed mo
dule of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @3c153a1)
My dependencies in pom.xml:
io.quarkus
quarkus-hibernate-orm
io.quarkus
quarkus-hibernate-validator
io.quarkus
quarkus-rest-client
io.quarkus
quarkus-smallrye-openapi
io.quarkus
quarkus-resteasy-reactive-jackson
io.quarkus
quarkus-liquibase
io.quarkus
quarkus-smallrye-health
io.quarkus
quarkus-redis-client
io.quarkus
quarkus-arc
io.quarkus
quarkus-rest-client-jackson
io.quarkus
quarkus-config-yaml
io.quarkus
quarkus-junit5
test
io.quarkus
quarkus-spring-data-jpa
org.projectlombok
lombok
${lombok.version}
compile
io.quarkus
quarkus-jdbc-postgresql
io.quarkus
quarkus-spring-web
io.quarkus
quarkus-resteasy-reactive
ANSWER
Answered 2021-Dec-06 at 16:19I just solved the problem... It was the order of dependecies. I switched quarkus-resteasy-reactive
to the top and it is working now.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-data-jpa
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page