Category Archives: IT Stuff

MappingJacksonHttpMessageConverter not found

I was trying to run a java batch that call an application context without success (it’s a java app that calls a Camel spring context). This is what I get during the startup:

ERROR ApplicationProperties @ addApplicationProperty [28] org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from file [/MessageRouting/src/test/resources/META-INF/spring/LOCALHOST-db-context.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/http/converter/json/MappingJacksonHttpMessageConverter
Fatal error! java.lang.RuntimeException: Error loading ClassPathXmlApplicationContext file - src/test/resources/META-INF/spring/LOCALHOST-db-context.xml

I’m using spring 4.2.3 (updated yesterday, probably the reason for which it doesn’t work. It was 4.0.9). I know that MappingJacksonHttpMessageConverter has been replaced by MappingJackson2HttpMessageConverter but, how can I tell to spring to use the new version???

I followed some suggestion and I added this to my pom.xml:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.6.3</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.6.3</version>
</dependency>   
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.6.3</version>
</dependency>

But this didn’t fix so, I finally resolved the issue adding this dependency to my pom.xml:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>${org.springframework-version}</version>
</dependency>
Tagged , ,

Which log4j configuration are you using?

Sometimes log4j is not working properly and you need to verify where it is actually writing the log entries. This can be easily verified turning on the log4j.debug:

-Dlog4j.debug

It will print to System.out lots of helpful information about which file it used to initialize itself, which loggers / appenders got configured and how etc.

Tagged ,

Looking for new challenge – Day #7

Replied to more than 20 job offers.
No replies.
Too much experience?

If found this article really interesting about the relocation: Relocation? No way! But please, keep requiring it by @alobbs

Consider this, here in Italy the job offers are for something absolutely not interesting (in some case really boring) and / or not honestly payed so, it’s mandatory to find outside Italy. Not a problem, there are a million of job offers, but what if somebody can’t relocate easily? (or can’t relocate at all?) I don’t want to settle and be unhappy for my entire life. I want to do something really interesting and exiting!

Tagged , ,

Parse an unknown JSON with Jquery

Sometime it happens to receive a JSON string than need to be visualized without knowing the structure. Suppose we have an HTML table:

<tbody id="reportTable">					
</tbody>

To populate this table with jQuery it’s possible to use this simple code:

var rows = ${reportRows};
var html = $.each(rows, function(key, value){
 
	$("#reportTable").append("<tr>");
 
	$.each(value, function (key, data) {
		$("#reportTable").append("<td>" + data + "</td>");
	});
 
	$("#reportTable").append("</tr>");
 
});

${reportRows} comes from a Spring MVC Controller and it’s a Java string generates using Jackson (or Gson) in this way:

ColumnMapRowMapper rowMapper = new ColumnMapRowMapper();
List<Map<String, Object>> reportDataList =  getJdbcTemplate().query(sqlComplete, rowMapper);
 
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(reportDataList);

So, we have a query that return a not know number of column (suppose your code dynamically generate the query), we translate the results in JSON and we use jQuery to render the results.

Tagged , , ,

Time to Quit

If you see one of these red flags:

  • being compensated unfairly.
  • being mistreated, undervalued, or disrespected.
  • disagreeing with the fundamental strategy or practices of the company and not being in a position to change them.
  • failing to get along with your manager and your teammates.
  • failing to fit in with the company culture.

read immediately this really interesting post

4 Terrible Questions Job Interviewers Should Never Ask Again

I have been interviewed a lot of time until now, and I can confirm, in some case, the interviewer did something really bad like asking me “Where do you see yourself in three years?” or reading my cv for first time or sending sms and smiling reading them during the interview. I read this article and I found it really interesting and, in particular, I love this:

4. “Out of all the other candidates, why should we hire you?”
Hmm. Since a candidate cannot compare herself with people she doesn’t know, all she can do is describe her incredible passion and desire and commitment and… well, basically beg for the job. (Way too many interviewers ask the question and then sit back, arms folded, as if to say, “Go ahead. I’m listening. Try and convince me.”)

And you learn nothing of substance.

 
Probably my answer would be: I can’t compare me with other candidates… don’t know them.. maybe Steve Wozniak is a candidate for this position: you should be dumbass to don’t hire him! Take him! Right now!

You can find the entire post here: Terrible Questions Job Interviewers – inc.com by @jeff_haden – btw, this article is pure gold!

Nuclear plant vs bikeshedding

From OpenMRS developer guide: “Although we encourage public discussions about our software design, it’s also important to avoid non-productive conversations about trivial details. This type of anti-pattern best described by the concept of bikeshedding, which gets its name from a 1960s book about management. In the book, C. Northcote Parkinson described how it might be often easier to get approval for an expensive nuclear power plant than it could be to discuss what color to paint a bike shed. Everyone feels they have a valid opinion of what color to paint the bike shed, but only certain qualified people can comment on the design of a reactor. Don’t let yourself fall into this trap — avoid these wasteful conversations on trivial topics”.

Kim Jong Un situation

That’s the situation on which you are doing a complicate change in production and the management is waiting (and in the worst case watching you) behind your chair.

“Hey dude, any update about the production deployment??”
“Sorry, can’t talk, Kim Jong Un situation here”

by Andrea Girardi – Fri 19, 2014

Kim Jong Un situation

PS: if you like it please, click on the banner :)

Query date based using milliseconds time on MongoDB

I need to search all records that match a date condition. On MongoDB I’ve a bunch of data like this:

{
    "_id" : "9ed3b937-0f43-4613-bd58-cb739a8c5bf6",
    "userModels" : {
        "5080" : {
            "generated_date_timestamp" : NumberLong(1413382499442),
            "model_id" : 5080,
        },
    }
    "values" : {}
}

With this query, is possible to do date / time based search:

db.anonProfile.find({ 
   "userModels.5080.generated_date_timestamp" : 
      { 
         "$gte" : ISODate("2013-10-01T00:00:00.000Z").getTime() 
      }
});
Tagged

Multiple COUNT select from same table

I fixed the issue in this way:

SELECT R.id_request,
    (SELECT COUNT(*) FROM Flow F 
        WHERE F.id_request = R.id_request AND processStatus = 1) AS flowTotal,
    (SELECT COUNT(*) FROM Flow F 
        WHERE F.id_request = R.id_request AND processStatus = 2) AS flowApproved
FROM Request R
Tagged