question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Zuul2: Unable to load filters from within a jar

See original GitHub issue

Hi, I am packaging my zuul 2 server application as a jar and I included the groovy filter source files in it (in a com/company/apigateway/filters folder, which is the same path specified in the application.properties file).

When trying to run the app using java -jar myapp.jar, I get an error related to loading filters:

2018-05-30 08:22:31,533 INFO  com.netflix.zuul.init.ZuulFiltersModule [main] Using filter locations: 
2018-05-30 08:22:31,538 INFO  com.netflix.zuul.init.ZuulFiltersModule [main]   com/company/apigateway/filters/inbound
2018-05-30 08:22:31,538 INFO  com.netflix.zuul.init.ZuulFiltersModule [main]   com/company/apigateway/filters/outbound
2018-05-30 08:22:31,538 INFO  com.netflix.zuul.init.ZuulFiltersModule [main]   com/company/apigateway/filters/endpoint
2018-05-30 08:22:31,789 ERROR com.netflix.zuul.FilterFileManager [main] Error accessing directory in classloader. path=com/company/apigateway/filters/inbound
java.lang.IllegalArgumentException: URI is not hierarchical
	at java.io.File.<init>(File.java:418)
	at com.netflix.zuul.FilterFileManager.getDirectory(FilterFileManager.java:142)
	at com.netflix.zuul.FilterFileManager.getFiles(FilterFileManager.java:162)
	at com.netflix.zuul.FilterFileManager.manageFiles(FilterFileManager.java:200)
	at com.netflix.zuul.FilterFileManager.init(FilterFileManager.java:95)
	at com.netflix.governator.internal.JSR250LifecycleAction.call(JSR250LifecycleAction.java:83)
	at com.netflix.governator.ManagedInstanceAction.call(ManagedInstanceAction.java:34)
	at com.netflix.governator.LifecycleModule$LifecycleProvisionListener.onProvision(LifecycleModule.java:175)
	at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
	at com.netflix.governator.ProvisionMetricsModule$MetricsProvisionListener.onProvision(ProvisionMetricsModule.java:46)

So, after looking at the code, it looks like that Zuul is creating a new File object for each filter file found in the class path. But, the constructor of File class does not seem to accept file path from within jars.

The zuul2 wiki also mentions that

The source code for each Filter is written to a specified set of directories on the Zuul server that are periodically polled for changes. Updated filters are read from disk, dynamically compiled into the running server, and are invoked by Zuul for each subsequent request.

Bottom line, in order for Zuul2 to work, the fiters must be packaged in a folder outside the jar. Is that correct ? Thanks

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
artgoncommented, Jun 12, 2018

You can use the properties: zuul.filters.packages or zuul.filters.classes. For example: https://github.com/Netflix/zuul/blob/2.1/zuul-sample/src/main/resources/application.properties#L27

3reactions
Jovonscommented, Jun 1, 2018

I think that is right. zuul2 encourages using groovy for filters which is a dynamic jvm language. I guess the developer team wants to have it more like riemann, a real time pipe of processors. zuul 2 is designed to be of such must be because of netflix usages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overriding zuul error filter results in Forwarding error
Please check this solution: Spring Cloud: Zuul error handling. It worked for me, specially for Forwarding error of Zuul.
Read more >
Spring Boot - Zuul Proxy Server and Routing - Tutorialspoint
After “BUILD SUCCESSFUL”, you can find the JAR file under the build/libs directory. Now, run the JAR file by using the command shown...
Read more >
Netflix zuul example - zuul api gateway pattern - spring cloud ...
Learn to create load balancer using Netflix Zuul and its solid bonding with Spring Cloud. Here we will mainly concentrate on API gateway ......
Read more >
Spring Boot 2.7.0 available now
On behalf of the Spring Boot team and everyone that has ... IllegalStateException: Cannot load configuration class: com.man.config.ignite.
Read more >
Chapter 6. Service routing with Spring Cloud and Zuul
Using a services gateway with your microservices; Implementing a service gateway using Spring Cloud and Netflix Zuul; Mapping microservice routes in Zuul; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found