Railo > Lucee Component error: [java.lang.NullPointerException]

Hello,
I want migrate from Railo (4.2.2.004) to Lucee (4.5.3.001) but I
encountered a problem that I do not know to solve:

https://hostr.co/file/ohp14qvaRBkC/error_lucee.png

Using the component cfmailgun by Dominic Watson
https://github.com/DominicWatson/cfmailgun

With Railo working properly.
(sorry for my English)

Hi Ivan,

I assume you have try to restart Lucee since upgrading? Also, 4.5.3.001 is
only a bleeding edge release, the current stable release is 4.5.2.018, so
not sure if this is a problem with the bleeding edge release, I would try
the stable release.

Kind regards,

Andrew
about.me http://about.me/andrew_dixon - mso http://www.mso.net - Lucee
Association Member http://lucee.orgOn 6 December 2015 at 10:11, Ivan <@Ivan> wrote:

Hello,
I want migrate from Railo (4.2.2.004) to Lucee (4.5.3.001) but I
encountered a problem that I do not know to solve:
https://hostr.co/file/ohp14qvaRBkC/error_lucee.png

https://hostr.co/file/ohp14qvaRBkC/error_lucee.png

Using the component cfmailgun by Dominic Watson
https://github.com/DominicWatson/cfmailgun

With Railo working properly.
(sorry for my English)


Love Lucee? Become a supporter and be part of the Lucee project today! -
http://lucee.org/supporters/become-a-supporter.html

You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/d2213d78-cc9f-4d1b-96c2-89abdf06e69b%40googlegroups.com
https://groups.google.com/d/msgid/lucee/d2213d78-cc9f-4d1b-96c2-89abdf06e69b%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

Hello Andrew,
I tried to remove the last patch and return to version 4.5.2.018. I also
rebooted the server, but I have not solved.
In my opinion, I’m wrong. Not a problem of Lucee.

If you need any more information, I am here!

Hi Ivan,

Not sure if this might be the cause, but the first argument of init()
(apiKey) is required. I’ve never seen this message before though, so it’s
probably not the issue but who knows.

Kind regards,
Jeroen

Hi Jeroen,
apiKey is defined in the file MailGunClient.cfc (for my convenience).
Here you will find exactly the component as well as works on Railo:

I correct what I wrote earlier… The problem seems to be in the "
sendMessage". If I delete this function, the other functions seem to work.





















var result = ""; var files = {}; var postVars = { from = arguments.from , to = arguments.to , subject = arguments.subject , text = arguments.text , html = arguments.html };

if ( Len( Trim( arguments.cc ) ) ) {
postVars.cc = arguments.cc;
}

if ( Len( Trim( arguments.bcc ) ) ) {
postVars.bcc = arguments.bcc;
}

if ( _getForceTestMode() or arguments.testMode ) {
postVars[ “o:testmode” ] = “yes”;
}

if ( ArrayLen( arguments.tags ) ) {
postVars[ “o:tag” ] = arguments.tags;
}

if ( Len( Trim( arguments.campaign ) ) ) {
postVars[ “o:campaign” ] = arguments.campaign;
}

if ( IsBoolean( arguments.dkim ) ) {
postVars[ “o:dkim” ] = _boolFormat( arguments.dkim );
}

if ( IsDate( arguments.deliveryTime ) ) {
postVars[ “o:deliverytime” ] = _dateFormat( arguments.deliveryTime );
}

if ( IsBoolean( arguments.tracking ) ) {
postVars[ “o:tracking” ] = _boolFormat( arguments.tracking );
}

if ( IsBoolean( arguments.clickTracking ) ) {
postVars[ “o:tracking-clicks” ] = _boolFormat( arguments.clickTracking );
} elseif( arguments.clickTracking eq “htmlonly” ) {
postVars[ “o:tracking-clicks” ] = “htmlonly”;
}

if ( IsBoolean( arguments.openTracking ) ) {
postVars[ “o:tracking-opens” ] = _boolFormat( arguments.openTracking );
}

for( var key in arguments.customHeaders ){
postVars[ “h:X-#key#” ] = arguments.customHeaders[ key ];
}

for( var key in arguments.customVariables ){
postVars[ “v:#key#” ] = arguments.customVariables[ key ];
}

if ( ArrayLen( arguments.attachments ) ) {
files.attachment = arguments.attachments;
}

if ( ArrayLen( arguments.inlineAttachments ) ) {
files.inline = arguments.inlineAttachments;
}

result = _restCall(
httpMethod = “POST”
, uri = “/messages”
, domain = arguments.domain
, postVars = postVars
, files = files
);

if ( StructKeyExists( result, “id” ) ) {
return result.id;
}

_throw(
type = “unexpected”
, message = “Unexpected error processing mail send. Expected an ID of
successfully sent mail but instead received [#SerializeJson( result )#]”
);

Why do you think it does not work?

Hi,
I thought and thought… I think that the 99% that the problem lies in the
following function:


_setApiKey( “pubkey-460ik78fbe8bu471dfsr9wtpf53gl4m6” );
var getVars = {};

if ( Len( Trim( arguments.address ) ) ) {
getVars.address = arguments.address;
};

var result = _restCall(
httpMethod = “GET”
, uri = “/address/validate”
, getVars = getVars
);

if ( IsStruct( result ) and StructKeyExists( result, “is_valid” ) ) {
return structFind(result, “is_valid”);
}

_throw(
type = “unexpected”
, message = “Unexpected mailgun response. Expected a validate object
(structure) but received [#SerializeJson( result )#]”
, errorCode = 500
);

This function has been added by me to check if the email address is
correct. But I repeat: on Railo worked…
Invoking the other functions, the component works.

What does not work in this function?Il giorno martedì 8 dicembre 2015 13:21:53 UTC+1, Jeroen Knoef ha scritto:

Since the empty component can be instantiated, you could remove functions
one at a time and see when the error goes away. Then you know there’s
something in that function that Lucee chokes on. If you’ve found that
function, comment out lines inside that function until there’s no error.
That should give you the line where things go wrong. Could you post that
line back here if you find it?

Since the empty component can be instantiated, you could remove functions
one at a time and see when the error goes away. Then you know there’s
something in that function that Lucee chokes on. If you’ve found that
function, comment out lines inside that function until there’s no error.
That should give you the line where things go wrong. Could you post that
line back here if you find it?

OMG … thanks to all I found the problem!

it’s here:

if ( IsDate( arguments.deliveryTime ) ) {
postVars[ “o:deliverytime” ] = _dateFormat( arguments.deliveryTime );
}

Lucee not like the word “_dateFormat”, so I changed and now it works! I
will do more tests, but for now I can say I solved!

P.S. ye are a great community, ready to give advice to try to solve
issues. Thank you!

Hi,
I tried to create the component (MailGunClient.cfc) in another directory
and the problem persists… It may be a bug or incompatibility of Lucee? Or
is it a problem of the component?

How can I make a more thorough debugging?

Thank you all!

Sorry for the late reply, have just seen this. Nice find! Would you mind
making a pull request with your fix?

Dominic :)On Tuesday, 8 December 2015 19:14:38 UTC, Ivan wrote:

OMG … thanks to all I found the problem!

it’s here:

if ( IsDate( arguments.deliveryTime ) ) {
postVars[ “o:deliverytime” ] = _dateFormat( arguments.deliveryTime );
}

Lucee not like the word “_dateFormat”, so I changed and now it works! I
will do more tests, but for now I can say I solved!

P.S. ye are a great community, ready to give advice to try to solve
issues. Thank you!