Pergunta

We are having a lot of issues with devkit built jars that try to resolve files based on either of these methods:

InputStream in = this.getClass().getClassLoader().getResourceAsStream(configFile);
InputStream in = IOUtils.getResourceAsStream(configFile, getClass());

The project works fine when building and running from the original project that compiles down to the devkit update site(ie the project that is using the devkit archtype and @Connector annotated classes), but when running from a project that uses the devkit update site we get file resolution problems.

I can confirm we have the wanted files in src/main/resources or src/test/resources. we are using relative paths for the configFile variable eg file.propertites

Foi útil?

Solução

What may happen is that the classloader where your connector class is loaded is different from the classloader where it is used, preventing the load of the classpath resource.

Try with:

Thread.currentThread().getContextClassLoader().getResourceAsStream(configFile)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top