Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

Joda-Time is a great library if you can't use Java 8 in your project. If you happen to be using version above 1.2.1.2 with your web service and deploying to WebLogic 12c (12.1) you will likely get java.lang.NoSuchMethodError exceptions. This is how to fix it.

In my case I was getting an exception like this...
 Exception
java.lang.NoSuchMethodError: org.joda.time.format.ISODateTimeFormat.localDateParser()Lorg/joda/time/format/DateTimeFormatter;


Strange I thought because I had joda-time-2.9.3.jar in my WEB-INF/lib directory.

It turns out that WebLogic comes with an old version of Joda-Time library, in my case it was the 1.2.1.2 version which I found at the following location...
 WebLogic Library
$WL_HOME/wlserver/modules/joda.time_1.2.1.2.jar


The fix is easy, just force your web service to use the jar file that you bundle inside the WEB-INF/lib directory. To do this you need to set prefer-web-inf-classes to true in the weblogic.xml file. Below is an example.
 weblogic.xml
<?xml version="1.0" encoding="UTF-8" ?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>




After making this change and redeploying everything should work as expected.

-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.