Skip to content

NullPointerException when querying the runtime dot #14

Open
@timothyjward

Description

@timothyjward

Current Behavior

The generation of the Runtime DTO fails on line

runtimeDTO.serviceReference = context.getServiceReference().adapt(ServiceReferenceDTO.class);

This is because the service is manually registered, and so the ComponentContext has no service registration. The manual registration should be used instead, and the component context can be removed throughout, replacing it simply with a BundleContext

TEST org.osgi.test.cases.webservice.junit.EndpointRegistrationTests#testNotRegisterableEndpoint() <<< ERROR: Cannot invoke "org.osgi.framework.ServiceReference.adapt(java.lang.Class)" because the return value of "org.osgi.service.component.ComponentContext.getServiceReference()" is null
java.lang.NullPointerException: Cannot invoke "org.osgi.framework.ServiceReference.adapt(java.lang.Class)" because the return value of "org.osgi.service.component.ComponentContext.getServiceReference()" is null
	at org.eclipse.osgi.technology.webservices.registrar.EndpointRegistrar.getRuntimeDTO(EndpointRegistrar.java:258)
	at org.osgi.test.cases.webservice.junit.WebServiceRuntimeTracker.waitForChange(WebServiceRuntimeTracker.java:146)
	at org.osgi.test.cases.webservice.junit.EndpointRegistrationTests.testNotRegisterableEndpoint(EndpointRegistrationTests.java:174)

Expected Behavior

It should be possible to call the getRuntimeDTO() method without a NullPointerException being thrown.

Steps To Reproduce

All calls to this method will fail.

Version

1.0.0-SNAPSHOT

Are you interested in contributing a solution yourself?

Perhaps, but please help me

Anything else?

No response

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