Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Docker image error: 401 on correct Password and user. #531

Open
CzarMich opened this issue Jan 19, 2022 · 1 comment
Open

Docker image error: 401 on correct Password and user. #531

CzarMich opened this issue Jan 19, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@CzarMich
Copy link

I passed my Variables as;

export password='SECURITY_AUTHPASSWORD=password' export authtype='SECURITY_AUTHTYPE=BASIC' export user='SECURITY_AUTHUSER=admin' export url='FHIR_BRIDGE_EHRBASE_BASE_URL=http://IP:8081/' export image='ehrbase/fhir-bridge:1.4.2'
After which I run
docker run -p 8888:8888 -e $url -e $authtype -e $user -e $password --name=fhirBridge $image

But with various changes in implementation; nothing seems to work out. I have even tried running on the same machine (localhost) where the Better Repository is held, but still same result.

Here is the output printed on exit;
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _ | \ \ \
\/ )| |)| | | | | || (| | ) ) ) )
' |
| .__|| ||| |_, | / / / /
=========||==============|/=///_/
:: Spring Boot :: (v2.5.5)

2022-01-19 00:20:09.030 INFO 1 --- [ main] o.e.fhirbridge.FhirBridgeApplication : Starting FhirBridgeApplication using Java 11.0.13 on 97129927745f with PID 1 (/workspace/BOOT-INF/classes started by cnb in /workspace)
2022-01-19 00:20:09.043 INFO 1 --- [ main] o.e.fhirbridge.FhirBridgeApplication : No active profile set, falling back to default profiles: default
2022-01-19 00:20:27.287 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2022-01-19 00:20:27.290 INFO 1 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.53]
2022-01-19 00:20:27.657 INFO 1 --- [ main] o.a.c.c.C.[.[localhost].[/fhir-bridge] : Initializing Spring embedded WebApplicationContext
Skipping auto-registration
2022-01-19 00:21:25.801 INFO 1 --- [ main] ca.uhn.hl7v2.util.Home : hapi.home is set to /workspace/.
2022-01-19 00:21:25.990 INFO 1 --- [ main] ca.uhn.hl7v2.VersionLogger : HAPI version is: 2.3
2022-01-19 00:21:26.007 INFO 1 --- [ main] ca.uhn.hl7v2.VersionLogger : Default Structure libraries found for HL7 versions 2.3.1, 2.5,
2022-01-19 00:21:31.453 INFO 1 --- [ main] o.e.f.c.e.EhrbaseTemplateInitializer : Initializing templates...
2022-01-19 00:21:32.128 INFO 1 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2022-01-19 00:21:32.280 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'templateInitializer' defined in class path resource [org/ehrbase/fhirbridge/config/ehrbase/EhrbaseConfiguration.class]: Invocation of init method failed; nested exception is org.ehrbase.client.exception.WrongStatusCodeException: Wrong Status code. Expected: [200, 204, 404]. Got: 401. Error message:
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.10.jar:5.3.10]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.5.5.jar:2.5.5]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~[spring-boot-2.5.5.jar:2.5.5]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[spring-boot-2.5.5.jar:2.5.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) ~[spring-boot-2.5.5.jar:2.5.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-2.5.5.jar:2.5.5]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332) ~[spring-boot-2.5.5.jar:2.5.5]
at org.ehrbase.fhirbridge.FhirBridgeApplication.main(FhirBridgeApplication.java:13) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[workspace/:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[workspace/:na]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[workspace/:na]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[workspace/:na]
Caused by: org.ehrbase.client.exception.WrongStatusCodeException: Wrong Status code. Expected: [200, 204, 404]. Got: 401. Error message:
at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient.checkStatus(DefaultRestClient.java:283) ~[client-10cce9b.jar:na]
at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestClient.internalGet(DefaultRestClient.java:230) ~[client-10cce9b.jar:na]
at org.ehrbase.client.openehrclient.defaultrestclient.DefaultRestTemplateEndpoint.findTemplate(DefaultRestTemplateEndpoint.java:72) ~[client-10cce9b.jar:na]
at org.ehrbase.fhirbridge.config.ehrbase.EhrbaseTemplateInitializer.afterPropertiesSet(EhrbaseTemplateInitializer.java:71) ~[classes/:na]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.10.jar:5.3.10]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.10.jar:5.3.10]`

@CzarMich CzarMich added the bug Something isn't working label Jan 19, 2022
@ejarte
Copy link

ejarte commented Feb 10, 2022

Hi,
I solved it by adding a file called .env.ehrbase

SERVER_NODENAME=local.ehrbase.org
SECURITY_AUTHTYPE=BASIC
SECURITY_AUTHUSER=myuser
SECURITY_AUTHPASSWORD=myPassword432
SECURITY_AUTHADMINUSER=myadmin
SECURITY_AUTHADMINPASSWORD=mySuperAwesomePassword123
SECURITY_OAUTH2USERROLE=USER
SECURITY_OAUTH2ADMINROLE=ADMIN
SPRING_SECURITY_OAUTH2_RESOURCESERVER_JWT_ISSUERURI=
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE=env,health,info,metrics,prometheus
MANAGEMENT_ENDPOINTS_WEB_BASEPATH=/management
MANAGEMENT_ENDPOINT_ENV_ENABLED=false
MANAGEMENT_ENDPOINT_HEALTH_ENABLED=false
MANAGEMENT_ENDPOINT_HEALTH_DATASOURCE_ENABLED=false
MANAGEMENT_ENDPOINT_INFO_ENABLED=false
MANAGEMENT_ENDPOINT_METRICS_ENABLED=false
MANAGEMENT_ENDPOINT_PROMETHEUS_ENABLED=false
MANAGEMENT_ENDPOINT_HEALTH_PROBES_ENABLED=false

and added it to my docker-compose.yml

version: '3'
services:
  ehrbase-db:
    image: ehrbase/ehrbase-postgres:latest
    ports:
      - 5432:5432
    networks:
      - ehrbase-network
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      EHRBASE_USER: ehrbase
      EHRBASE_PASSWORD: ehrbase
  ehrbase:
    image: ehrbase/ehrbase:next
    ports:
      - 8080:8080
    networks:
      - ehrbase-network
    env_file:
      - .env.ehrbase
    environment:
      DB_URL: jdbc:postgresql://ehrbase-db:5432/ehrbase
      DB_USER: ehrbase
      DB_PASS: ehrbase
      ADMIN_API_ACTIVE: 'true'
    depends_on:
      - ehrbase-db
  fhir-bridge:
    image: ehrbase/fhir-bridge:1.4.2
    ports:
      - 8888:8888
    networks:
      - ehrbase-network
    env_file:
      - .env.ehrbase
    environment:
      FHIR_BRIDGE_EHRBASE_BASE_URL: http://ehrbase:8080/ehrbase/
    depends_on:
      - ehrbase
networks:
  ehrbase-network: { }

Hope this will solve you problem!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants