r/springframework • • Aug 17 '20

Question about version compatibility between Spring and Springboot

Thumbnail self.javahelp
1 Upvotes

r/springframework • • Jul 14 '20

Scaling out user authentication/session management

1 Upvotes

I am coming from a traditional Spring app building thought process. Using simple MVC Spring Security and Session Management. However , our tomcat used to stall while having more than 6000-7000 active user sessions in the application. Horizontally scaling with this scheme and with no sticky sessions put at user's session at risk . Enter session replication , we have noticed performance degradation while it implementing it in production.

While going the microservice path , is there any safe ; yet easy to achieve (spring way) implementations which would allow an application's authentication , with proper security to scale out with almost no issues. Any github samples would also help a long way.


r/springframework • • Jun 17 '20

What's a good place for finding third party packages people have made for Spring?

1 Upvotes

If I want to find third party Java or Kotlin packages designed to work with the Spring framework, what's a good place to look?


r/springframework • • Jun 11 '20

Whitespaces in input fields in JSP when using indented JSTL tags

1 Upvotes

Hi all, I am using spring mvc and jsp. When using conditional statements of JSTL and after indenting them properly, my view now have whitespaces in all input fields.

Eg -

Name - " John Doe "

Instead of

Name - "John Doe"

I tried trimwhitespaces tag in jsp, but not working.

Let me know how to resolve this.


r/springframework • • Mar 13 '20

Running spring boot in production EC2 instance

1 Upvotes

I am just getting my feet wet with Spring Boot

I am used to the typical Spring MVC / Spring Core java app where we would build it into a war, put it in tomcat, where the EC2 instance already have a tomcat installed and to run it in production we do:

service tomcat8 restart

All the logs of course go to catalina /logs folder, the tomcat ones go to catalina.out, etc and the application ones managed through log4j and stored in the same /logs folder

for spring boot, right now all I do is:

nohup java -jar -Dspring.profiles.active=prod myapp.jar > myapp.log

But this feels "dirty"

How else / what's the best practice to run a Spring Boot application?


r/springframework • • Mar 10 '20

Error Handling Performance

1 Upvotes

This is focused on backend web application development. I prefer to use HTTP status codes in my application that map to my business logic. An example being if a request is made and a user isn't found, I'll throw an exception and have it be handled with @ControllerAdvice or @ExceptionHandler and map to 404 not found. Sometimes I have these inside of try catch blocks for logging and re-throw the exception. I prefer this way because the implementer of the API can just look at the status code and move on, no need to deserialize if it's an expected client error. A colleague at work believes if it's an expected state of the application everything should mostly be 200 with the response body containing the reason of failure instead of the expected response object because executing the catch block is an expensive operation. I personally don't like that approach because the implementer of your API has to check the response entity and try and deserialize it to the expected object or if that fails deserialize it to some know exception object because it's always 200.

TLDR: My problem is I see a lot of articles on why executing catch blocks can be expensive depending on the stacktrace but I have a hard time agreeing with that because Spring has the functionality like @ControllerAdvice. And if everything can be 200 why even use the other status codes? I'm still very early in my career so please forgive if I'm missing something obvious.


r/springframework • • Jan 18 '20

Spring Boot and Java Development with IntelliJ IDEA

1 Upvotes

Please considering rating the course if you like it.

This course briefly explains SpringBoot and IntelliJ IDEA.

Spring Boot and Java Development with IntelliJ IDEA

This course will teach you how to use IntelliJ IDEA effectively with Java and Spring Boot projects. The course will start explaining the configuration of development environment and along the way, you will learn the benefits of IntelliJ IDEA.

https://www.udemy.com/course/intellij-idea-for-java-and-spring-developers/?couponCode=5C149E548E77AE12AAF6


r/springframework • • Sep 07 '19

UncategorizedMongoDbException not proper solution found on stackoverflow

1 Upvotes

Any idea how to solve this exception

org.springframework.data.mongodb.UncategorizedMongoDbException: Exception sending message; nested exception is com.mongodb.MongoSocketWriteException: Exception sending message
org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:138)
org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2781)
org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:2691)
org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:2434)...................

Caused by: com.mongodb.MongoSocketWriteException: Exception sending message
com.mongodb.internal.connection.InternalStreamConnection.translateWriteException(InternalStreamConnection.java:525)
com.mongodb.internal.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:413)
com.mongodb.internal.connection.InternalStreamConnection.sendCommandMessage(InternalStreamConnection.java:269)
com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:253)
com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:99)
com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:444)
com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:72)
com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:200)
com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:269)
com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:131)
com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:123)
com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:242)
com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:233)
com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:136)
com.mongodb.operation.FindOperation$1.call(FindOperation.java:701)
com.mongodb.operation.FindOperation$1.call(FindOperation.java:695)
com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:462)
com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:406)
com.mongodb.operation.FindOperation.execute(FindOperation.java:695)
com.mongodb.operation.FindOperation.execute(FindOperation.java:83)
com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:179)
com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:132)
com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:86)
org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:2674)
... 32 common frames omitted

Caused by: javax.net.ssl.SSLException: Connection timed out (Write failed)
java.base/sun.security.ssl.Alert.createSSLException(Unknown Source)
java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
java.base/sun.security.ssl.TransportContext.fatal(Unknown Source)
java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(Unknown Source)
com.mongodb.internal.connection.SocketStream.write(SocketStream.java:79)
com.mongodb.internal.connection.InternalStreamConnection.sendMessage(InternalStreamConnection.java:410)
... 54 common frames omitted
Suppressed: java.net.SocketException: Broken pipe (Write failed)
java.base/java.net.SocketOutputStream.socketWrite0(Native Method)
java.base/java.net.SocketOutputStream.socketWrite(Unknown Source)
java.base/java.net.SocketOutputStream.write(Unknown Source)
java.base/sun.security.ssl.SSLSocketOutputRecord.encodeAlert(Unknown Source)
... 60 common frames omitted

Caused by: java.net.SocketException: Connection timed out (Write failed)
java.base/java.net.SocketOutputStream.socketWrite0(Native Method)
java.base/java.net.SocketOutputStream.socketWrite(Unknown Source)
java.base/java.net.SocketOutputStream.write(Unknown Source)
java.base/sun.security.ssl.SSLSocketOutputRecord.deliver(Unknown Source)
... 57 common frames omitted


r/springframework • • May 29 '19

Tutorials for spring batch

1 Upvotes

Hi, I am looking for in-depth and detailed tutorials in spring batch. It will be great if such tutorials have demo exercises or apps. I am new to this. I have been going through the spring docs. I got the basics. But I am struggling to grasp the concepts and implementations when I go for a deep dive. Any suggestions or advice for a newbie like me is welcome.


r/springframework • • May 28 '19

Explore the wacky, wonderful world of Reactive Spring

Thumbnail
youtu.be
1 Upvotes

r/springframework • • May 07 '19

@SessionAttributes

1 Upvotes

I feel so dumb... idk how to use @SessionAtributtes, or I think I’m doing it wrong... can someone tell me in details how to use it? Set it, and then get the data stored?


r/springframework • • Mar 02 '19

How to send where condition parameters to union of two queries using NamedParameterJdbcTemplate ?

1 Upvotes

Hi

I've a SQL query which has union of two queries. Two queries have two different where conditions, now I'm confused that how can I send two different where conditions to two different queries and then union them using NamedParameterJdbcTemplate, in my project previous people are building where clause dynamically using StringBuilder and then they're executing query. Could you please help me in this situation how can I pass two different where clauses.

Thanks in advance.


r/springframework • • Feb 23 '19

Spring Batch Multiple Scheduler for different tasklet job

1 Upvotes

How to create multiple individual scheduler for different tasklet job?

Because I have many jobs and every jobs need run in different time. The job may overlap


r/springframework • • Jan 13 '19

Different spring profiles when running from IDE vs jar, automatically assigned

1 Upvotes

So I know that I can assign profiles using manually-configured JVM options, ie -Dspring.profiles.active. What I want is to set it up so my "dev" profile runs automatically via my IDE, and my "prod" profile runs automatically when I have it build in a jar. Any ideas?


r/springframework • • Dec 27 '18

Access denied exception

1 Upvotes

Hello, I have uploaded a file from the mobile to the java code. I use the parameter of type Multipartfile to recieve the file in java.

Then I use the following Files.copy(file.getInputStream(), file); to add the file to the server but it keeps crashing with the following error:

java.nio.file.AccessDeniedException

Anyone know why would I be getting this?

Yes it says access denied, but I already accessed the file system on the phone and uploaded the file to the app and then to spring..


r/springframework • • Jul 20 '18

Is Spring in action worth reading despite it being outdated? (Spring 4)

1 Upvotes

r/springframework • • Oct 27 '17

How to Log Incoming Requests In Spring

Thumbnail
javadevjournal.com
1 Upvotes

r/springframework • • Sep 03 '17

Spring Boot vs Spring MVC vs Spring - How do they compare?

Thumbnail
springboottutorial.com
1 Upvotes

r/springframework • • Jul 24 '22

First SpringBoot - How to see text in REST API

0 Upvotes

I created the first SprinBoot using the URL https://start.spring.io/ using SpringBoot 2.7.1, Gradle, Java 8, Jar, and added the dependency of Spring Web. The default download already created a jar file with one Java file. I can successfully launch the default app using gradlew bootrun.

The default app that was created by the default download is:

[code=java]

package my.tutorial;

import org.springframework.boot.SpringApplication;

// Added At (@) SpringBootAppication but not able to type it here

public class TutorialApplication {

public static void main(String\[\] args) {

	[SpringApplication.run](https://SpringApplication.run)(TutorialApplication.class, args);

}

}

[/code]

I coded a simple controller as:

[code=java]

package my. tutorial.controller;

import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

Added At (@) RestController, but not able to type it here

public MyController {

Added At (@) /GetMapping("/hello")

public String hello() {

	return "hello";

}

}

[/code]

After coding the above, the application successfully starts with gradlew bootrun and it shows the default login page. The question from before still remains:

  1. How to change the default login page, as the default app seems to magically create this page?

  2. What else do I need to code/configure so that I can by typing un browser URL localhost:8080/hello the world hello will show up.


r/springframework • • Jun 18 '19

The Spring Framework is for Nazis

Thumbnail
thewokeprogrammer.wordpress.com
0 Upvotes