Started to learn “Spring in Action” and got a trouble on the very first chapter. I have simple Spring application, built with Maven: pom.xml I have XML application context where I define three beans: As yo see I’ve tried to inject invocations of two particular methods before and after method…
IndexNotFoundException[no such index]
I was running my first elasticsearch test case, I am using Java as the solution perspective to do elasticsearch experiment. it works perfectly fine in eclipse Debug Mode, the debug mode result: But when I try this on in normal Run application mode, I am getting the following exception and I have no idea at al…
Substituting parameters in log message and add a Throwable in Log4j 2
I am trying to log an exception, and would like to include another variable’s value in the log message. Is there a Logger API that does this? Answer Have you tried looking at ParameterizedMessage? From the docs Parameters: messagePattern – The message “format” string. This will be a St…
How to get response body in Zuul post filter?
How it is possible to read a response body while using Zuul as a proxy in post filter? I am trying to call the code like this: Answer I’ve managed to overcome this. The solution consists of 4 steps: Read ctx.getResponseDataStream() into a ByteArrayOutputStream Copy OutputStream to 2 InputStreams. Use on…
how to get Indian Time Standard from in java?
I want to know date and time in Indian standard time and I don’t want to use my system time and date. I have never used Network Transfer Protocol (NTP) but by browsing through internet i think ntp can do the jop. Answer An easier option might be to use JodaTime, so that you could do something like this
How to create Fuzzy Logic rules or model in Java
I have been given a new task in my new job, basically, I have to create a “model” to predict future data. I have been told Fuzzy Logic is the best way to do this, and I use Java almost every day, so I would prefer to use it here too. I have searched for information about Fuzzy Logic and
javadoc @hide can’t work
According to the link, i wrote the following code: When i use the command to generate the doc: The doc still have the myMethod item. So how to hide the myMethod? What did i miss ? Answer You are using a Doclava tag, but are generating the API documentation using the standard doclet. Building Doclava The Docla…
junit test for stateless ejb + jpa
I would like to write a junit test for my stateless ejb + jpa demo code. I think it is actually not a junit test, it is an integration test. I have a stateless ejb with an injected EntityManager and PostgreSQL database server is used. I use CDI (Spring is not used in my project) and EclipseLink with a persist…
What the difference between iCal4j/biweekly and google-rfc-2445?
Right now I’m using google-rfc-2445 library to evaluate recurring events, and generate actual dates, for example to know when will occur event defined by following RRULE: RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1 I’m using biweekly library to generate *.ics files. Actually it does same a…
Java cooperating generic classes: can we avoid unchecked cast?
I have two abstract generic classes. They cooperate and hence depend on each other. Occasionally one needs to pass this to the other. I am trying to find a type safe way to do this: My question is whether I can find a cleaner way so I avoid the unchecked cast in AbstractB.setA(). I had hoped to declare it set…