credentials / irma_api_server

This project has been deprecated, use https://github.com/privacybydesign/irmago
BSD 3-Clause "New" or "Revised" License
5 stars 10 forks source link

[v1.4.2]: gradle appRun: ERROR org.irmacard.api.web.ApiApplication - Store initialization failed #28

Closed mrtuborg closed 6 years ago

mrtuborg commented 6 years ago

Hello,

I am trying to follow Readme for building irma_api_server and getting following error:

irma_api_server [tags/v1.4.2] % gradle --version

------------------------------------------------------------
Gradle 4.3.1
------------------------------------------------------------

Build time:   2018-04-30 11:59:57 UTC
Revision:     cdb459eef3c887e603a49388c6e83c3ba6fd3567

Groovy:       2.4.8
Ant:          Apache Ant(TM) version 1.10.5 compiled on August 21 2018
JVM:          1.8.0_181 (Oracle Corporation 25.181-b15)
OS:           Linux 4.18.9-200.fc28.x86_64 amd64
21:35:36.780 [main] ERROR org.irmacard.api.web.ApiApplication - Store initialization failed:
java.lang.NullPointerException: null
        at org.irmacard.credentials.info.TreeWalker.parseConfiguration(TreeWalker.java:47)
        at org.irmacard.credentials.info.DescriptionStore.initialize(DescriptionStore.java:115)
        at org.irmacard.credentials.info.DescriptionStore.initialize(DescriptionStore.java:95)
        at org.irmacard.credentials.info.DescriptionStore.initialize(DescriptionStore.java:109)
        at org.irmacard.api.web.ApiApplication.loadOrUpdateIrmaConfiguration(ApiApplication.java:127)
        at org.irmacard.api.web.ApiApplication.<init>(ApiApplication.java:89)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1375)
        at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1007)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:975)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1067)
        at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1059)
        at org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:385)
        at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:342)
        at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
        at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
        at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
        at javax.servlet.GenericServlet.init(GenericServlet.java:244)
        at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:612)
        at org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:395)
        at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:871)
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:298)
        at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1349)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:505)
        at org.akhikhl.gretty.JettyWebAppContext.super$10$doStart(JettyWebAppContext.groovy)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1206)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:130)
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuper0(ScriptBytecodeAdapter.java:150)
        at org.akhikhl.gretty.JettyWebAppContext.doStart(JettyWebAppContext.groovy:44)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:163)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
        at org.eclipse.jetty.server.Server.start(Server.java:387)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
        at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
        at org.eclipse.jetty.server.Server.doStart(Server.java:354)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.util.component.LifeCycle$start$0.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
        at org.akhikhl.gretty.JettyServerManager.startServer(JettyServerManager.groovy:45)
        at org.akhikhl.gretty.ServerManager$startServer$0.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        at org.akhikhl.gretty.Runner.run(Runner.groovy:119)
        at org.akhikhl.gretty.Runner.this$2$run(Runner.groovy)
        at org.akhikhl.gretty.Runner$this$2$run.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
        at org.akhikhl.gretty.Runner.main(Runner.groovy:46)
confiks commented 6 years ago

Hi! Are the scheme managers in the irma_configuration folder correctly checked out and in the right location (src/main/resources/irma_configration by default)? It seems to be an error while traversing those files. The relevant code for the traversing is in irma_api_common, another repository in this organization.

You could try to use this script to setup a development environment (with a keyshare server as well, which you probably don't need): https://gist.github.com/confiks/ab7ae1802d2b64dc20659c0addcc5613

If there's anything else, please let us know.

mrtuborg commented 6 years ago

According README, I have created directory:

irma_api_server [tags/v1.4.2] % ls -lah src/main/resources/irma_configuration 
totalt 4,0K
drwxrwxr-x  3 user user   23 sep.  29 13:59 .
drwxrwxr-x  3 user user  140 sep.  29 13:59 ..
drwxrwxr-x 16 user user 4,0K sep.  29 13:59 irma-demo

Where irma-demo was created by another tip in README:

irma_api_server [tags/v1.4.2] % cd src/main/resources/irma_configuration/irma-demo 
irma-demo [master] % grv
origin  https://github.com/privacybydesign/irma-demo-schememanager (fetch)
origin  https://github.com/privacybydesign/irma-demo-schememanager (push)
irma-demo [master] %

My configuration file:

irma-demo [master] % cat /etc/irma_api_server/config.json 
{
    // Configuration file for unit tests, not used for anything else
    "enable_verification": true,
    "enable_issuing": true,
    "enable_signing": true,
    "allow_unsigned_issue_requests": false,
    "allow_unsigned_verification_requests": true,
    "allow_unsigned_signature_requests": true,
    "authorized_idps": {
        "testip": [ "irma-demo.MijnOverheid.ageLower" ]
    },
    "authorized_sps": {
        "testsp": [ "irma-demo.*" ]
    },
    "authorized_sigclients": {
        "testsigclient": [ "irma-demo.*" ]
    }
}
irma-demo [master] % 

Thanks for the script, looks like a missing chain in documentation, it is very helpful to understand this. I will look on the script in parallel while investigating issue with gradle appRun

mrtuborg commented 6 years ago

The whole error output is here: gradle output gist on issue #28

sietseringers commented 6 years ago

The problem still seems to be that it can't find any schemes in the irma_configuration folder it is looking at.

You mention /etc/irma_api_server/config.json and src/main/resources/irma_configuration - but the server always looks for config.json and the irma_configuration folder (and in fact all other configuration files as well) in the same place. The IRMA_API_CONF environment variable can be used to instruct the server to look for (all) its configuration in a place of your choosing (such as /etc/irma_api_server). So if you're using IRMA_API_CONF in order to point the server to /etc/irma_api_server, then you should put your irma_configuration folder there as well. If not, config.json should also be in src/main/resources

mrtuborg commented 6 years ago

@sietseringers Thanks for your help. I have just tried to put config.json and irma_configuration in one place:

irma_api_server [tags/v1.4.2] % ls -1 src/main/resources
config.json
config.sample-demo.json
config.sample.json
irma_configuration
logback.xml
README

It still does not work. The same error. But script from @confiks (after a little bit of polishing to linux world) works fine.

So, I am going to dig in to outcome from the script and publish solution here.

mrtuborg commented 6 years ago

@sietseringers You was right. I just was needed to clean the build and apply your suggestions. Now everything works.

Can I create PR and update README.md for IRMA_API_CONF usage ?

sietseringers commented 6 years ago

Yes, please, we'd be grateful!