Cfcollection giving a java.lang.NullPointerException

I want to use Lucene for full text searching in documents. However, when creating a collection, I immediately run into an error:


My code is as follows:


The path is correct. When this code runs I get the error. What happens in detail is:

  • As said an error when creating
  • the required folders are created
  • When using cfcollection list, ‘vrk’ shows up in the list
  • When trying to delete the collection, the same nullPointerException error
  • When trying to add files to the collection, also the same error

So it seems as though cfcollection did some things, but then failed. I’ve tried this with different versions of Lucene, but they all give the same error. Any ideas would be welcome.

Didn’t try much with Lucene, but could you show us the full stack trace? Of course, mask any sensitive data. With a full stack trace, others may see more information to help you.

1 Like

Thanks for your reply. I hope the below stack trace helps?

lucee.runtime.exp.NativeException: java.lang.NullPointerException at at at
lucee.runtime.tag.Collection.doCreate( at 
lucee.runtime.tag.Collection.doStartTag( at 
.cfm:30) at lucee.runtime.PageContextImpl._doInclude( at 
lucee.runtime.PageContextImpl._doInclude( at 
lucee.runtime.PageContextImpl.doInclude( at 
normity.application_cfc$cf$2d.udfCall(/normity/Application.cfc:239) at 
lucee.runtime.type.UDFImpl.implementation( at 
lucee.runtime.type.UDFImpl._call( at at 
lucee.runtime.ComponentImpl._call( at 
lucee.runtime.ComponentImpl._call( at at at 
lucee.runtime.listener.ModernAppListener._onRequest( at
 lucee.runtime.listener.MixedAppListener.onRequest( at 
lucee.runtime.PageContextImpl.execute( at 
lucee.runtime.PageContextImpl._execute( at 
lucee.runtime.PageContextImpl.executeCFML( at 
lucee.runtime.engine.Request.exe( at 
lucee.runtime.engine.CFMLEngineImpl._service( at 
lucee.runtime.engine.CFMLEngineImpl.serviceCFML( at 
lucee.loader.engine.CFMLEngineWrapper.serviceCFML( at 
lucee.loader.servlet.CFMLServlet.service( at 
javax.servlet.http.HttpServlet.service( at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( at 
org.apache.catalina.core.ApplicationFilterChain.doFilter( at 
org.apache.tomcat.websocket.server.WsFilter.doFilter( at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( at 
org.apache.catalina.core.ApplicationFilterChain.doFilter( at 
org.apache.catalina.core.StandardWrapperValve.invoke( at 
org.apache.catalina.core.StandardContextValve.invoke( at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke( at 
org.apache.catalina.core.StandardHostValve.invoke( at 
org.apache.catalina.valves.ErrorReportValve.invoke( at 
org.apache.catalina.core.StandardEngineValve.invoke( at 
org.apache.catalina.connector.CoyoteAdapter.service( at 
org.apache.coyote.ajp.AjpProcessor.service( at 
org.apache.coyote.AbstractProcessorLight.process( at 
org.apache.coyote.AbstractProtocol$ConnectionHandler.process( at$SocketProcessor.doRun( at at 
java.util.concurrent.ThreadPoolExecutor.runWorker( at 
java.util.concurrent.ThreadPoolExecutor$ at 
org.apache.tomcat.util.threads.TaskThread$ at Caused by: java.lang.NullPointerException

I’d recommend just going for a different solution, the search stuff in lucee is rather old (it’s not the core focus for our limited resources).

try something modern like elastic search

@Marcel_van_Langen regarding:

Here is a nice blog post from @Julian_Halliwell that might help.

to add files to a collection the action should be refresh, not create

When dealing with removing files, both ACF and Lucee on windows do not do well with spaces in names of files or folders and the windows max path bug plagues both cf engines on windows when dealing with long path operations where you do anything over 129 characters in length, even with the longpath enabled.

try creating a collection out on the \driveroot\test or “testcollection”, the above code works

I’ve modified my code so that everything is as easy and simple as possible. All it is now is (for creating the collection, not adding to the collection):


Unfortunately the same error is still showing up…

Thanks all. Although it would be nicer to use Elastic (or something similar), I know that is a lot more work than using something already available. My first hope is still that I can use Lucene, just hoping this error can be avoided…

Lucee locks the collection, it’s common bug with Lucene and we tried at length to figure it out with no luck

1 Like

The only thing I can think of, (and forgive me, but this weekend was exhausting and I am not fully caffeinated this morning) is my “test” windows box, I have stripped all the WINDOWS ACL / permissions off.

When I run the following code, it works.
This creates a collection


This deletes a collection


After you create the collection, you would want to run a “REFRESH” on it to update the engine to understand there is “stuff”

<cfindex collection="testcollection" action="refresh" 
key="C:\lucee\tomcat\webapps\ROOT\col1" type="path" 
urlpath="C:\lucee\tomcat\webapps\ROOT\col1" extensions=".cfm,.html">

To search for “Stuff” you would use

<cfsearch name="searchResults" collection="testcollection" criteria="CF">
<cfdump var="#searchResults#"> (1.2 KB)

1 Like

So you got it to work? That’s interesting! Perhaps it had to do with the permissions. Can you give me insight as to how you stripped all WINDOWS ACL / premissions? I want to try that as well!

This seems to be a problem only when the collection is already created. The problem I’m having is that the error already occurs when we’re creating the collection…

remove UAC
C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f

Give the “EVERYONE” user / group full control on “DRIVE” you want no permissions for
Assign “EVERYONE” to the administrator group

Note, this is a “VM” in production this would be suicidal.

1 Like

to put it mildy :slight_smile:


Unfortunately this did not work. Kind of at a loss here. Suppose the way to go forward is make some time to get working on Elastic…

You could post you code here… it Does work, at least for us, but you have to keep in mind you can not go over 129 characters for file operations on windows.

My code could not be easier… See the code above!

Try this, as it looks like a permissions issue

1 Like

Unfortunately no luck. I still get the error “java.lang.NullPointerException”… Thanks for your suggestions though! When I look at the folder, I can see that 2 directories are created: CFtestcollection0 and CFtestcollection220. Both of them are empty.

after you create the collection, you have to run “REFRESH” on it, and tell it what “STUFF” you want to index.

Think of it as creating a database,
then putting data into the database

So if you have word docs and text files for example, which are .doc and .txt you would use

<cfindex collection="testcollection" action="refresh" 
key="C:\lucee\tomcat\webapps\ROOT\temp" type="path" 
urlpath="C:\lucee\tomcat\webapps\ROOT\temp" extensions=".doc,.txt">