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

Java modules causes resource loading to fail #72

Closed
05nelsonm opened this issue Mar 22, 2023 · 1 comment · Fixed by #75 or #76
Closed

Java modules causes resource loading to fail #72

05nelsonm opened this issue Mar 22, 2023 · 1 comment · Fixed by #75 or #76
Assignees
Labels
bug Something isn't working

Comments

@05nelsonm
Copy link
Owner

05nelsonm commented Mar 22, 2023

Original report: 05nelsonm/kmp-tor#291

cc: @craigraw

As per the docs for Class.getResourceAsStream, any resources in a jar are encapsulated if that class is in a named module. This means that the binary resources for kmp-tor cannot be loaded by Extractor.kt, since in a modular setting it is in a different jar and therefore module.

The following error occurs:

io.matthewnelson.kmp.tor.manager.common.exceptions.TorManagerException: io.matthewnelson.kmp.tor.binary.extract.ExtractionException: Resource not found: kmptor/geoip.gz
	at [email protected]/io.matthewnelson.kmp.tor.TorConfigProviderJvm.extractGeoIpV4File(TorConfigProviderJvm.kt:63)
	at [email protected]/io.matthewnelson.kmp.tor.manager.TorConfigProvider.retrieve$kmp_tor_manager(TorConfigProvider.kt:253)
	at [email protected]/io.matthewnelson.kmp.tor.manager.KmpTorLoader$load$validated$1.invokeSuspend(KmpTorLoader.kt:171)
	at kotlin.stdlib/kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at [email protected]/kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: io.matthewnelson.kmp.tor.binary.extract.ExtractionException: Resource not found: kmptor/geoip.gz
	at [email protected]/io.matthewnelson.kmp.tor.binary.extract.internal.ExtractorDelegate.resourceNotFound$kmp_tor_binary_extract(-ExtractorDelegate.kt:207)
	at [email protected]/io.matthewnelson.kmp.tor.binary.extract.Extractor$extract$1.invoke(Extractor.kt:46)
	at [email protected]/io.matthewnelson.kmp.tor.binary.extract.Extractor$extract$1.invoke(Extractor.kt:42)
	at [email protected]/io.matthewnelson.kmp.tor.binary.extract.internal.ExtractorDelegate.extract$kmp_tor_binary_extract(-ExtractorDelegate.kt:76)
	at [email protected]/io.matthewnelson.kmp.tor.binary.extract.Extractor.extract(Extractor.kt:42)
	at [email protected]/io.matthewnelson.kmp.tor.TorConfigProviderJvm.extractGeoIpV4File(TorConfigProviderJvm.kt:57)
	... 7 more
Caused by: java.lang.NullPointerException
	at [email protected]/io.matthewnelson.kmp.tor.binary.extract.Extractor$extract$1.invoke(Extractor.kt:44)
	... 11 more

Probably the answer is to use a 'loader' class contained in the resources jar for this purpose.

I've committed the current state of my test project to https://github.com/craigraw/kmp-tor-java, which produces this error. BTW, I'm happy to wait for the 2.0.0 release - it may make more sense at this point to wait for kmp-tor to support modular applications natively if that is a goal.

@05nelsonm
Copy link
Owner Author

Still not fixed. Need to call getResourceAsStream from the Loader classes, not from Extract

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
1 participant