spreadsheet-cfml icon indicating copy to clipboard operation
spreadsheet-cfml copied to clipboard

First Time Install java.lang.NullPointerException

Open Conrad-T-Pino opened this issue 3 years ago • 30 comments
trafficstars

Any help interpreting this stack trace is welcome: "Severity","ThreadID","Date","Time","Application","Message" "ERROR","catalina-exec-3","07/05/2022","08:28:40","DelekHope","excel.cfm;java.lang.NullPointerException;lucee.runtime.exp.NativeException: java.lang.NullPointerException at lucee.runtime.op.Caster.castTo(Caster.java:4683) at lucee.runtime.functions.string.JavaCast.to(JavaCast.java:93) at lucee.runtime.functions.string.JavaCast.call(JavaCast.java:54) at helpers.sheet_cfc$cf.udfCall4(/helpers/sheet.cfc:338) at helpers.sheet_cfc$cf.udfCall(/helpers/sheet.cfc) 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.type.scope.UndefinedImpl.call(UndefinedImpl.java:785) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1747) at helpers.sheet_cfc$cf.udfCall2(/helpers/sheet.cfc:149) at helpers.sheet_cfc$cf.udfCall(/helpers/sheet.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:207) at lucee.runtime.type.scope.UndefinedImpl.callWithNamedValues(UndefinedImpl.java:802) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1766) at helpers.sheet_cfc$cf.udfCall3(/helpers/sheet.cfc:238) at helpers.sheet_cfc$cf.udfCall(/helpers/sheet.cfc) 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:650) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:572) at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1911) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1747) at spreadsheet_cfc$cf.udfCall9(/Spreadsheet.cfc:1416) at spreadsheet_cfc$cf.udfCall(/Spreadsheet.cfc) 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.type.scope.UndefinedImpl.call(UndefinedImpl.java:785) at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:787) at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1747) at spreadsheet_cfc$cf.udfCall7(/Spreadsheet.cfc:1234) at spreadsheet_cfc$cf.udfCall(/Spreadsheet.cfc) at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106) at lucee.runtime.type.UDFImpl._call(UDFImpl.java:344) at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:207) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:651) at lucee.runtime.ComponentImpl._call(ComponentImpl.java:572) at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1930) at lucee.runtime.util.VariableUtilImpl.callFunctionWithNamedValues(VariableUtilImpl.java:866) at lucee.runtime.PageContextImpl.getFunctionWithNamedValues(PageContextImpl.java:1766) at webreg.delekhope.admin.action.excel_cfm$cf$4.call(/webreg/DelekHope/Admin/action/excel.cfm:17) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1003) at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:926) at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:217) 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:733) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:667) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346) at org.apache.coyote.http2.StreamProcessor.service(StreamProcessor.java:404) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.http2.StreamProcessor.process(StreamProcessor.java:74) at org.apache.coyote.http2.StreamRunnable.run(StreamRunnable.java:35) 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:829) Caused by: java.lang.NullPointerException ... 82 more"

Conrad-T-Pino avatar Jul 05 '22 15:07 Conrad-T-Pino

What does your calling code look like?

cfsimplicity avatar Jul 05 '22 15:07 cfsimplicity

local = [:]; local["Spreadsheet"] = new Spreadsheet(); local["SpreadsheetNew"] = local.Spreadsheet.new(sheetName="Sheet1");

Conrad-T-Pino avatar Jul 05 '22 16:07 Conrad-T-Pino

I've been back tracing the source; all these calls are inner methods of the download I really want;

local.Spreadsheet.workbookFromQuery(local.result); local.Spreadsheet.binaryFromQuery(local.result); local.Spreadsheet.downloadFileFromQuery(local.result, "FileName");

Conrad-T-Pino avatar Jul 05 '22 16:07 Conrad-T-Pino

Not sure I understand why you're using the local scope in that way. local is a built in scope within a function and doesn't need to be defined. You also don't need to use [] notation when defining variables.

local.Spreadsheet = new Spreadsheet();

Or more simply, just use the var keyword once to declare it as local, then you can omit the scope:

var Spreadsheet = new Spreadsheet();
var newSpreadsheet = Spreadsheet.new(sheetName="Sheet 1");

In any case, which line of your code is actually triggering the exception?

cfsimplicity avatar Jul 05 '22 16:07 cfsimplicity

I'm in simple template "excel.cfm" and use "local" structure as fast way to clean up variables scope when including this template. I use "[]" notation to force name case in cfdump output.

All these cause same exception: local.Spreadsheet.new(sheetName="Sheet1"); local.Spreadsheet.workbookFromQuery(local.result); local.Spreadsheet.binaryFromQuery(local.result); local.Spreadsheet.downloadFileFromQuery(local.result, "FileName");

Conrad-T-Pino avatar Jul 05 '22 16:07 Conrad-T-Pino

I've tried replicating your dummy "local scope" in a template and it doesn't seem to affect things so we can rule that out. But I can't replicate the NPE unfortunately which makes it tricky to diagnose.

Which versions of Lucee and java are you using?

cfsimplicity avatar Jul 05 '22 16:07 cfsimplicity

Lucee 5.3.8.206 openjdk version "11.0.15" 2022-04-19 OpenJDK Runtime Environment (build 11.0.15+10-post-Debian-1deb11u1) OpenJDK 64-Bit Server VM (build 11.0.15+10-post-Debian-1deb11u1, mixed mode, sharing)

Conrad-T-Pino avatar Jul 05 '22 16:07 Conrad-T-Pino

Those versions should be fine. Sorry am at a bit of a loss...

cfsimplicity avatar Jul 05 '22 16:07 cfsimplicity

The stack trace contains "(/helpers/sheet.cfc:338)" as last location within this project's scope. The code at Line 338

336 private numeric function getSheetIndexFromName( required workbook, required string sheetName ){ 337 //returns -1 if non-existent 338 return arguments.workbook.getSheetIndex( JavaCast( "string", arguments.sheetName ) ); 339 }

The stack trace continue in "JavaCast" which suggests a "arguments.sheetName" issue?

Conrad-T-Pino avatar Jul 05 '22 19:07 Conrad-T-Pino

Yes, but I've tested your code with the sheetName="Sheet1" argument and it works fine for me (and many other people are using the library without issue). It must be something in your environment, but it's hard to know what given that the NPE doesn't give any clue as to the underlying problem.

Presumably leaving off the sheetName argument makes no difference given that you said other calls are producing the same error?

cfsimplicity avatar Jul 05 '22 19:07 cfsimplicity

Are you able to run the following? If so please post the output.

dump( new Spreadsheet().getEnvironment() )

Also, just a shot in the dark, but try this in case there's an OSGi issue of some kind:

new Spreadsheet().flushOsgiBundle()

Then retry your code.

cfsimplicity avatar Jul 05 '22 20:07 cfsimplicity

For expediency sake we are going to export "ms" styled CSS in html tables using excel "Content-Type". IMO less than ideal but good enough for this project's program manager.

  • I can clone Lucee instance at AWS and test replication there.
  • I can grant shell access with a PuTTY or SSH public key.
  • I can grant the Lucee administrator password.

My issue title choice is intended to imply I agree this issue is likely installation environment specific. I will do the heavy lifting following experienced guidance all hopefully to the project's and future user's benefit. If agreeable, I can deploy AWS clone in about an hour or two.

Conrad-T-Pino avatar Jul 06 '22 07:07 Conrad-T-Pino

Did you try flushOsgiBundle() and getEnvironment()?

cfsimplicity avatar Jul 06 '22 07:07 cfsimplicity

No, I reverted local project host and can't replicate locally which is reason I propose the AWS Lucee clone.

Conrad-T-Pino avatar Jul 06 '22 11:07 Conrad-T-Pino

Not sure I understand. So there's no issue on your local setup? Where is it a problem then? In AWS?

cfsimplicity avatar Jul 06 '22 11:07 cfsimplicity

I develop locally with VMware ESXi instance. Only try was local ESXi instance which I reverted. Integration testing is AWS EC2 instance. Production is another EC2 instance. What matters are AWS instances.

Conrad-T-Pino avatar Jul 06 '22 12:07 Conrad-T-Pino

BTW I see similar issue with GitHub "cfspreadsheet-lucee-5" Lucee extension which has Apache POI dependency as well.

Conrad-T-Pino avatar Jul 07 '22 15:07 Conrad-T-Pino

Can you please provide a link to that issue?

cfsimplicity avatar Jul 08 '22 11:07 cfsimplicity

I didn't open cfspreadsheet-lucee-5 issue as I prefer this project's features.

The export HTML as Content-Type "application/msexcel" is good enough for browser and Excel but was labor intensive to mimic this project's "downloadFileFromQuery" function. I want to replace my hack with this project once this issue is resolved.

Conrad-T-Pino avatar Jul 08 '22 12:07 Conrad-T-Pino

I just want to know which is the "similar issue" with the cfspreadsheet extension that you saw? Can you give the URL of that issue? Thanks.

cfsimplicity avatar Jul 08 '22 12:07 cfsimplicity