You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by "Hamilton-dfp (via GitHub)" <gi...@apache.org> on 2023/11/30 00:35:55 UTC

[I] 4.10: FesukiAutoModule not loading when running as standalone service [jena]

Hamilton-dfp opened a new issue, #2106:
URL: https://github.com/apache/jena/issues/2106

   ### Version
   
   4.10
   
   ### What happened?
   
   Hey, folks. I'm having issues getting a FusekAutoModule to load. I'm reporting this as a defect because I believe I've followed the [documentation](https://jena.apache.org/documentation/fuseki2/fuseki-modules.html#automatically-loaded) and the [example](https://github.com/apache/jena/blob/main/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples/ExFusekiMain_3_FusekiModule.java#L56) correctly, but I will admit to being unfamiliar to ServiceLoaders, so it's possible I'm missing something obvious.
   
   Steps to reproduce:
   
   1. Test Module:
   ```
   package ai.test.fuseki;
   
   import org.apache.jena.fuseki.main.FusekiServer;
   import org.apache.jena.fuseki.main.sys.FusekiAutoModule;
   
   public class HelloFuseki implements FusekiAutoModule {
   
       public HelloFuseki() {}
   
       @Override
       public String name() {
           return "HelloFuseki";
       }
   
       @Override
       public void serverAfterStarting(FusekiServer server) {
           System.out.println("*********************************** Hello Fuseki");
       }
   }
   ```
   2. In my resources directory I added `META-INF/services` folder and a file named `org.apache.jena.fuseki.main.sys.FusekiAutoModule` with a single line:
   ```
   ai.test.fuseki.HelloFuseki
   ```
   3. Compiled jar. See attached (renamed `.jar` to `.zip` for upload purposes only)
   4. Added compiled jar to `run/extra` directory in my extracted service, as described in [fuseki-service](https://github.com/apache/jena/blob/0aa670f077baae18810946a607fb862f11afab58/jena-fuseki2/apache-jena-fuseki/fuseki-server#L128).
   5. Started application with `sh fuseki-server`
   
   Expected Results:
   I should see the output String `*********************************** Hello Fuseki` in my terminal output.
   
   Actual Results:
   I see no indication that my module was loaded and do not see the expected output.
   
   Additional Notes:
   * Before creating an FusekiAutoModule and attempting to load with a ServiceLoader, I first created a FusekiModule and started a server programmatically. This gave me the expected results.
   * Because the [example](https://github.com/apache/jena/blob/main/jena-fuseki2/jena-fuseki-main/src/test/java/org/apache/jena/fuseki/main/examples/ExFusekiMain_3_FusekiModule.java#L56) mentions it, and because the [FusekiServiceLoaderModules](https://github.com/apache/jena/blob/0aa670f077baae18810946a607fb862f11afab58/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/sys/FusekiAutoModules.java#L148) seems to be trying to use FusekiModule, I also tried implementing `FusekiModule` and changing the name of the `META-INF/services` file to `org.apache.jena.fuseki.main.sys.FusekiModule`. Alas, no dice.
   
   Anything I might be missing, or anywhere else I can look? I can work around this by just creating the server programmatically, but would prefer not to if I don't need to.
   
   [helloFuseki-0.0.1.zip](https://github.com/apache/jena/files/13506899/helloFuseki-0.0.1.zip)
   
   ### Relevant output and stacktrace
   
   ```shell
   17:31:08 INFO  Server          :: Apache Jena Fuseki 4.10.0
   17:31:08 INFO  Config          :: FUSEKI_HOME=/Users/user/jena/apache-jena-fuseki-4.10.0/.
   17:31:08 INFO  Config          :: FUSEKI_BASE=/Users/user/jena/apache-jena-fuseki-4.10.0/run
   17:31:08 INFO  Config          :: Shiro file: file:///Users/user/jena/apache-jena-fuseki-4.10.0/run/shiro.ini
   17:31:08 INFO  Config          :: Load configuration: file:///Users/user/jena/apache-jena-fuseki-4.10.0/run/configuration/my-test.ttl
   17:31:08 INFO  Server          :: Configuration file: /Users/user/jena/apache-jena-fuseki-4.10.0/run/config.ttl
   17:31:08 INFO  Server          :: Path = /my-test
   17:31:08 INFO  Server          ::   Memory: 4.0 GiB
   17:31:08 INFO  Server          ::   Java:   17.0.8
   17:31:08 INFO  Server          ::   OS:     Mac OS X 13.2.1 aarch64
   17:31:08 INFO  Server          ::   PID:    6255
   17:31:08 INFO  Server          :: Started 2023/11/29 17:31:08 MST on port 3030
   ```
   
   
   ### Are you interested in making a pull request?
   
   Maybe


-- 
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: issues-unsubscribe@jena.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] 4.10: FesukiAutoModule not loading when running as standalone service [jena]

Posted by "Hamilton-dfp (via GitHub)" <gi...@apache.org>.
Hamilton-dfp closed issue #2106: 4.10: FesukiAutoModule not loading when running as standalone service
URL: https://github.com/apache/jena/issues/2106


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] 4.10: FesukiAutoModule not loading when running as standalone service [jena]

Posted by "Hamilton-dfp (via GitHub)" <gi...@apache.org>.
Hamilton-dfp commented on issue #2106:
URL: https://github.com/apache/jena/issues/2106#issuecomment-1834366175

   @rvesse, @afs, thank you for taking the time to respond.
   
   This issue did turn out to be that I was using the UI webapp.
   
   Downloading the `jena-fuseki-server` jar and following the fuseki-main documentation (both linked above), I was able to get the expected output.
   
   The only gotcha that I will note here for posterity is that adding the `--modules=true` flag is required to get it to load the module. This threw me for a loop because I think in the [next iteration it will be on by default](https://github.com/apache/jena/blob/cb37a5657756bdadf37a1832d307e134b30669c5/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/cmds/FusekiMain.java#L108)?
   
   ```
   java -cp jena-fuseki-server-4.10.0.jar:helloFuseki-0.0.1.jar org.apache.jena.fuseki.main.cmds.FusekiMainCmd --modules=true --loc=/Users/user/jena/apache-jena-fuseki-4.10.0/run/configuration /my-test
   ```
   
   Note that I just pointed this instance to the TDB that the UI webapp had created for me.
   
   ```
   [2023-11-30 11:36:23] Server     INFO  Module: HelloFuseki (unknown)
   [2023-11-30 11:36:23] Server     INFO  Apache Jena Fuseki 4.10.0
   [2023-11-30 11:36:23] Server     INFO  Database: TDB2 dataset: location=/Users/user/jena/apache-jena-fuseki-4.10.0/run/configuration
   [2023-11-30 11:36:23] Server     INFO  Path = /my-test
   [2023-11-30 11:36:23] Server     INFO    Memory: 8.0 GiB
   [2023-11-30 11:36:23] Server     INFO    Java:   17.0.8
   [2023-11-30 11:36:23] Server     INFO    OS:     Mac OS X 13.2.1 aarch64
   [2023-11-30 11:36:23] Server     INFO    PID:    11407
   *********************************** Hello Fuseki
   [2023-11-30 11:36:23] Server     INFO  Start Fuseki (http=3030)
   ```
   
   Thanks again, folks!
   


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] 4.10: FesukiAutoModule not loading when running as standalone service [jena]

Posted by "rvesse (via GitHub)" <gi...@apache.org>.
rvesse commented on issue #2106:
URL: https://github.com/apache/jena/issues/2106#issuecomment-1833402969

   How are you packaging the JAR?
   
   A common pitfall related to `ServiceLoader` is that people repack multiple dependencies into a single fat/uber JAR with Maven shade plugin or equivalent.  If that is done the default behaviour is to only keep one instance of each given file so when you have multiple `META-INF/services/<foo>` files across your dependencies only one gets picked.  The shade plugin has a transformer that can be explicitly enabled to merge all those files together sensibly, see [Combining Apache Jena JARs](https://jena.apache.org/documentation/notes/jena-repack.html) for examples of that
   
   Have you double checked that your JAR definitely contains your `META-INF/services` file if you unpack it with `unzip`?  The version you've attached to this issue does appear to have that correct AFAICT
   
   And if you inspect the `ps -ax` (or equivalent) output your extra JAR definitely got added to the `java` command run by `fuseki-service`?


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org


Re: [I] 4.10: FesukiAutoModule not loading when running as standalone service [jena]

Posted by "afs (via GitHub)" <gi...@apache.org>.
afs commented on issue #2106:
URL: https://github.com/apache/jena/issues/2106#issuecomment-1833647274

   Hi @Hamilton-dfp,
   
   The log indicate you are running the packaging of Fuseki with the UI webapp.
   Presumably the `apache-jena-fuseki-4.10.0` download.
   
   This for of Fuseki does not support Fuseki Modules.
   
   The form that does is "Fuseki Main" - the long term reworking that will (sometime) be packaged with the UI and admin function and be the standalone server. 
   
   https://jena.apache.org/documentation/fuseki2/fuseki-main.html -- this does not have the UI and only supports command line arguments and configuration files.
   
   The artifact is https://repo1.maven.org/maven2/org/apache/jena/jena-fuseki-server/4.10.0/
   
   While there has been some prototyping work of Fuseki Main + UI + Shiro + admin, it is only a proof-of-concept at the moment.
   
   


-- 
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: issues-unsubscribe@jena.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org