Skip to content

Working behind a proxy #205

@michaelruocco

Description

@michaelruocco

Hi,

It seems that it is not possible to use this library behind a proxy. I have a proxy that runs fine on my laptop but when I try to run it on a machine behind a proxy it looks as though it is unable to download a referenced schema:

uk.co.tpplc.middleware.ValidationException: com.github.fge.jsonschema.core.exceptions.ProcessingException: fatal: unable to dereference URI "http://json-schema.org/geo#"
level: "fatal"
uri: "http://json-schema.org/geo#"
exceptionMessage: "json-schema.org"

at uk.co.tpplc.middleware.Validator.validate(Validator.java:56)
at uk.co.tpplc.middleware.ValidatorTest.shouldReturnSchemaPointerForMissingFieldJson(ValidatorTest.java:196)
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:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
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:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Caused by: com.github.fge.jsonschema.core.exceptions.ProcessingException: fatal: unable to dereference URI "http://json-schema.org/geo#"
level: "fatal"
uri: "http://json-schema.org/geo#"
exceptionMessage: "json-schema.org"

at com.github.fge.jsonschema.core.load.URIManager.getContent(URIManager.java:115)
at com.github.fge.jsonschema.core.load.SchemaLoader$1.load(SchemaLoader.java:115)
at com.github.fge.jsonschema.core.load.SchemaLoader$1.load(SchemaLoader.java:109)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
at com.github.fge.jsonschema.core.load.SchemaLoader.get(SchemaLoader.java:172)
at com.github.fge.jsonschema.core.load.RefResolver.rawProcess(RefResolver.java:114)
at com.github.fge.jsonschema.core.load.RefResolver.rawProcess(RefResolver.java:51)
at com.github.fge.jsonschema.core.processing.RawProcessor.process(RawProcessor.java:77)
at com.github.fge.jsonschema.core.processing.RawProcessor.process(RawProcessor.java:41)
at com.github.fge.jsonschema.core.processing.ProcessorChain$ProcessorMerger.process(ProcessorChain.java:189)
at com.github.fge.jsonschema.core.processing.ProcessingResult.of(ProcessingResult.java:79)
at com.github.fge.jsonschema.core.processing.CachingProcessor$1.load(CachingProcessor.java:128)
at com.github.fge.jsonschema.core.processing.CachingProcessor$1.load(CachingProcessor.java:120)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
at com.github.fge.jsonschema.core.processing.CachingProcessor.process(CachingProcessor.java:109)
at com.github.fge.jsonschema.processors.validation.ValidationChain.process(ValidationChain.java:107)
at com.github.fge.jsonschema.processors.validation.ValidationChain.process(ValidationChain.java:57)
at com.github.fge.jsonschema.core.processing.ProcessorMap$Mapper.process(ProcessorMap.java:166)
at com.github.fge.jsonschema.core.processing.ProcessingResult.of(ProcessingResult.java:79)
at com.github.fge.jsonschema.core.processing.CachingProcessor$1.load(CachingProcessor.java:128)
at com.github.fge.jsonschema.core.processing.CachingProcessor$1.load(CachingProcessor.java:120)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)
at com.google.common.cache.LocalCache.get(LocalCache.java:3934)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)
at com.github.fge.jsonschema.core.processing.CachingProcessor.process(CachingProcessor.java:109)
at com.github.fge.jsonschema.processors.validation.InstanceValidator.process(InstanceValidator.java:110)
at com.github.fge.jsonschema.processors.validation.InstanceValidator.processObject(InstanceValidator.java:218)
at com.github.fge.jsonschema.processors.validation.InstanceValidator.process(InstanceValidator.java:151)
at com.github.fge.jsonschema.processors.validation.InstanceValidator.processArray(InstanceValidator.java:188)
at com.github.fge.jsonschema.processors.validation.InstanceValidator.process(InstanceValidator.java:149)
at com.github.fge.jsonschema.processors.validation.ValidationProcessor.process(ValidationProcessor.java:56)
at com.github.fge.jsonschema.processors.validation.ValidationProcessor.process(ValidationProcessor.java:34)
at com.github.fge.jsonschema.core.processing.ProcessingResult.of(ProcessingResult.java:79)
at com.github.fge.jsonschema.main.JsonSchema.doValidate(JsonSchema.java:76)
at com.github.fge.jsonschema.main.JsonSchema.validate(JsonSchema.java:109)
at uk.co.tpplc.middleware.Validator.validate(Validator.java:53)
... 36 more

I have managed to get around this issue by downloading the schema and referencing it locally. I intend to try creating a pull request to have a look and see if it is possible to add this functionality but I wanted to clarify whether or not the functionality already exists before doing so.

I have played around with the JsonSchemaFactory with creating a new builder and can see that it is possible to add a LoadingConfiguration which seemed like it might be the place to set some proxy config but it wasn't obvious where. If I were to try and work on adding this, is this where you would recommend I start looking?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions