felix-atomos icon indicating copy to clipboard operation
felix-atomos copied to clipboard

gosh_profile errors on startup of substrate

Open fipro78 opened this issue 3 years ago • 3 comments

If I try to configure a custom gosh_profile and motd with the created substrate I get the following error:

/gosh_profile: ERROR: java.lang.IllegalArgumentException: Cannot coerce resolve(Token) to any of []

With the Atomos substrate examples the error looks a bit different, but almost the same:

gosh_profile: ERROR: java.lang.IllegalArgumentException: Cannot coerce addcommand(Token, BundleContextImpl) to any of []

Somehow the gosh_profile execution does not work correctly. I tried several things to make it work, but I don't get the point what is missing in the reflection configuration. Even using the java_agent and inspecting the resulting configs did not uncover anything related to this specific thing. Any ideas what could be missing?

fipro78 avatar Sep 30 '22 08:09 fipro78

Further investigation results:

I added the following blocks to the reflect-config.json to make some things work:

  {
    "name" : "java.lang.Exception",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true,
    "allDeclaredClasses" : true,
    "allPublicClasses" : true
  },
  {
    "name": "org.apache.felix.gogo.command.Basic",
    "allPublicConstructors": true,
    "allPublicMethods": true,
    "allDeclaredMethods": true,
    "allPublicFields": true,
    "allDeclaredFields": true,
    "methods":[{"name":"resolve","parameterTypes":["org.osgi.framework.Bundle[]"] }]
  },
  {
    "name": "org.apache.felix.gogo.runtime.CommandProcessorImpl",
    "allPublicMethods": true,
    "allDeclaredMethods": true,
    "allPublicFields": true,
    "allDeclaredFields": true
  },

This way the error with addCommand is gone and I am able to use the exception function in the Gogo shell. But the resolve method is still not working.

fipro78 avatar Sep 30 '22 08:09 fipro78

The issue about the resolve command seems to come out of this gosh_profile line

if { $.gosh_quiet } { } { cat ($0 resolve motd) }

In the substrate version the resolve seems to be not resolved correctly for whatever reason (I wonder why it works as resolve takes a Bundle[] argument and motd is a simple file). I changed this to

if { $.gosh_quiet } { } { cat ./etc/motd }

which makes an assumption on the location of the motd file. Maybe this can be done in a more elegant way, but my Gogo shell scripting knowledge is not that experienced.

Anyhow, it doesn't seem to be an issue in Atomos, maybe interesting for the examples to add the handling of the exit command etc. I'll leave it to the Atomos team if the ticket should be closed or not, dependent on the decision if it is important for the examples.

fipro78 avatar Sep 30 '22 11:09 fipro78

Perhaps open an issue against felix-dev to consider adding a native image resource file to gogo that includes the necessary reflection config json files it needs to make it work with native image?

tjwatson avatar Sep 30 '22 13:09 tjwatson