Questions tagged [spring]

89909 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
179

Views

Get the name of the “method argument” in aspect ? (AspectJ)

How can I get the name of argument in aspect, for example if my method is test(Sample sampleDto), I need know the name of sampleDto in my aspect. How get it from ProceedingJoinPoint ? I try this, but I get null. String[] argumentsName = ((MethodSignature) proceedingJoinPoint.getSignature()).getPara...
Hamid
1

votes
1

answer
59

Views

Spring Roo example on main page does not work

I installed Spring Roo. But when I try the script at the bottom of the Roo's main page, project setup --topLevelPackage com.fooI have this error: You cannot specify option 'topLevelPackage' when you have also specified '' in the same command What can I do to make it work?
Pierre Thibault
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
156

Views

multiple query vs batch performance with Mybatis in Spring

I have one question. multiple query vs batch with mybatis in Spring example) case 1. allowmutiquery=true and one call call 'mutiquery' ; update ... set .... case 2. loop multiple call and batch execute for( ; ; ){ call 'batch' ; } update ... set .... what is the way better?
J.K.R
1

votes
0

answer
240

Views

Spring NamedParameterJdbcTemplate return empty list for oracle db

I had such problem: 'ORA-12705: Cannot access NLS data files or invalid environment' before. After reading different solution of this issue I added string Locale.setDefault(Locale.ENGLISH); to my DAO class method But now it returns empty list. Code of Dao class: public class StudentsDao { private...
AKS
1

votes
1

answer
451

Views

How are ids autogenerated in spring data couchbase?

I want to create autogeneration of IDs to my documents in spring data couchbase. Spring docs has steps for this: https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#couchbase.autokeygeneration Here is my code: @Document public class User { @Id @GeneratedValue(strategy = Gener...
User1230321
1

votes
1

answer
51

Views

Creating JSON Objects from Relational DB JPA/Hibernate Queries

I have a relational DB accessed with JPA/Hibernate in a Spring web app. I have a lot of Ajax queries where the relational results need to be translated into JSON objects. Is there a simple solution to convert something like this, from a Relational JPA query, to the below? Result [ { id: event-..782,...
gene b.
1

votes
0

answer
69

Views

EclipseLink JPA query not working

I have an sql query as below select pset.psetID from PlanPlanSet pset left join Excludedplans eld on pset.plnNBR = eld.plnNBR group by pset.psetID having count(pset.plnNBR) = count(eld.plnNBR) I am trying to write Eclipse link JPA query for the same as below select pset.psetID from PlanPlanSetDO pse...
user1940878
1

votes
0

answer
94

Views

Spring consuming-ws: Exception: java.net.ConnectException: Connection refused (Connection refused)

I run my spring ws application downloaded from official spring.io web site, and it gives me following error Please help me, cant understand what's problem? P.s: It is consuming web service, building on maven, and 'http://www.webservicex.com/stockquote.asmx?WSDL' works if call via browser
matthew
1

votes
0

answer
34

Views

add multiple same primary key in one row

i have created PromoCode table as follow: PromoCode table: @Entity @Table(name = 'PromoCode', uniqueConstraints = { @UniqueConstraint(columnNames = 'promocode_name', name = 'UK_PromoCode_PromocodeName') }) public class PromoCode { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id;...
Rahul Chavan
1

votes
1

answer
224

Views

Spring Cloud Config server - Logback error

I am creating a client. I use a remote server. The bootstrap file is: spring.application.name=myApp spring.profiles.active=dev spring.cloud.config.uri=https://url.config.server spring.cloud.config.username=user spring.cloud.config.password=pass logging.config=${spring.cloud.config.uri}/${spring.appl...
Xavier
1

votes
1

answer
180

Views

Jackson One-to-many Many-to-One infinite Loop deserialization errors

I have 2 models - Member.java @Entity @Table(name='members') public class Member { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name='member_id') private Integer id; @Column(name='member_name') @NotNull private String name; @Column(name='member_joining_date') @NotNull private Date joi...
Prateek Narendra
1

votes
1

answer
34

Views

video is not fetching completly,

I want to fetch video from mongodb than it should play that video up to video size, but its playing only some second, i gave maxUploadSize is 20mb and maxInMemorySize also 20mb,but on the jsp page, its fetching only 1mb video even video size more than 1mb. I am not getting what to do, video should p...
Laxmi Prajapati
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
0

answer
144

Views

Could not connect secured LDAP server from other PC (CentOS)

I have created an LDAP server on my pc which has both secured and non-secured connections created. I have configured my Spring-MVC application to connect to LDAP servers in both secured and non-secured ways. When I try to connect the LDAP server from MY pc it is working fine. But when I try to conn...
VPK
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
191

Views

The type org.springframework.context.support.GenericApplicationContext cannot be resolved

package test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import config.StudentConfig; import model.Student; public class StudentTest { public static void main(String[] args) { AnnotationConfigApplicationContext Context= new AnnotationConfigApplicationContext(St...
LearnerForever
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
3

answer
372

Views

Spring @Transactional annotation making my class not able to Autowire

I have a class SaveRoute which has got an auto-wired property SaveProcessor. This SaveProcessor class has got a method which is annotated with @Transactional annotation. When I try to run my application, Java is throwing an exception that bean SaveProcessor dependency injection failed. When I remov...
Jewel Jose
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
1

answer
273

Views

How can i access application.yml values at entity class level

I am working on spring boot application and using application.yml file for configuration and looks like: center: setting: beforeCancellationLimit: min: 0 max: 50 maximumBeforeCancellationLimit: min: 0 max: 60 rangeOfCancellation: min: 0 max: 30 I want to access these values into my @Entity level cla...
sawai singh
1

votes
2

answer
35

Views

Using identifiers and values from other places in a Spring CrudRepository

I'm learning how to extend Spring's CrudRepository interface to create a repository for an entity. But I'm having trouble implementing more complicated queries that use values that aren't hard-coded. Here's a contrived example. The HQL is not valid, but it shows what I'm trying to do: import mypa...
J-bob
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
2.1k

Views

How to populate modal window by entity from controller in thymeleaf by ajax query

I want to show a particular user with the help of a materialized modal window by clicking on 'view' button. I'm trying to do this by ajax query to my controller. Also I have an error: There was an unexpected error (type=Internal Server Error, status=500). Exception evaluating SpringEL expression: '...
Vitaly Park
1

votes
1

answer
360

Views

Setting multiple inbound-channel-adapter at runtime

Using spring-integration-sftp, what is the recommended way to create an arbitrary number of inbound-channel-adapter objects? My application needs to monitor multiple remote directories (1 to n), which will not be known until runtime.
Brian K
1

votes
1

answer
244

Views

unable to download the static xml file using spring Rest Controller

Here is my code snippet when i test it from postman, getting the file content but i am expecting file to be downloaded as opening window . @Override   public ResponseEntity downloadXmlFile() {     try {        String FILE_PATH =new ClassPathResource(ApplicationConstants.my_xm...
Nag-Raj
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
1

votes
0

answer
448

Views

Upload big jar file to Google Cloud Appengine

so I am trying to deploy my spring-based application to Google Appengine via Maven plugin. I am getting error, that my jar is bigger then allowed size. [INFO] GCLOUD: ERROR: (gcloud.app.deploy) Cannot upload file [C:\path\core-web\target\appengine- staging\core-web-0.0.1-SNAPSHOT.jar], which has si...
J.T
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
1

answer
1.2k

Views

Spring WebFlux & WebClient make many API calls

Recently I asked question Spring WebFlux create pool of no-blocking threads I got the answer, read link provided, but still don't understand the right way of doing such stuff. I use Spring WebFlux (WebClient) to write my REST service. For each incoming request I make several hundred requests to anot...
Sergey Luchko
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
0

answer
108

Views

Default Enum Constructor Exception In Spring Boot

I have this Enum definition:: public enum PromoUsage { ONLINE, OFFLINE, ONLINE_AND_OFFLINE; } I have another class where i use the Enum like this:: @Embedded @Column(name='promoUsage', nullable=false) @NotNull @Enumerated(EnumType.STRING) private PromoUsage promoUsage; Now when i run my Spring Bo...
Eddy Freeman
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
2

answer
100

Views

Error 404 on SpringMVC using Maven

I keep getting this Error 404 and I've done/looked at almost all the solutions on StackOverflow that are relevant and still haven't fixed my problem. Why am I having this error? When I do http://localhost:8080 it gives me my index.jsp page, but when I do http://localhost:8080/index.jsp of http://loc...
reagan yuan
1

votes
0

answer
77

Views

Spring @WebFilter causes 404 on prod, runs fine on local

I am using a @WebFilter with urlMapping = '/*' option. (Also tried with servlet). I use it to manage my oAuth single sign ons. It runs fine on local with tomcat on eclipse. On prod it throws a 404. Disabling the filter(thus, by passing the filter) works fine. Any pointers anyone? AppConfig.java: @...
dixyantar panda
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
2

answer
814

Views

How to fix role in Spring Security?

I'm trying to use Spring Security in my project, here is the code: @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { // TODO Auto-generated method stub //super.configure(auth); //auth.inMemoryAuthentication().withUser('admin').password('1111').roles('USER'); au...
Abd ELL

View additional questions