Skip to content

NPE caused by using ClassLoader.getSystemResourceAsStream in OSGI environment #423

@kdvolder

Description

@kdvolder

RandomWordList initialization crashes in OSGI environment because it seems to be trying to use the system classloader to load application resources. This essentially makes the client unusable in OSGI environment as its not possible to instantiate it properly. (Well, I suppose we could try copying whatever resources it is looking for into the system classpath as a workaround)

The WordListRandomWords class should use its own classloader to load the wordlists that are enclosed in its own bundle rather than the system classloader.

This is the stacktrace of the NPE I got:

!ENTRY org.springframework.ide.eclipse.boot.dash 4 0 2016-03-21 16:36:59.521
!MESSAGE 
!STACK 0
java.lang.NullPointerException
    at java.io.Reader.<init>(Reader.java:78)
    at java.io.InputStreamReader.<init>(InputStreamReader.java:72)
    at org.cloudfoundry.operations.applications.WordListRandomWords.getWordList(WordListRandomWords.java:53)
    at org.cloudfoundry.operations.applications.WordListRandomWords.<init>(WordListRandomWords.java:33)
    at org.cloudfoundry.operations.applications.DefaultApplications.<init>(DefaultApplications.java:124)
    at org.cloudfoundry.operations.DefaultCloudFoundryOperations.<init>(DefaultCloudFoundryOperations.java:58)
    at org.cloudfoundry.operations.CloudFoundryOperationsBuilder.build(CloudFoundryOperationsBuilder.java:62)
    at org.springframework.ide.eclipse.boot.dash.cloudfoundry.client.v2.DefaultCloudFoundryClientFactoryV2.getClient(DefaultCloudFoundryClientFactoryV2.java:46)
    at org.springframework.ide.eclipse.boot.dash.cloudfoundry.client.CloudFoundryClientFactory.getClient(CloudFoundryClientFactory.java:44)
    at org.springframework.ide.eclipse.boot.dash.cloudfoundry.CloudFoundryRunTarget.createClient(CloudFoundryRunTarget.java:145)
    at org.springframework.ide.eclipse.boot.dash.cloudfoundry.CloudFoundryRunTarget.connect(CloudFoundryRunTarget.java:102)
    at org.springframework.ide.eclipse.boot.dash.cloudfoundry.ops.ConnectOperation.doCloudOp(ConnectOperation.java:51)
    at org.springframework.ide.eclipse.boot.dash.cloudfoundry.ops.CloudOperation.runOp(CloudOperation.java:37)
    at org.springframework.ide.eclipse.boot.dash.cloudfoundry.ops.CloudOperation.runOp(CloudOperation.java:1)
    at org.springframework.ide.eclipse.boot.dash.cloudfoundry.ops.Operation.run(Operation.java:38)
    at org.springframework.ide.eclipse.boot.dash.cloudfoundry.ops.OperationsExecution$1.run(OperationsExecution.java:37)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

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