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:

java.lang.NullPointerException

My code is as follows:

<cfcollection
		engine="lucene"
		categories="yes"
		action="create"
		collection="vrk"
		language="Dutch"
		path="#ExpandPath(application.setting.directoryCollecties)#"
	>

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 
org.lucee.extension.search.SearchEngineSupport.addCollection(SearchEngineSupport.java:162) at 
org.lucee.extension.search.SearchEngineSupport.createCollection(SearchEngineSupport.java:131) at
lucee.runtime.tag.Collection.doCreate(Collection.java:251) at 
lucee.runtime.tag.Collection.doStartTag(Collection.java:156) at 
normity.applicatie.zoeken.zoekenoverzicht_cfm$cf$2m.call(/normity/applicatie/zoeken/zoekenOverzicht
.cfm:30) 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 
normity.application_cfc$cf$2d.udfCall(/normity/Application.cfc:239) 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:102) 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:496) 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:790) at 
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468) at 
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at 
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at 
java.lang.Thread.run(Thread.java:748) 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):

<cfcollection
				categories="no"
				action="create"
				collection="testcollection"
				path="C:\temp"
			>

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

https://luceeserver.atlassian.net/browse/LDEV-3310

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

<cfcollection
				categories="no"
				action="create"
				collection="testcollection"
				path="C:\lucee\tomcat\webapps\ROOT\col1"
			>

This deletes a collection

<cfcollection
				categories="no"
				action="delete"
				collection="testcollection"
				path="C:\lucee\tomcat\webapps\ROOT\col1"
			>

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#">

coll-sample.zip (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:

2 Likes

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

   <cfcollection
    				categories="no"
    				action="create"
    				collection="testcollection"
    				path="C:\lucee\tomcat\webapps\ROOT\temp"
    			>
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">