european-commission-empl / european-digital-credentials

European Union Public License 1.2
5 stars 3 forks source link

Issues with logging in to the Europass in local-tomcat #8

Open SeSodesa opened 2 years ago

SeSodesa commented 2 years ago

I have been able to compile the project with Maven and NPM, but have since run into issues with logging in to the Europass and viewing the diploma pages. I have done as follows, with slight modifications to the actual contents of certain strings:

  1. copied the contents of configuration/documentation/mvn_settings.xml into the file $HOME/.m2/settings.xml,

  2. installed the .jar files in configuration/external_libs/ into my local Maven repository $HOME/.m2/repository/, so that Maven can locate them during the project build process,

  3. disabled any malfunctioning tests that prevent Maven from compiling the project,

  4. built the project with Maven and NPM in that order and

  5. placed the generated .war files into my tomcat/webapps/ folder.

I am able to start up the Angular front-end server at localhost:4200 by running

ng serve --open

in edci-viewer/edci-viewer-web/src/main/angular, as can be seen in the below video.

https://user-images.githubusercontent.com/19917000/134295319-08cc4fd8-673d-431a-b83b-04ddd125f470.mp4

The error seen in the lower right corner turns out to be the result of a CORS violation. This is strange, because the file

~/europass-digital-credentials/edci-viewer/edci-viewer-web/src/main/resources/config/ext/viewer.properties

says the following:

app.host=localhost
app.port=8080
server.full.address=${app.schema}://${app.host}:${app.port}
⋮
#CORS WHITELIST
allowed.domains=${server.full.address},http://localhost:4200

Now, Tomcat itself is running at localhost:8080, as can be verified by running the command systemctl status tomcat (and just by looking at the fact that the 404 page was displayed in the first place):

● tomcat.service - Tomcat 8.5 servlet container
     Loaded: loaded (/etc/systemd/system/tomcat.service; disabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-09-22 09:16:14 EEST; 17s ago
    Process: 5228 ExecStart=/opt/tomcat/active-version/bin/startup.sh (code=exited, status=0/SUCCESS)
   Main PID: 5246 (java)
      Tasks: 20 (limit: 14168)
     Memory: 783.0M
     CGroup: /system.slice/tomcat.service
             └─5246 /usr/lib/jvm/java-8-openjdk-amd64/bin/java -Djava.util.logging.config.file=/opt/>

Logging in to the Tomcat manager app also reveals, that the .war files have been deployed successfully:

Screenshot from 2021-09-22 09-19-42

However, trying to actually start the webapps up in the manager results in an error

FAIL - Application at context path [/europass2/edci-viewer] could not be started.

Looking into the logs in

/opt/tomcat/apache-tomcat-8.5.70/logs/catalina.out

reveals the following:

2021-09-16 10:41:51,665 [http-nio-8080-exec-5] ERROR ContextLoader -  - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [eu.europa.ec.empl.edci.viewer.service.ViewerConfigService]; nested exception is java.io.FileNotFoundException: /opt/tomcat/apache-tomcat-8.5.70/conf/edci/viewer/viewer.properties (No such file or directory)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:189)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4763)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5232)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1405)
    at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:697)
    at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:216)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:211)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:126)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:109)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:196)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:669)
    at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:378)
    at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:56)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:364)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:624)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:831)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1650)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.FileNotFoundException: /opt/tomcat/apache-tomcat-8.5.70/conf/edci/viewer/viewer.properties (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at org.springframework.core.io.UrlResource.getInputStream(UrlResource.java:186)
    at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:159)
    at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:99)
    at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:73)
    at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:59)
    at org.springframework.core.io.support.ResourcePropertySource.<init>(ResourcePropertySource.java:67)
    at org.springframework.core.io.support.DefaultPropertySourceFactory.createPropertySource(DefaultPropertySourceFactory.java:37)
    at org.springframework.context.annotation.ConfigurationClassParser.processPropertySource(ConfigurationClassParser.java:463)
    at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:280)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181)
    ... 50 more
16-Sep-2021 10:41:51.668 SEVERE [http-nio-8080-exec-5] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file
16-Sep-2021 10:41:51.669 SEVERE [http-nio-8080-exec-5] org.apache.catalina.core.StandardContext.startInternal Context [/europass2/edci-viewer] startup failed due to previous errors

In other words, the viewer.properties file located in the sources and whose contents contain a CORS whitelist must not have been placed into a correct location in the .war file generated by the Maven build.

Now, I am still learning the technologies used here, and apparently an instance of a MitreID server also needs to be set up as well to make this work, but since some settings seem to be off from the get-go, there is not much I can do. I can program, but I can't know how a system is supposed to work without these semantic errors (?), if there is no documentation of how these different components are supposed to be integrated.

My question then is, what exactly do I need to set up (and how) to be able to log into Europass locally, and is everything in the settings (disregarding any user-defined admin usernames and passwords) as intended? If it is not, what do I need to change to have the compilation process work as intended, such as having the viewer.properties file properly copied to a desired location?

SeSodesa commented 2 years ago

Or maybe the .properties file is to be copied manually to the Tomcat conf folder? If so, it wouldn't hurt to know what else needs to be deployed manually. Maybe a clear mention in the documentation for any Tomcat newcomers would be in place?

SeSodesa commented 2 years ago

As an update, moving the

edci-viewer/edci-viewer-web/src/main/resources/config/ext//viewer.properties

file to the location

$CATALINA_HOME/conf/edci/viewer/viewer.properties

indicated by the error message in catalina.out did not resolve the issue. Tomcat still complains about a missing file in exactly the same manner, even after it has been restarted.

Edit: this should not be a permissions issue, as Tomcat is the sole owner of the $CATALINA_HOME directory.