Why do my wildcard imports fail?
To use classes within a Groovy code studio or Persistent Query, you must import them. For example, to use the Java LinkedBlockingQueue
, you would import it as follows:
import java.util.concurrent.LinkedBlockingQueue
Sometimes, when you want to use many different classes from the same package, using a wildcard import with an asterisk (*
) is convenient. For example, to import all classes in org.apache.commons.text
, you might import:
import org.apache.commons.text.*;
If you have not imported an individual class from this package, then you get an error message like the following on a Core+ worker:
r-Scheduler-Serial-1 | .c.ConsoleServiceGrpcImpl | Error running script: java.lang.RuntimeException: Attempting to import a path that does not exist: import import org.apache.commons.text.*;
at io.deephaven.engine.util.GroovyDeephavenSession.updateScriptImports(GroovyDeephavenSession.java:585)
at io.deephaven.engine.util.GroovyDeephavenSession.grepScriptImports(GroovyDeephavenSession.java:595)
at io.deephaven.engine.util.GroovyDeephavenSession.evaluate(GroovyDeephavenSession.java:310)
at io.deephaven.enterprise.dnd.modules.GroovyConsoleSessionWithDatabaseModule$1.evaluate(GroovyConsoleSessionWithDatabaseModule.java:81)
at io.deephaven.engine.util.AbstractScriptSession.lambda$evaluateScript$0(AbstractScriptSession.java:151)
at io.deephaven.engine.context.ExecutionContext.lambda$apply$0(ExecutionContext.java:180)
at io.deephaven.engine.context.ExecutionContext.apply(ExecutionContext.java:191)
at io.deephaven.engine.context.ExecutionContext.apply(ExecutionContext.java:179)
at io.deephaven.engine.util.AbstractScriptSession.evaluateScript(AbstractScriptSession.java:151)
at io.deephaven.engine.util.DelegatingScriptSession.evaluateScript(DelegatingScriptSession.java:84)
at io.deephaven.engine.util.ScriptSession.evaluateScript(ScriptSession.java:102)
at io.deephaven.server.console.ConsoleServiceGrpcImpl.lambda$executeCommand$4(ConsoleServiceGrpcImpl.java:186)
at io.deephaven.server.session.SessionState$ExportBuilder.lambda$submit$3(SessionState.java:1499)
at io.deephaven.server.session.SessionState$ExportObject.doExport(SessionState.java:1008)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at io.deephaven.server.runner.scheduler.SchedulerModule$ThreadFactory.lambda$newThread$0(SchedulerModule.java:97)
at java.base/java.lang.Thread.run(Thread.java:840)
Or on a Legacy worker:
java.lang.RuntimeException: Attempting to import a path that does not exist: import org.apache.commons.text.*;
at com.illumon.iris.db.util.IrisDbGroovySession.updateScriptImports(IrisDbGroovySession.java:426)
at com.illumon.iris.db.util.IrisDbGroovySession.grepScriptImports(IrisDbGroovySession.java:436)
at com.illumon.iris.db.util.IrisDbGroovySession.evaluate(IrisDbGroovySession.java:205)
at com.illumon.iris.console.events.RemoteScriptCommandQuery.execute(RemoteScriptCommandQuery.java:89)
at com.illumon.iris.console.events.RemoteScriptCommandQuery.execute(RemoteScriptCommandQuery.java:24)
at com.illumon.iris.db.tables.remotequery.RemoteQueryProcessor$QueryAction.lambda$execute$0(RemoteQueryProcessor.java:1935)
at com.illumon.util.locks.FunctionalLock.computeLockedInterruptibly(FunctionalLock.java:98)
at com.illumon.iris.db.tables.remotequery.RemoteQueryProcessor$QueryAction.execute(RemoteQueryProcessor.java:1935)
at com.illumon.iris.db.tables.remotequery.RemoteQueryProcessor$ClientConnectionHandler.runSyncQueryAndSendResult(RemoteQueryProcessor.java:1696)
at com.illumon.iris.db.tables.remotequery.RemoteQueryProcessor$ClientConnectionHandler.handleCommandST(RemoteQueryProcessor.java:1590)
at com.illumon.iris.db.tables.remotequery.RemoteQueryProcessor$ClientConnectionHandler$HandleCommandRunnable.run(RemoteQueryProcessor.java:1185)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
You can work around this error by importing at least one class from the package before the wild card import:
import org.apache.commons.text.CaseUtils;
import org.apache.commons.text.*;