0

We have an issue on our production system and some of our test systems. We have an intermittent Grails Exception which occurs in a view.

No signature of method: static org.apache.commons.lang.StringUtils.isNotBlank() is applicable for argument types: (null) values: [null] Possible solutions: isNotBlank(java.lang.String), isBlank(java.lang.String)

The error seems to suggest that Grails can't seem to figure out that it should use StringUtils.isNotBlank(String) should be used when null is passed to it.

We noticed that:

  • on production, the issue appeared and took more than 12 hours before it seemed to magically disappear. A search of logs seems to suggest that no reboot took place.
  • a developer saw no issue on a test system in the morning. After a few hours, he was able to reproduce it. To resolve, we rebooted Tomcat.

I'm not sure what the Grails version is or how to check it. If you comment below on how to find that, I'd be happy to edit the question with the Grails version.

  • What causes this and is there a way we can reliably reproduce it?
  • Is there a reliable way to work around it?
Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
MedicineMan
  • 15,008
  • 32
  • 101
  • 146
  • Related to https://stackoverflow.com/questions/24021641/resource-plugin-error-when-upgrading-from-grails-2-3-8-2-4 – biniam Sep 06 '17 at 13:08

3 Answers3

0

I can reproduce this in the console by running:

org.apache.commons.lang.StringUtils.isNotBlank((Object)null) => Your Error

Passing just null allows the compiler to coerce the null to a String:

org.apache.commons.lang.StringUtils.isNotBlank(null) => false

It's possible whatever you are passing in is strictly typed to be something other than a String but is null. The Groovy compiler is pretty smart of coercing types, but I have seen it blow up on some easy cases. This is especially true if using @CompileStatic and/or using native Java objects.

Aaron
  • 546
  • 3
  • 8
  • Any idea why the problem is intermittent, and why reboot fixes it – MedicineMan May 15 '15 at 00:49
  • I wonder if the No signature error is just a symptom of the real problem. Perhaps there is something that intermittently causes a null, non-String type to be passed to that method. I would start looking at all the callers of the method and the origin of the parameters that are being passed. – Aaron May 15 '15 at 13:45
0

A reliable workaround is that we restart the application.

Horrible answer, I know. I feel dirty every time.

MedicineMan
  • 15,008
  • 32
  • 101
  • 146
  • Ultimately, the engineering staff has decided that grails just plain sucks and we've hated using it from the beginning. We've moved on, but not before placing a 100 years curse on the original developers who chose the stack. – MedicineMan Jul 13 '16 at 17:01
0

I recently experienced this as well. Turns out, we had a piece of code that was passing in a Long to StringUtils.isNotEmpty(). Every subsequent call made to this method having a String value of null, errored with the same MissingMethodException.

You can replicate this pretty easily by executing...

        String string = null
        Long longVal = new Long("1103384")

        try{
                StringUtils.isNotEmpty(longVal)
            }catch(Exception e){
                e.printStackTrace()
            }
        try{
            if(!StringUtils.isNotEmpty(string)){
                println("............EMPTY. Good.")
            }
        }catch(Exception e){
            e.printStackTrace()
        }

In the snipped above BOTH calls with error out.