Report this

What is the reason for this report?

Different output in live and local environment. Receiving error

Posted on January 5, 2018

The code seems to behave differently in local environment and differently in a live one. A code that works locally doesnt seem to work on digital ocean server.

This is the code I am using and it works fine in local environment

def date = params.deadline
def dateAgain = date.tokenize('/')
def BD = dateAgain[2] + "-" + dateAgain[0] + "-" + dateAgain[1] + " "+ params.deadLinSubmiteTime +":00"
def deadline = Date.parse("yyyy-MM-dd HH:mm:ss", BD)

And this error is what I get in live environment

Unparseable date: "null-10-01-2018-null 16:51:00". Stacktrace follows:
java.text.ParseException: Unparseable date: "null-10-01-2018-null 16:51:00"
 at java.text.DateFormat.parse(DateFormat.java:357)
 at crm.ContactsController.addTask(ContactsController.groovy:1017)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:745)

Using MySQL, Tomcat 7 in Ubuntu 14.04.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

According to the error that you’ve shared, it looks like that as the value of params.deadline is null in the live environment, the tokenize() method is failing and throwing an error.

To resolve the issue, you should confirm that the deadline parameter is passed correctly and meets the expected format before trying to parse it into a Date object.

You could try setting a default value for the deadline parameter so that you don’t hit that error in case that the parameter is not passed.

Best,

Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.