gstackoverflow

1

votes
2

answer
1.3k

views

MailConnectException: Couldn't connect to host, port: smtp.sendgrid.net

I have created API key for sendGrid: I have following spring mail configuration: spring.mail.default-encoding=UTF-8 spring.mail.host=smtp.sendgrid.net spring.mail.username=apikey spring.mail.password=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 spring.mail.port=25 spring.mai...
gstackoverflow
1

votes
1

answer
4.1k

views

BeanCreationException: Error creating bean with name 'springApplicationAdminRegistrar'. InstanceAlreadyExistsException

I have 2 spring boot applications. application_A dependsn_on application_B Actually each of applications has main class marked as @SpringBootApplication application_B starts successfully but application_A doesn't start: org.springframework.beans.factory.BeanCreationException: Error creating bean wit...
gstackoverflow
1

votes
0

answer
54

views

How to get test execution report after JUnitCore.runClasses

I have following code to start my class methods in parallel: @Test public void test() throws Exception { Class[] cls = {OrderPlacementCancelTest.class}; Result result = JUnitCore.runClasses(new ParallelComputer(false, true), cls); } I understand that runClasses returns Result but I don't understand...
gstackoverflow
1

votes
1

answer
302

views

Spring oauth2 sso example doesn't work

I am trying to repeat actions described in the official tutorial(Spring Boot and OAuth2) I stuck on the section Hosting an Authorization Server I tried to download all sources from github but result the same I am trying to start sub project social-auth-server: I found 2 starters there: src\main\java...
gstackoverflow
1

votes
2

answer
823

views

How to add security for spring 5 websockets

I followed the following tutorial: Using WebSocket to build an interactive web application Everything works as described and aplication looks fine. I just have a nice controller: @Controller public class GreetingController { @MessageMapping('/hello') @SendTo('/topic/greetings') public Greeting g...
gstackoverflow
1

votes
2

answer
2.2k

views

How to add csrf token to the html form?

After I enabled csrf(removed line .csrf().disable()) in my application my login request stopped working - /login POST redirects me to the home page: request looks like this: On the page I have following js: ... $('#login-form').submit(function (ev) { ev.preventDefault(); // to stop the form from sub...
gstackoverflow
1

votes
0

answer
1.2k

views

MissingCsrfTokenException: Could not verify the provided CSRF token because your session was not found

I am reading the spring documentation: Adding CSRF to Stomp Header And I try to add stom header to the connect event but I get the error on client: >>> CONNECT XSRF-TOKEN:f86232c1-e877-46e9-b4e6-7427c3d89940 accept-version:1.1,1.0 heart-beat:10000,10000
gstackoverflow
1

votes
0

answer
219

views

How to authenticate one microservice into another(spring cloud)

I am learning microservice architecture and currently I have following architecture: User can access as hello-service as hello-world-service. It is clear for me how to implement user authorization using oauth2. For achieve it I use oauth2 (spring-security-oauth2). But it is not clear for me how to...
gstackoverflow
1

votes
1

answer
206

views

How to run method on startup and schedule according the the cron expression and avoid parallel execution

I want to run job every day at 14:00. Also I want to run that job after application startup. This job is long enough(lets say 10 min) and I am afraid what happens if startup happens at 13:58. I want to forbid concurrent task execution. Will the below work? @Scheduled(cron = '0 14 * * *') public voi...
gstackoverflow
1

votes
1

answer
115

views

java.sql.SQLException: Field foreign_key doesn't have a default value

I have following model structure: @Entity @Table(name = 'MY_TEMPLATE') public class MyTemplate { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = 'ID', nullable = false, updatable = false) private Long id; @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn(...
gstackoverflow
1

votes
2

answer
280

views

Should I mark spring mvc DTO with Serializable? [duplicate]

This question already has an answer here: Spring MVC - should my domain classes implement Serializable for over-the-wire transfer? 4 answers We develop very usual spring MVC application We have: Controller layer (@RestComtroller + @GetMapping and @PostMapping) Service layer(@Service) Repository lay...
gstackoverflow
1

votes
1

answer
29

views

How to get full sql script with replaced wild cards in jdbcTemplate?

I have following code public class Foo{ private final NamedParameterJdbcTemplate nJdbcTemplate; public void bar(....){ String query = 'INSERT INTO .... .... nJdbcTemplate.batchUpdate(query, mapSqlParameterSourcesArray); } } I want to get full , valid insert SQL script to insert it into another datab...
gstackoverflow
1

votes
1

answer
313

views

How transmit parameters from href by not method GET? [closed]

How transmit parameters from href by not method GET? I use spring. maybe spring tools can to help me? by method get: ${candidate.name} candidate.id transmit by get method How transmit candidate.id by Post(for example method)?
gstackoverflow
1

votes
1

answer
74

views

different validation politic for inhertiance classes

How to configure different validation politics for so classes: @MappedSuperClass public class Base{ @Size(min=4) String name; } and so: public class Child extends Base{ @NotBlank String surname; } If I create Base class I want switch off validation. But if I create Child class I want switch on valid...
gstackoverflow
1

votes
3

answer
5.3k

views

HTTP Status 500 - Request processing failed; nested exception is org.hibernate.HibernateException: No Hibernate Session bound to thread

I write test spring application. I have problem. my java code: controller method @RequestMapping(value = '/index') public String setupForm() { mainService.getAllRecords()); } service interface @Transactional public interface MainService { public List getAllRecords(); } service impl @Service('mai...
gstackoverflow
1

votes
1

answer
762

views

How does polymorphism work for inner classes?

When I tried to understand how to works collections in java I had understood that I don't understand how polymorphism works for inner classes. Simple code example: class Parent { public static void main(String[] args) { new Parent().newInnerClass().myMethod(); new Child().newInnerClass().myMethod();...
gstackoverflow
1

votes
1

answer
697

views

java. redeclare class field within class initializer and local variable within method nested block(framed braces) differences

I prepare for scjp exam and noticed surprising behaviour for me. public class Test { int k; { int k; // it is valid variant } public static void main(String[] args) { int kk; { int kk; // NOT VALID.java: variable kk is already defined in method main(java.lang.String[]) } } public void method (int va...
gstackoverflow
1

votes
1

answer
55

views

All variants method overriding

Consider the scenario where we have two classes related by inheritance class Parent { } class Child extends Parent{ } If Parent declares a method with folowing signature: public String method(Number n) / /parent 1 I know that in Child I can declare method with following signature(should be ov...
gstackoverflow
1

votes
1

answer
59

views

Different policy for wild card and generic class/method declaration. Why?

I have read a lot of information generics and I have knew a lot of new information. But I have some misunderstandings. Misunderstaning #1 I can write class MyClass {} and I can write: List
gstackoverflow
1

votes
1

answer
2.9k

views

apache commons I/O. How to filter files by wildcard?

I have following files in directory: error.log error1.log Somename.log.trololo AnotherName.logarifm I want that following files will be in array: error.log error1.log Somename.log.trololo I wrote following code: FileFilter fileFilter = new WildcardFileFilter('*.log.*|*.log$'); File[] files = source...
gstackoverflow
1

votes
2

answer
121

views

executor service. how to await while all threads will terminate

Please help to understand concurrency problem. I have following code for thread execution: public void startPool(final Processor processor, Configuration config) { ExecutorService pool = Executors.newFixedThreadPool(config.getThreadPoolSize()); for (final String source : config.getSourcePaths()) {...
gstackoverflow
1

votes
2

answer
338

views

What happens when I wrap I/O streams twice?

I know that java I/O uses decorator pattern. But I feel that I understand its wrong. Please clarify difference between two code snippets: snippet 1: PipedInputStream pipedInputStream = new PipedInputStream(); PipedOutputStream pipedOutputStream = new PipedOutputStream(); pipedOutputStream.connect(pi...
gstackoverflow
1

votes
1

answer
82

views

Who manages System.in/System.out opening/closing?

It is known fact that System.in and System.out is a InputStream and PrintStream respectively. Thus it is a java.io Streams. When we work with streams we should open and close its. Also we should to catch a lot of exceptions. When we work with System.in and System.out we spared from these activitie...
gstackoverflow
1

votes
1

answer
635

views

How to alert message about file upload(using ajax) completition?

I use following form to file upload: and following ajax to send content to server. $('.file').click(function(){ var formData = new FormData($('#imageUploadForm')[0]); $.ajax({ url: 'uploadImage', //Server script to process data type: 'POST', success: alertSucces, data: formData, cache: false, conte...
gstackoverflow
1

votes
1

answer
369

views

cannot find symbol symbol: class NestableRuntimeException location: package org.hibernate.exception

I have following maven dependency in my pom.xml: org.hibernate hibernate-core 3.6.3.Final But after project compile I see following message: cannot find symbol symbol: class NestableRuntimeException location: package org.hibernate.exception P.S. I tryed to change hibernate version to 4.3.7.Final B...
gstackoverflow
1

votes
1

answer
87

views

How does underscore replace variables?

I have following row in code: terminalsListHtml += this.compiled(_.extend(this.terminals[i], {clazz: 'all'}, obj)); Behaviour of execution this row is surprising for me. I evaluate argument value of this.compiled method. It looks like this: more details: compiled: _.template($('#terminal-template')....
gstackoverflow
1

votes
1

answer
52

views

How to avoid redundant catching exceptions of mocked methods which can throws exceptions according interface

I have following code in my unit test: when(workspaceMock.getNamespaceRegistry()).thenReturn(namespaceRegistryMock); method getNamespaceRegistry can throws IOException In terms of java mentioned row is method call and I should to catch it. But on another hand I understand that this method cannot...
gstackoverflow
1

votes
2

answer
96

views

Table doesn't reset when click on X

I have following javascript: $(function(){ $table = $('#myTable') .tablesorter({ theme: 'blue', widthFixed: true, headerTemplate: '{content} {icon}', widgets: ['zebra','filter'], widgetOptions: { zebra: ['even', 'odd'], // filter_anyMatch replaced! Instead use the filter_external option // Set to us...
gstackoverflow
1

votes
2

answer
476

views

Encoding issue while spring message source using in idea

I have resource bundle property file with following content: OwnerImagesController.TerminalContentFormatIsNotAcceptable = \u0424\u0430\u0439\u043b \u0438\u043c\u0435\u0435\u0442 \u043d\u0435\u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 In idea conf...
gstackoverflow
1

votes
1

answer
50

views

How to read date from two different inputs?

I render my field on jsp into two inputs like this: Now I want to read date into same single Date object into my controller.
gstackoverflow
1

votes
2

answer
80

views

reflection. How to know sibling field value?

I have following class: class CampaignBeanDto { Date startDate; @MyAnnotation Date endDate; } I need the reference to field endDate I should know which value has value startDate for same instance
gstackoverflow
1

votes
2

answer
629

views

jsp include doesn't work for jspf files under tomcat 8 but works under the jetty

I have the following jsp: ... ... When I open following jsp when application run under the tomcat 8 I see that my include replaces with empty string. When I run application under the jetty - it renders good. As I undestand the problem related with format of included file because I don't see problem...
gstackoverflow
1

votes
1

answer
110

views

ResourceNotFoundException on existing path

I have the following class: public class EmailService { static { Velocity.setProperty('resource.loader', 'class'); Velocity.setProperty('class.resource.loader.class', 'org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader'); Velocity.init(); } public void sendTerminalModerationStatusCh...
gstackoverflow
1

votes
2

answer
64

views

tableSorter custom date parser doesn't work

I have the following table sorter configuration: $(function () { $.tablesorter.addParser({ id: 'customDate', is: function(s) { //return false; //use the above line if you don't want table sorter to auto detected this parser //else use the below line. //attention: doesn't check for invalid stuff //20...
gstackoverflow
1

votes
1

answer
138

views

Wrong column filtering for date column

I use tablesorter to sort columns. But I found the following issue: As you can see the second row doesn't have 16. This table also have the external search field and search result equals 1 if I type 16, thus second row doesn't show. But it lools like a tablesorter bug. html source: .... 1 16.06.201...
gstackoverflow
1

votes
2

answer
2.9k

views

How to start immediate = false component?

I have following component: @Component( label = 'Service name', description = 'Service description', metatype = true, immediate = false) @Properties({ @Property( label = 'My Label' name = 'property-name', value = 'my value', propertyPrivate = true ) }) @Service public class SampleServiceImpl impleme...
gstackoverflow
1

votes
1

answer
59

views

Why does my multithreaded code leads to hang?

I study java concurency. I am trying to estimate time execution depends on thread count(read and write) my code: public class Task5 { public static int [] readerThreadCount = {1,10,100,1000}; public static int [] writerThreadCount = {10, 1000, 1000000}; public static void main(String[] args) throws...
gstackoverflow
1

votes
1

answer
961

views

How to start threads at the same time when I use executors?

I have wrote following code: ExecutorService es = Executors.newCachedThreadPool(); long start= System.currentTimeMillis(); ArrayHolder arrayHolder = new ArrayHolderBySynchronized(); List runnables = new ArrayList(); for (int i = 0; i < readerThreadCount; i++) { es.submit(new ArrayReader(...
gstackoverflow
1

votes
2

answer
1.3k

views

Spring defaultHtmlEscape doesn't prevent xss attack

I want to prevent xss attacks in my spring application. I added defaultHtmlEscape true into my web.xml (I found this soulution here) but on my page I save content with name alert(1); and this scripts executes after page refresh. client side code: $.ajax({ type: 'POST', url: 'setContentName', da...
gstackoverflow

View additional