Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HAPI FHIR Core enforces a non-optional Jetty dependency breaking Spring WebFlux Applications #1481

Closed
krmeda opened this issue Sep 10, 2019 · 3 comments

Comments

@krmeda
Copy link

@krmeda krmeda commented Sep 10, 2019

HAPI FHIR Core with v4.0.0 has a compile dependency on Jetty Server breaking non-jetty implementers
For users of only the HAPI DSTU2/DSTU3 domain libraries (ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2) the transitive dependency of ca.uhn.hapi.fhir:hapi-fhir-base now has a compile level dependency on org.eclipse.jetty:jetty-server. This implies that users bring in the jetty server and if the user happens to be a Spring Webflux application, it also forces to use the jetty server instead of the default netty implementation.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://github.com/krmeda/demo-fhir-dependency-problem/tree/8224d88fe9db8f73a21bc2de2bb19d04a76629f0 for a demo project using DSTU2 structures working with 3.8.0 version of HAPI FHIR.
  2. Perform a ./gradlew bootRun to run the app
  3. From command line perform the following curl to verify result:
curl -v http://localhost:8080/infra/Audit/GIVEMEANEVENT | jq
  1. Checkout master on https://github.com/krmeda/demo-fhir-dependency-problem/. This uses the 4.0.1 dependency.
  2. Perform a ./gradle2 bootRun
  3. App fails to start with following log:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.8.RELEASE)

2019-09-10 10:38:14.429  INFO 96194 --- [           main] m.k.p.h.HapiDomainDemoApplication        : Starting HapiDomainDemoApplication on MACC02T36J0GTFM with PID 96194 (/Users/keerthiramanarayan/proto-git/krgh/demo-fhir-dependency-problem/build/classes/java/main started by keerthiramanarayan in /Users/keerthiramanarayan/proto-git/krgh/demo-fhir-dependency-problem)
2019-09-10 10:38:14.432  INFO 96194 --- [           main] m.k.p.h.HapiDomainDemoApplication        : No active profile set, falling back to default profiles: default
2019-09-10 10:38:15.343  INFO 96194 --- [           main] org.eclipse.jetty.util.log               : Logging initialized @1747ms to org.eclipse.jetty.util.log.Slf4jLog
2019-09-10 10:38:15.511  WARN 96194 --- [           main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/servlet/ServletHolder
2019-09-10 10:38:15.523  INFO 96194 --- [           main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-10 10:38:15.538 ERROR 96194 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start reactive web server; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/servlet/ServletHolder
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:81) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.refresh(ReactiveWebServerApplicationContext.java:66) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at me.keerthimeda.prototypes.hapidomaindemo.HapiDomainDemoApplication.main(HapiDomainDemoApplication.java:10) [main/:na]
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jetty/servlet/ServletHolder
        at org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory.createJettyServer(JettyReactiveWebServerFactory.java:174) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.boot.web.embedded.jetty.JettyReactiveWebServerFactory.getWebServer(JettyReactiveWebServerFactory.java:105) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext$ServerManager.<init>(ReactiveWebServerApplicationContext.java:196) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext$ServerManager.get(ReactiveWebServerApplicationContext.java:213) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.createWebServer(ReactiveWebServerApplicationContext.java:88) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        at org.springframework.boot.web.reactive.context.ReactiveWebServerApplicationContext.onRefresh(ReactiveWebServerApplicationContext.java:78) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
        ... 8 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.servlet.ServletHolder
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_222]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_222]
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_222]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_222]
        ... 14 common frames omitted

Expected behavior
Expect that the structures library only provide the support for structures with serializer and deserialization support instead of enforcing required on a HTTP Server implementation.

Environment (please complete the following information):

  • HAPI FHIR Version: 4.0.1
  • OS: Mac OS
@srdo

This comment has been minimized.

Copy link
Contributor

@srdo srdo commented Oct 17, 2019

I think this is my bad. The dependency was added in https://github.com/jamesagnew/hapi-fhir/pull/1336/files#diff-2c9dae56366ea937996c43839fcedb74, where we decided to move the code that needed it to another module. It looks like I forgot to remove the dependency. I think it should work to just delete it from the hapi-fhir-base pom.

@jamesagnew

This comment has been minimized.

Copy link
Owner

@jamesagnew jamesagnew commented Oct 17, 2019

@srdo - Makes sense. I'll do that now.

srdo added a commit to srdo/hapi-fhir that referenced this issue Oct 17, 2019
@srdo

This comment has been minimized.

Copy link
Contributor

@srdo srdo commented Oct 17, 2019

@jamesagnew Hapi-fhir-docs doesn't compile now, please see #1548

jamesagnew added a commit that referenced this issue Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.