hansva opened a new issue, #9501:
URL: https://github.com/apache/hop/issues/9501

   ### Apache Hop version?
   
   2.21.0-SNAPSHOT
   
   ### Java version?
   
   21
   
   ### Operating system
   
   Other
   
   ### What happened?
   
   Hop's command-line tools and Hop Server fail when the SWT jar is not on the 
class path. The `hop-*.sh` scripts always add `lib/swt/<os>/<arch>/*`, so this 
doesn't show in a normal installation. It does show wherever Hop runs with its 
own class path: an embedded Hop, a slim container image, or a Spark fat jar 
without SWT.
   
   ### What fails without SWT
   
   | What fails | Where | Cause |
   |---|---|---|
   | Hop doesn't start (`hop-run`, `hop-server`, `hop-conf`) | 
`VariableRegistry.init()` in `HopEnvironment.init()` | `BaseDialog` declares 
`HOP_USE_NATIVE_FILE_DIALOG` as a `@Variable` and extends SWT's `Dialog`. The 
registry loads the class to read the variable and catches only `Exception`, so 
`NoClassDefFoundError: org/eclipse/swt/widgets/Dialog` stops start-up. |
   | Every workflow run | Lint's `WorkflowBeforeStartLintExtension` (and the 
pipeline one), on `HopGuiWorkflowBeforeStart`, which `hop-run` also fires | 
Uses `HopGui.peekInstance()` as its "no GUI" check, but loading `HopGui` itself 
needs SWT. The `Error` escapes `catch (Exception)`. |
   | Every pipeline run, and pipeline images on Hop Server | The testing 
plugin's `PipelineGetFieldsExtensionPoint` (on every `getTransformFields`) and 
`DrawTweakOnTransformExtensionPoint` | Both call 
`TestingGuiPlugin.getCurrentUnitTest`, a GUI class. |
   | Showing unit-test results after a run (found by reading the code, not 
reproduced) | `ValidatePipelineUnitTestExtensionPoint` | Calls 
`HopGui.getInstance()`. |
   | `hop-conf` and every `hop` subcommand (`lint`, `search`, `export`, ...) | 
`Hop.addMixinPlugins`: picocli reflects over the config plugins | 16 config 
plugins (6 in hop-ui; projects, git, lint, AI, Azure, Dropbox, Google Cloud 
Storage, Google Drive, Calcite, Formula) have SWT types in method signatures, 
including lambdas that capture SWT or `HopGui`. |
   | Projects with an SMB connection or a Vault, OpenBao or AWS Secrets Manager 
variable resolver | Metadata serialization reflects with `getMethod` | These 
classes implement `IGuiPluginCompositeWidgetsListener`, whose methods take SWT 
types. #9098 fixed the same pattern for the Oracle, MS SQL Server Native and 
Redshift database types. |
   | A pipeline with a Salesforce input can't be loaded | Reflection over 
`SalesforceInputMeta` | An unused `getDialog(Shell, ...)` method. |
   | The LLM chat transform can't be created | `LanguageModelChatMeta` → 
`ModelType` → `i18nUtil` | The message bundle is keyed on 
`LanguageModelChatDialog.class`. |
   
   Already fine without SWT: plugin registration (since #9098), transform metas 
(they name their dialog as a string), and extension points that only fire on 
GUI events.
   
   ### How to reproduce
   
   1. Unzip a client build.
   2. In `hop-run.sh`, remove the `lib/swt/...` entry from `CLASSPATH`.
   3. Run any pipeline or workflow with `./hop-run.sh`. Hop fails in 
`HopEnvironment.init()` with `NoClassDefFoundError: 
org/eclipse/swt/widgets/Dialog`.
   
   Once start-up is past that, every workflow fails in the lint extension point 
and every pipeline fails in the testing extension point.
   
   ### Proposed fix
   
   - **Start-up:** move `HOP_USE_NATIVE_FILE_DIALOG` to a class without SWT, 
and have `VariableRegistry` skip a class it can't load (`LinkageError`) instead 
of failing.
   - **A GUI check without SWT:** add `Const.isGuiRuntime()`, true when 
`HOP_PLATFORM_RUNTIME` is `GUI` (set by `hop-gui.sh`, Hop GUI and Hop Web). 
Lint and testing check it before touching `HopGui`.
   - **Active unit test:** look it up without `TestingGuiPlugin`, and show 
unit-test results only in the GUI.
   - **A widget listener without SWT types:** add 
`IGuiPluginModelWidgetsListener`, with the same callbacks and no SWT 
parameters. `GuiCompositeWidgets` calls either listener. The config plugins, 
the SMB connection and the Vault, OpenBao and AWS resolvers move to it; 
GUI-only code moves to a separate GUI class.
   - **Small fixes:** remove the unused `SalesforceInputMeta.getDialog(Shell, 
...)`, and key the LLM chat messages on `LanguageModelChatMeta`.
   - **Tests:** a `WithoutSwt` helper in the hop-ui test jar loads, reflects 
over and creates a class with SWT hidden. Each fix gets a test with it.
   
   ### Not in scope
   
   - `Hop.addMixinPlugins`: one config plugin that fails to load still stops 
`hop-conf`.
   - `SessionDisplay` catches only `RuntimeException`.
   - A CI check that runs `hop-run` without SWT on the class path.
   
   
   ### Issue Priority
   
   Priority: 2
   
   ### Issue Component
   
   Component: API, Component: Hop Gui


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to