CFadmin UpdateDatasource syntax

Still on my journey to launch a server instance from a user data script, I’m getting there, but I’m stuck in the adding a datasource step.
I’m creating a temporary .cfm
file to run once then be deleted, this contains:

<cfadmin
    action="updateDatasource"
    type="server"
    password="adminpass"
    classname="com.mysql.cj.jdbc.Driver"
    dbdriver="mysql"
    dsn="mydsn"
    name="mydsn"
    newName="mydsn"
    host="mydburl"
    database="sql5"
    port="3306"
    dbusername="myuser"
    dbpassword="mypass"
    allowMultiQueries = "true"
    blob="false"
    clob="false"
    allowed_select="true"
    allowed_insert="true"
    allowed_update="true"
    allowed_delete="true"
    allowed_alter="false"
    allowed_drop="false"
    allowed_revoke="false"
    allowed_create="false"
    allowed_grant="false"
    remoteClients="arrayOfClients"
>

But this now throws the error:

Cannot invoke "java.sql.Connection.close()" because "this.connection" is null

Which is nort terribly informative. and the documentation is not 100% clear… any ideas?
Don’t forget to tell us about your stack!

OS: Alma Linux 9
Java Version: 21.0.6
Tomcat Version: 10.1.36
Lucee Version: 6.2.0.321

Hmm, can you file a bug, we can improve that

I think there’s a verify attribute? If you look at the src code for the lucee admin you’ll find the working examples

I confirmed this works on my local CommandBox dev machine (Lucee 5.4.6.9)
Servlet container: WildFly / Undertow - 2.2.37.Final
Java 11.0.26
Mac OS X (12.7.2) 64bit

Does not work on Alma 9 install using the latest Lucee installer (Lucee 6.2.0.321)

I’ll look at a submitting a bug report, not done before…

2 Likes

Always include the stacktrace, it really helps

You can snip out the middle section (where you see the cfc/cfml line), it’s always the same with Catalina etc, but there’s often a caused by section (s) at the bottom which should be always included

1 Like

Ok sorry! here it is:

lucee.runtime.exp.NativeException: Cannot invoke "java.sql.Connection.close()" because "this.connection" is null
 at lucee.runtime.db.DatasourceConnectionImpl.close(DatasourceConnectionImpl.java:295)
 at lucee.runtime.tag.Admin._doVerifyDatasource(Admin.java:2920)
 at lucee.runtime.tag.Admin.doUpdateDatasource(Admin.java:2699)
 at lucee.runtime.tag.Admin._doStartTag(Admin.java:729)
 at lucee.runtime.tag.Admin.doStartTag(Admin.java:359)
 at config_db_cfm$cf$4d.call(/config_db.cfm:25)
 at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1063)
 at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:987)
 at lucee.runtime.listener.ClassicAppListener._onRequest(ClassicAppListener.java:63)
 at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:42)
 at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2785)
 at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2772)
 at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2743)
 at lucee.runtime.engine.Request.exe(Request.java:45)
 at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1099)
 at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1056)
 at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
 at lucee.loader.servlet.jakarta.CFMLServlet.service(CFMLServlet.java:49)
 at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:195)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)
 at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)
 at org.apache.catalina.filters.RemoteIpFilter.doFilter(RemoteIpFilter.java:924)
 at org.apache.catalina.filters.RemoteIpFilter.doFilter(RemoteIpFilter.java:980)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:483)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:663)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
 at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:397)
 at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
 at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:905)
 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)
 at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
 at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190)
 at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
 at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Cannot invoke "java.sql.Connection.close()" because "this.connection" is null
 ... 45 more

I tried adding the verify attribute (my local dev box doesn’t require this) same error.
I also checked in on another Alma 9 working install I have running serving my dev site and got the same error.

the connection is coming back null, hence the error

does adding the datasource via the admin work with the same config?

It may be because this DSN needs SSL to connect - I dont see an explicit attribute for that in the examples

Yes it does, though its not entirely obvious which attributes in the cfadmin tag map to which items in the actual admin interface and there appears to be no clear definition I can find. Most use values that are placeholders of variables rather than examples of the format of the data

I have now got pretty much everything working - apart from the add datasource…