This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!

Atul More

Ranch Hand
+ Follow
since Dec 26, 2016
Atul likes ...
Java jQuery Spring
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
12
Received in last 30 days
1
Total given
6
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Atul More

Hi,

Just started working on HSQLDB. The insert statement wont work. I am creating memory(mem) db for HSQLDB.
Can somebody help:
HSQLDB created:

HSQLDB - Table created


Connection to DB:


Prepared statement code:


After running this code, it is showing below error:


HSQLDB JDBCDriver Loaded
HSQLDB Connection Created
Connection Obtained
java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: TOKENS in statement [insert into tokens(TOKEN) values (?)]
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
at HSQLDBCrud.insertToken(HSQLDBCrud.java:18)
at HSQLDBCrud.main(HSQLDBCrud.java:31)
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: TOKENS
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ParserDQL.readTableName(Unknown Source)
at org.hsqldb.ParserDQL.readRangeVariableForDataChange(Unknown Source)
at org.hsqldb.ParserDML.compileInsertStatement(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
... 4 more



I am using HSQLDB 2.4.1 version.

Thanks,
Atul
Hi Rob,

Thanks for inputs.
I changed the approach and now I used JWT for authenticate/authorization.
The web application and spring boot serivce now communicate via JWT token.

Thanks,
Atul
3 weeks ago
Hi,

I have a web application, spring boot service.
I called a service of spring boot from my web application. The spring boot service return me a json given below.


[{"createdby":"ats","updatedby":"ats","createddate":"2019-04-01 09:27:03","updateddate":"2019-04-01 09:27:03","id":1,"address1":"ABC","address2":"STN","mobile":"111111111","email":"a@a.cp","status":false}]



When I pass this json string to UI from my web application, it again converts to array like.


[[{"createdby":"ats","updatedby":"ats","createddate":"2019-04-01 09:27:03","updateddate":"2019-04-01 09:27:03","id":1,"address1":"ABC","address2":"STN","mobile":"111111111","email":"a@a.cp","status":false}]]



THe web application also configure with @RestController and the web api also exposed.

I am using ObjectMapper class to convert the object to json string.

I have tried couple of things like


this.configure(SerializationFeature.WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS, false);



But it wont work.

Is there any way to not convert already converted array into another array.

Thanks,
Atul
3 weeks ago
Hi,

Thanks for response.
As per the documentation "HTTPSession - allows replacing the HttpSession in an application container (i.e. Tomcat) neutral way, with support for providing session IDs in headers to work with RESTful APIs."
What is this then?

Thanks,
Atul
1 month ago
Hi,

I am working on a application in which I have a kind of architecture where I have a web application and multiple microservices.
Everything is built on Spring 5 and microservices are built using spring boot 2.1+

I have used spring security for authentication/authorization purpose. This security implementation is at web application layer. Its basic authentication mechanism using jdbc.
I am also using spring session to share the session information among the services.

I am able to integrate it with web application as well as with microservices.

The problem occurs when I am passing the SESSION from web application to any microservice. Below is the code I am using to set the SESSION information and then add it to RestTemplate to call a service.




I am passing SESSION form cookie to the microservice. It hits the url which I configured but it return me 401 from the microservice.

I have configured the microservice with spring security and spring session. The code is in microservice is:







The filter logs from microservice, related to security filters are:

2019-03-21 23:37:15.476  INFO 8468 --- [  restartedMain] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@60bec07d, org.springframework.security.web.context.SecurityContextPersistenceFilter@537790d1, org.springframework.security.web.header.HeaderWriterFilter@25cf5c91, org.springframework.security.web.authentication.logout.LogoutFilter@591877b1, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@5497ede1, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@5f517baa, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@2ed09ded, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@5e06fa8e, org.springframework.security.web.session.SessionManagementFilter@60cb0c42, org.springframework.security.web.access.ExceptionTranslationFilter@6309dacf, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@5ec4f775]


The microservice does not create filter for springSessionRepositoryFilter which handles the spring session.
Why it is no there in the list of filters?

I am able to connenct to Redis from web and microservice.

Can anybody tell me what the issue is?

How to pass SESSION to the microservice from web application.

Thanks,
Atul
1 month ago
1. While making update to version, make sure you have version present in the Maven repository.
2. Also make sure while making the changes to the certain module, make sure other modules which are used by this module or by application also get updated or compatible with it.(This is my personal observation, kind of problem I have also faced)
6 months ago
As the spring boot followed the new servlet specifications, where we don't need to define web.xml file.
You can configure all these things which you mentioned(in web.xml) through java files as well.
6 months ago
Hello Campbell,

Its atomic, sorry its my mistake.
Atomic is mainly working on the principal of CAS (Compare And Swap).
By using the Read and Write lock mechanism, the only thing I want to understand is, how DB operation we manage like account debit/credit. Multiple threads reading the value and writing as well.

Thanks,
Atul
Hi,

It is basic question but I am not yet work on kind of functionalities. So asking this question.
Can I use "automic" variable in "ReadWriteLock" mechanism? Is it right ?

Thanks,
Atul

6 months ago
Hi,

A code I finished one task where I need to find a maximum sentence from a given sentece.
The scenario is like, let say you have a sentence: I am Atul More. I am a Java developer.
So again divide the sentence on to the basis of full stop(.). So they are two different sentence I am Atul More and I am a Java developer.
After that I need to find out the max length string from them. So the answer is: 5 for I am a Java developer.

The code is dine but have a couple of questions:
1. Is the approach is right?
2. Can I make it reduce the code by merging two line os code or something.

The code is as below:


Thanks,
Atul
6 months ago
Hi,

I am able to solve the issue. Now getting the desired result.




Thanks,
Atul
7 months ago
Hi,

Thanks Camplbell.

Well done


Am I deserving a cow in that case ...  
(Kidding   )

You might consider line 8 as ....collect(Collectors.toList())


Yes ... Thats also work.

Thanks,
Atul
7 months ago
Hi Campbell,

Thanks for your inputs and help. The required solution is as below:



Now it is returning me the expected result: {4, 9, 6}

Thanks,
Atul
7 months ago
Hi,

Line no.2 returning me

java.util.stream.ReferencePipeline$Head@3d075dc0
java.util.stream.ReferencePipeline$Head@214c265e
java.util.stream.ReferencePipeline$Head@448139f0



Just need help how can I process each one.
Integer or Long does not matter but need some help to do it.

Thanks,
Atul
7 months ago
Hi

If I use map then it return me soemthing like:


java.util.stream.ReferencePipeline$Head@3d075dc0
java.util.stream.ReferencePipeline$Head@214c265e
java.util.stream.ReferencePipeline$Head@448139f0



7 months ago