Avatar of WestCoast_BC
WestCoast_BC
Flag for Canada asked on

Why is my call to CFPOP sometimes causing the error: java.lang.NullPointerException

I am trying to figure out why my call to CFPOP is sometimes giving me the error:


java.lang.NullPointerException 

ucee.runtime.exp.NativeException: java.lang.NullPointerException at java.base/java.lang.String$CaseInsensitiveComparator.compare(String.java:1225) at java.base/java.lang.String$CaseInsensitiveComparator.compare(String.java:1218) at java.base/java.lang.String.compareToIgnoreCase(String.java:1258) at lucee.runtime.op.Operator.compare(Operator.java:438) at lucee.runtime.net.mail.MailClient.contains(MailClient.java:656) at lucee.runtime.net.mail.MailClient.getMessages(MailClient.java:421) at lucee.runtime.net.mail.MailClient.getMails(MailClient.java:318) at lucee.runtime.tag._Mail.doStartTag(_Mail.java:269) at d1_cfm$cf$m61.call(/d1.cfm:91) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1034) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:926) at lucee.runtime.PageContextImpl.doInclude(PageContextImpl.java:907) at application_cfc$cf$ijr.udfCall(/Application.cfc:449) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.call(UDFImpl.java:217) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:684) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:572) at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1911) at lucee.runtime.listener.ModernAppListener.call(ModernAppListener.java:437) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:216) at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44) at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2460) at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2450) at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2421) at lucee.runtime.engine.Request.exe(Request.java:45) at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1179) at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1125) at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97) at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51) at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:479) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.NullPointerException ... 52 more 

Open in new window

My call to CFPOP is the following:

<cfpop action="getall" uid="#mailUID#" name="qMessage" server="#REQUEST.Pop.Server#" username="#REQUEST.Pop.Username#" password="#REQUEST.Pop.Password#" attachmentpath="#ExpandPath( '/custom/emailattachments/' )#" generateuniquefilenames="true" debug="true" />

Open in new window

ColdFusion Language* mailserver

Avatar of undefined
Last Comment
_agx_

8/22/2022 - Mon
gr8gonzo

What does your debug log look like when the error happens?
WestCoast_BC

ASKER
I haven't been able to reproduce since I added debug="true". As soon as it happens again I will look at the log file
gr8gonzo

Okey-doke.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Charlie Arehart

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
gr8gonzo

Hey Charlie,

Thanks for chiming in. This member has a very similar open question where CFPOP was sometimes returning a message indicating "Folder is not open" which sounds almost like the connection is dropping. My guess is that these two are just different symptoms of the same root problem, and it's just happening at different points in the process. Just my guess, though.
WestCoast_BC

ASKER
I am trying to figure out if my other error, Folder is not open, is related to this one. Unfortunately I have not been able to reproduce that error and I am trying to figure out if the nullpointerexception is related.

I will add some dumping of variables when the error occurs.

Thank you all for your help.
Charlie Arehart

Thanks, to both of you. Let's see how things shake out. :-) 
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
_agx_

<cfpop action="getall" uid="#mailUID#"

Open in new window


What is the value and the source of #mailUID#? I mention it because the error seems to occur when comparing message id's. It would be a good idea to log that value, so if the error occurs again you can search the debug log for activity related to those message id(s).  

Also, is there another process that removes messages from this same mailbox?
WestCoast_BC

ASKER
I have added code to log the mailUID and I have added debug to the CFPOP calls. So far I have not yet been able to reproduce either of my bugs. As soon as I do and I learn something I will post it here.

Thank you for all of your help
_agx_

Update

Sounds like a good plan.

Also, is there another process that removes messages from this same mailbox?                                     
BTW, the reason I asked is to get a better picture of how that cfpop fits into your overall process. While the NPE might be caused by some transient issue with the mail server, if you're using threads it could also suggest some sort of race condition. Especially as the error is sporadic. (Race conditions are notoriously difficult to reproduce). So it would help to see a bit more of the overall code to get an understanding of how the mailbox is being accessed from CF.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
WestCoast_BC

ASKER
In this case I do not believe there are any processes that removes the message from the same mailbox. I am still no longer able to reproduce this.

gr8gonzo

I think Charlie might have the right answer here if it's been this long without showing up again - the recompiling changed something to make it work. Just my two cents - you might want to just accept his answer and if the error pops up again, just open a new question.
_agx_

@WestCoast_BC - That was just one possibility mentioned. But you probably have other irons in the fire.  Like gr8gonzo said, keep monitoring and open a new thread when it happens again.

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.