Tuesday, December 25, 2018

How to post json string for datatables framework

By default, the Ajax request that DataTables makes to obtain server-side processing data is an HTTP GET request. However, there are times when you might wish to use POST. This is very easily done by using the type option of the ajax initialisation option. Naturally, you might want to post your data as a json string within the body of this ajax call. Here comes the important attributes of the ajax option for that scenario.
$('.my-datatable-div').DataTable( {
  "ajax": {
    "contentType": "application/json",
    "type": "POST",
    "data": function(d) {
      return JSON.stringify({"languages" : ["javascript","golang"]});

Thursday, July 26, 2018

XML-20116: (Warning) Entity already defined, using the first definition.

I’ve been pulling my hair out seeing the following error message while trying to make a simple XSLT transformation in my spring application.
XML-20116: (Warning) Entity 'tablemodel' already defined, using the first definition.
 at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:425)
 at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:290)
 at oracle.xml.parser.v2.XMLReader.scanNameChars(XMLReader.java:1306)
 at oracle.xml.parser.v2.XMLReader.scanQName(XMLReader.java:2204)
 at oracle.xml.parser.v2.XMLExternalReader.scanQName(XMLExternalReader.java:404)
 at oracle.xml.parser.v2.NonValidatingParser.parseAttrDecl(NonValidatingParser.java:1024)
 at oracle.xml.parser.v2.NonValidatingParser.parseAttlistDecl(NonValidatingParser.java:989)
 at oracle.xml.parser.v2.NonValidatingParser.parseMarkupDecl(NonValidatingParser.java:819)
 at oracle.xml.parser.v2.NonValidatingParser.parseMarkupDecl(NonValidatingParser.java:843)
 at oracle.xml.parser.v2.NonValidatingParser.parseDoctypeDecl(NonValidatingParser.java:644)
 at oracle.xml.parser.v2.NonValidatingParser.parseProlog(NonValidatingParser.java:435)
 at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:393)
 at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:236)
Even though I’ve explicitly instructed my app to use Saxon library, obviously xml parser from oracle gets in the way, but why? It turns out that when you bring the oracle jdbc driver dependency via maven using Oracle's maven repo, it transitively gets other libraries which causes this problem when parsing the XMLs. I just excluded the transitive dependencies for the oracle driver and everything works just fine. I don't think those extra libs are necessary at all at runtime. If you have this in your pom:
Just exclude the transitive dependencies for the oracle driver and everything works just fine.
This is the dependency tree by the way
  • ojdbc7 :
  • xdb6 :
  • orai18n :
  • xmlparserv2 : -> obvious culprit
  • oraclepki :
  • osdt_cert :
  • osdt_core :

Happy coding!

Saturday, July 21, 2018

Maven error - Credentials cannot be used for NTLM authentication

I've been using CNTLM to access the resources on the internet through corporate proxy. Recently, I started getting the following error messages from maven.
  • WARNING: NEGOTIATE authentication error: No valid credentials provided (Mechanism level: No valid credentials provided (Mechanism level: Failed to find any Kerberos tgt))
  • WARNING: NTLM authentication error: Credentials cannot be used for NTLM authentication: org.apache.maven.wagon.providers.http.httpclient.auth.UsernamePasswordCredentials
After some investigation, I found out that wagon-http-lightweight artifact has to be overridden in maven configuration. I was able to do this by placing wagon-http-lightweight-2.2.jar file into $M2_HOME\lib\ext folder I'm using maven version number 3.5.2. I haven't checked it with other versions. This artifact can be downloaded from here

Wednesday, February 14, 2018

Shopify dashing - swiping jira issues widget

Based on Matt Snider's dashing widget and Swiper from iDangero.us

See it live here as part of a complete Agile Dashboard, with some cartoon sugar :)

Source code can be accessed here

Tuesday, February 6, 2018

Shopify dashing - How to avoid list widget flickering

Please note that the live demo cannot be viewed on IE because dashing does not support IE, either. Because basically Dashing relies on "Server Sent Events"

How to convince MUnit Maven Plugin that you have an enterprise license

Let's say you have an enterprise license for Mule Runtime and you'd like to see the coverage report for your unit tests in a CI environment like Jenkins or Bamboo. You configured everything in your pom.xml as described in the documentation but you keep seeing the following message.

[INFO] [CoverageManager] Coverage feature runs over EE runtime only. Feature is shut down

OK, you need to convince the plugin that you're an enterprise customer but how?

Surprisingly very simple, but hard to find out unless you do some reverse engineering because this information is not documented, or let's say was not documented last time I checked.

just make sure that you don't have the following community artifact dependency in your pom.xml


and instead, you have this enterprise artifact dependency


Tuesday, August 13, 2013

mapping XML to Java objects without XSD

There is a common misconception that JAXB requires an XML Schema

Until I read the following blog post, JAXB xjc Java Generation with DTD, I was also thinking that there was no binding solution for DTDs when you try to map XML content into Java objects. 

For that reason, while maintaining some legacy applications using DTD, I was being forced to write my own parser(using SAX generally) for each different XML structure.

Luckily, although not part of the JAXB specification, the XJC tool offers the ability to generate Java classes from a DTD.

Simply execute the following command in your console, 

"%JAVA_HOME%\bin\xjc" -dtd -d generatedsrc -p the.target.packagename sample.dtd

Sample DTD File : Product Catalog
 <!ENTITY AUTHOR "John Doe">

 <!ENTITY COMPANY "JD Power Tools, Inc.">

 <!ENTITY EMAIL "jd@jd-tools.com">






 CATEGORY (HandTool|Table|Shop-Professional) "HandTool"


 PLANT (Pittsburgh|Milwaukee|Chicago) "Chicago"

 INVENTORY (InStock|Backordered|Discontinued) "InStock">







 FINISH (Metal|Polished|Matte) "Matte"

 ADAPTER (Included|Optional|NotApplicable) "Included"

 CASE (HardShell|Soft|NotApplicable) "HardShell">








Running XJC and producing Java classes
 xjc.exe -dtd -d generatedsrc -p com.example.product.catalog product_catalog.dtd 
 parsing a schema...
 compiling a schema...