Questions tagged [spring-boot]

21046 questions
1

votes
1

answer
264

Views

Not able access multiple data sources in Spring boot

I am new to Spring & Spring boot and I am trying to access two data sources but am I able to connect to only one data source. when I try to call a function accessing 2nd data source the call goes to the first data source and I get the below error, com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorExce...
Arigato Manga
1

votes
1

answer
275

Views

How to setup standalone Controller only once before all test cases in Spring Boot?

I am writing unit tests for controller. I am mocking service layer and using standalone setup for rest controller. ProductSupplierControllerUnitTest.java public class ProductSupplierControllerUnitTest { @Mock private ProductSupplierService productSupplierService; @InjectMocks private ProductSupplier...
Harshit
1

votes
0

answer
377

Views

Spring Scheduler not working when used on the Interface method

I am trying to implement a interface method annotated with @Scheduled annotation with a cron expression. I am expecting the class that implements the interface and overrides the method should have the scheduler functionality from the interface but that's not the case? Can anyone explain me why? Is t...
Bhagath
1

votes
1

answer
583

Views

Bearer token failure MockMvc test Java Spring Boot

I'm failing to understand why this does not work. I'm assuming it's something simple that I'm overlooking. All other other test methods not utilizing a token work fine. There is no expiration currently on the token, and I can use it fine with Postman. @Test public void getUser() throws Exception {...
Leo Williams
1

votes
1

answer
40

Views

Starting Sub SpringBootApplication in Spring project for micro service

I'm trying to run another spring boot service from existing application, in order and use the same database layer. The two app should be deferent services with deferent ports. My project structure is this: - com.name (Project A) | - Application | - com.name.controller - com.name.controller2 (New) (P...
Jonny
1

votes
0

answer
161

Views

Replace space for %20 in Spring with UriCompnentsBuilder

I've got a method that takes some parameters and forms a URI from them in order to access our client REST service. It may occur of one of these parameters be a space. The problem is that UriComponentsBuilder.pathSegment ignores space. So, let say, 'v1', ' ', 'v2'... would form the URI .../v1/v2 inst...
GordonBR
1

votes
1

answer
73

Views

Is it guaranteed that subscription for response is established before request is processed in temp-topic based request/response scheme?

I would like to implement an request/response pattern in the following parts: Server: Springboot with ActiveMQ Client: JavaScript with stompjs over websocket I want a behaviour like an http request. Send a Request, get a corresponding Response. I try to do this with temporary channels I send 3 Mess...
Ralf B.
1

votes
0

answer
67

Views

Spring - How to secure Server Sent Events

I want to to use Springs Server Sent Events to update specific parts in a Angular frontend. I want that only authorized user can subscribe to the Server Sent Events. That's not the problem but how can I check if the user is still authorized to retrieve the push messages after e.g. the session is exp...
meleagros
1

votes
1

answer
1.4k

Views

Testing Spring Boot Cache(Caffeine)

I have my cache config as below; @Configuration public class CacheConfiguration { @Bean public CacheManager cacheManager(Ticker ticker) { CaffeineCache bookCache = buildCache('books', ticker, 30); SimpleCacheManager cacheManager = new SimpleCacheManager(); cacheManager.setCaches(Collections.singleto...
Raj
0

votes
0

answer
10

Views

How to change the username/password and database runtime using HikariCP

I have a multi tenant application that tries to connect to database per tenant and each database will have its own username/password. I want to achieve this using a single datasource by switching between the datasources and users. I tried to set the username and password at runtime on getting the co...
Srik91
1

votes
0

answer
270

Views

Unable to deserialize Xml annoted class in Spring boot

First off, I used JAXB to create the java classes from an XSD document, and this created the following structure import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; import javax.xml.bind.annotation.XmlType; @XmlType( name = 'types' ) @XmlEnum public enum Types {...
neo
1

votes
1

answer
373

Views

Spring PermissionEvaluator multiple permissions

I have created a customPermissionEvaluator and I'm trying to find the best way of using hasPermission implementation for multiple permissions. I know that If I use the next way: @PreAuthorize('hasPermission(#foo, 'test1') and hasPermission(#foo2, 'test2')') it will call @Override public boolean...
Gal Sosin
1

votes
0

answer
525

Views

Fallback option in Spring application properties

I have a REST Service built with Spring Boot where I'm using an application.yml file to setup environment variables. The REST service will be deployed to Amazon Elastic Beanstalk. I have setup Environment Properties in the configuration for the Environment (Configuration -> Software Configuration ->...
g3blv
1

votes
0

answer
49

Views

javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: void

I am getting following Exception: javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: void while calling spring data jpa repository's save method, any specific reason behind this ? *Edited please see activitymaster and repository I have added. @Entity @Table(nam...
Mayur
1

votes
0

answer
159

Views

Spring integration application failing on weblogic-properties file doesnt exist

2018-01-02 15:55:27 DEBUG ClasspathLoggingApplicationListener:55 - Application failed to start with classpath: unknown 2018-01-02 15:55:27 ERROR SpringApplication:771 - Application startup failed org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [co...
sreenivas
1

votes
0

answer
49

Views

Calling method on autowired controller hangs when executed on a new thread

I have a very simplified code sample below, but basically I have a scheduler that calls a controller on a new thread. In that new thread MOST autowired beans work fine, but one of them, MyController, just hangs if i try and invoke it for any reason. The only thing i can find different about MyContr...
GavinF
1

votes
0

answer
58

Views

Is it good design to loop through many users? - SpringBoot

I am looking into good design principles and would just like some feedback. I want to go through every user in my application that is a patient, check their scheduled activities, see if there is one upcoming and send them an email. It looks a little like this: List listOfAllPatients = patientReposi...
jackabe
1

votes
1

answer
88

Views

MockMvc - calling a query with a complicated object

I want to send to the controller a complex object consisting of files and simple types. public class ContributionNew { private List elementsToAdd; private Map elementsToUpdate; private Set idsToDelete; private Set sources; private String comment; } public class Photo extends MovieInfoDTO { private M...
sfsdfgdsg
1

votes
0

answer
450

Views

java.io.FileNotFoundException: Could not open ServletContext resource [/application.properties]

org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.gaian.adwize.ssp.main.SSPStarter]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/application.properties] at org.springframework.context.annotation.Co...
ShantiRadhkrishnan
1

votes
0

answer
139

Views

Redirect to another page when login based on condition in spring boot

I am developing a sample in spring boot in which first show login page and if login is correct then move to home page. Their is one feature in which I send a mail with a link.On click of this link my login page is open in new window and if already login then move to that page which is specify in lin...
parita porwal
1

votes
1

answer
233

Views

GAE(Spring Boot App) CORS check not returning Access-Control-Allow-Origin header

I have spent the whole day trying to deploy a Spring Boot Application (REST API) to Google App Engine, and I am stuck trying to get past the CORS configuration. The spring application works locally so I know that Spring CORS configuration is correct. However, I get the following error when I deploy...
Calvin Son
1

votes
1

answer
206

Views

Cannot update entity

I'm trying to update an entity with a particular mapping : @Entity @Table(name = 'obs_structure2') @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = 'id') public class Structure implements Serializable{ private String id; private String tag; private String descrip...
Grechka Vassili
1

votes
0

answer
78

Views

Can Spring Cloud Task application can run on embedded tomcat

I have a simple webapp with @EnableTask annotation at main class. My Application is running on embedded tomcat. Is it is possible to run SpringBoot WebApp wrapped with @EnableTask annotation in embedded tomcat. Is yes can i have a simple example for that? Thanks
Jagadheeswaran Mohan
1

votes
0

answer
563

Views

Unique records on multiple columns in Spring Boot

I have for example 2 tables: Table 1: user userid titleid (Links to title table below) name surname Table 2: title titleid title User Entity class: @Entity @Table(name='user', uniqueConstraints={@UniqueConstraint(name='user_unique', columnNames={'titleid', 'name'})}) @NamedQuery(name='User.findAll'...
Quentinb
1

votes
2

answer
1.2k

Views

Spring/tomcat Cannot load driver class: com.mysql.jdbc.driver

Lately I have been trying to learn spring boot. I have the following relevant files: an @Configuration class: I use this to generate the entitymanagerfactory an @Entity class: I use this to map to a mysql table instance an @Repository crudrepository interface: this is built in to spring an @Control...
Connor Butch
1

votes
1

answer
780

Views

OpenId connect Spring security 5 and Spring Boot

I'm trying to implement an authorization server Google like. After a few hour spend searching I'm not able to find the solution. Where can I find a simple example to do that? I'm trying to use the @EnableAuthorizationServer annotation but I don't know it it is the right way.
Luca
1

votes
1

answer
649

Views

No service dependencies found in Jaeger UI

I am new to jaeger and I am facing issues with finding the services list in the jaeger UI. Below are the .yaml configurations I prepared to run jaeger with my spring boot app on Kubernetes using minikube locally. kubectl create -f https://raw.githubusercontent.com/jaegertracing/jaeger-kubernetes/mas...
Sourav
1

votes
1

answer
629

Views

Spring-Boot: configure Log4j2 to use Spring-Boot DataSource

I'm building an application using Spring-Boot (1.5.9-RELEASE) and I want to use log4j2 with it. I want to configure log4j2 to log to a database table using a JDBC connection. My issue is that I am unable to configure log4j2 to use the DataSource I have configured for Spring-Boot. I know that log4j2...
MattWeiler
1

votes
1

answer
217

Views

Securing SpringBoot REST endpoints in Google Cloud Platform

I created a SpringBoot application with a couple of REST endpoints and deployed it to Google App Engine Standard. Everything works fine and I am able to hit the endpoints. Now I want to secure these endpoints and allow only users authorized as admin to be able to call one of the endpoints. I tried...
AndoverDev
1

votes
1

answer
426

Views

Spring boot and Akka cluster actor dependency injection not working

I am trying to use Spring boot and akka. I have two processes and communicate with akka cluster. Only process A uses spring boot. @Autowired private ActorSystem springActorSystem; @Autowired private SpringExtension springExtension; private ActorRef caActor; caActor = springActorSystem.actorOf(spring...
Chi Shin Hsu
1

votes
1

answer
1.3k

Views

spring-cloud-config server - org.springframework.cloud.config.server.environment.NoSuchRepositoryException | Cannot clone or checkout repository:?

I'm working with Spring Cloud, and using Config-server to externalize properties for micro-services. following is the config-server's manifest file server: port: 8888 spring: cloud: config: server: git: uri: https://github.com/Girdhars/config-server.git application: name: config-server management:...
1

votes
1

answer
586

Views

spring.config.location not working without classpath resource

I have my config class as below @Configuration @PropertySource(value= 'classpath:conf/agent.properties') public class AppConfig{ While running the application using java -jar app.jar spring.config.location=path-to-external-property-file the application runs fine and takes the properties from the ex...
java_dev
1

votes
1

answer
82

Views

Springboot Jackson Generic data type serialize

I have a class public class ResponseWrapper { private T mObject; /** * @return the mObject */ public T getmObject() { return mObject; } /** * @param mObject the mObject to set */ public void setData(T mObject) { this.mObject = mObject; } } T is a generic type object which I set. So i'll initialize...
Uday
1

votes
0

answer
132

Views

JHipster: Login with email + password. Issue with cache

I have a problem with the cache when I login with email/password in my dev enviroment of a JHipster project. Here are the steps: In a new fresh project, I login with [email protected] user Go to account->settings and change the email to [email protected] and save the changes I logout and then I can login...
Paul
1

votes
1

answer
1.9k

Views

java.lang.IllegalArgumentException: URI is not absolute Error in spingboot application

I am trying to call an App1 from App2. Both are in springboot and are hosted in Cloudfoundry. I am getting the below error while doing the process. java.lang.IllegalArgumentException: URI is not absolute But when I call the App1 from postman it works perfectly. Also when I call App1(at cloudfoundry)...
Tulsi Jain
1

votes
1

answer
713

Views

Webjars + Springboot. Custom resource path

I have a Spring Boot application which acts as a server for my frontend, built by webpack and included into my spring boot web archive. I use webjars to access my frontend scripts and contents. But there is one problem. To access webjars resources I need to use pathes like: /webjars/jar-file-name/r...
Konstantin Abakumov
1

votes
1

answer
301

Views

My Angular 4 Application cannot request token to Spring Boot Server

I am currently developing an Angular 4 application with Spring Boot as backend. When I want to request a token to the backend server, I get different error messages for each browser. 1. Chrome console message : Failed to load http://localhost:4002/oauth/token?username=wiko&password=shefvaas&grant_...
Annas Dan
1

votes
1

answer
181

Views

reload table datatables with fragment

i m trying to reload a fragment by ajax, but when i reload my event select does not work neither the row count, it means the default config is not working as i want: @PostMapping('/admin/add') public String add(@ModelAttribute(name = 'client') Client client,Model model){ client.setPassword('sdfsdf'...
1

votes
1

answer
886

Views

Spring Boot: Disable Client Auth for specific URL

I have the below config in my appliaction.yml server: #address: port: 8443 sessionTimeout: 30 ssl: client-auth: need key-store: keyStore.jks key-store-password: 12345 key-password: datacert protocol: TLS trust-store: truststore.jks trust-store-password: 12345 Since I have client-auth: need, my appli...
RanPaul
1

votes
0

answer
84

Views

Spring default error handler tries to write error html to output stream used by spring to return file content

Hi I have the following problem I have a Controller that is used to download a file public ResponseEntity downloadFile(String path) { FileContentInformation fileContent = getInputContentFromSomewhere(); //Content-Type, Content-Length, Content-Disposition, etc. final HttpHeaders responseHeaders = cr...
maczikasz

View additional questions