[jboss-osgi-issues] [JBoss JIRA] (JBOSGI-507) NPE in URL.openConnection() for bundle:// protocol

Martin Ždila (Commented) (JIRA) jira-events at lists.jboss.org
Wed Jan 11 09:18:09 EST 2012


    [ https://issues.jboss.org/browse/JBOSGI-507?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12655185#comment-12655185 ] 

Martin Ždila commented on JBOSGI-507:
-------------------------------------

Hello

I was wrong in my first description. NPE is thrown when the resource doesn't exist. URL.openConnection() must throw IOException instead. The source code of the atached testcase is:

{code:java}
package com.mwaysolutions.gofer2.sandbox2;

import java.net.URL;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class SandboxActivator implements BundleActivator {

	@Override
	public void start(final BundleContext context) throws Exception {
		final Bundle bundle = context.getBundle();
		final URL baseUrl = bundle.getEntry("com/mwaysolutions/gofer2/sandbox2/");
		final URL url = baseUrl.toURI().resolve("not-existing-resource").toURL();
		url.openConnection();
	}

	@Override
	public void stop(final BundleContext context) throws Exception {

	}

}
{code}

{noformat}
15:15:02,483 ERROR [org.jboss.as.osgi] (MSC service thread 1-2) JBAS011912: Cannot start bundle: gofer-sandbox2:1.0.0: org.osgi.framework.BundleException: Cannot start bundle: gofer-sandbox2:1.0.0
	at org.jboss.osgi.framework.internal.HostBundleState.transitionToActive(HostBundleState.java:328) [jbosgi-framework-core-1.1.0.jar:1.1.0]
	at org.jboss.osgi.framework.internal.HostBundleState.startInternal(HostBundleState.java:223) [jbosgi-framework-core-1.1.0.jar:1.1.0]
	at org.jboss.osgi.framework.internal.AbstractBundleState.start(AbstractBundleState.java:494) [jbosgi-framework-core-1.1.0.jar:1.1.0]
	at org.jboss.as.osgi.deployment.BundleStartTracker$1.processService(BundleStartTracker.java:144) [jboss-as-osgi-service-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.as.osgi.deployment.BundleStartTracker$1.transition(BundleStartTracker.java:119) [jboss-as-osgi-service-7.1.0.CR1b.jar:7.1.0.CR1b]
	at org.jboss.msc.service.ServiceControllerImpl.invokeListener(ServiceControllerImpl.java:1429) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
	at org.jboss.msc.service.ServiceControllerImpl.access$2600(ServiceControllerImpl.java:49) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
	at org.jboss.msc.service.ServiceControllerImpl$ListenerTask.run(ServiceControllerImpl.java:1952) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
	at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]
Caused by: java.lang.NullPointerException
	at org.jboss.osgi.framework.internal.BundleProtocolHandler.openConnection(BundleProtocolHandler.java:52) [jbosgi-framework-core-1.1.0.jar:1.1.0]
	at org.jboss.osgi.framework.internal.URLHandlerPlugin$URLStreamHandlerProxy.openConnection(URLHandlerPlugin.java:309) [jbosgi-framework-core-1.1.0.jar:1.1.0]
	at java.net.URL.openConnection(URL.java:945) [:1.6.0_26]
	at com.mwaysolutions.gofer2.sandbox2.SandboxActivator.start(SandboxActivator.java:16)
	at org.jboss.osgi.framework.internal.HostBundleState.transitionToActive(HostBundleState.java:300) [jbosgi-framework-core-1.1.0.jar:1.1.0]
	... 10 more
{noformat}
                
> NPE in URL.openConnection() for bundle:// protocol
> --------------------------------------------------
>
>                 Key: JBOSGI-507
>                 URL: https://issues.jboss.org/browse/JBOSGI-507
>             Project: JBoss OSGi
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Core Framework
>            Reporter: Martin Ždila
>            Assignee: Thomas Diesler
>            Priority: Critical
>         Attachments: gofer-sandbox2.jar
>
>
> Version: jboss-as-7.1.0.CR1b
> I am getting NullPointerException when calling new URL("bundle://my.bundle-60-0-0/some/path/resource.xml").openConnection();
> The URL is actually resolved as bundle.getEntry("some/path/resource.xml") and the resource exists. The testcase works in Apache Felix.
> Stacktrace:
> 15:49:09,983 WARN  [org.eclipse.jetty.util.log] (qtp767222020-128) /some/path/resource.xml: java.lang.NullPointerException
> 	at org.jboss.osgi.framework.internal.BundleProtocolHandler.openConnection(BundleProtocolHandler.java:52)
> 	at org.jboss.osgi.framework.internal.URLHandlerPlugin$URLStreamHandlerProxy.openConnection(URLHandlerPlugin.java:309)
> 	at java.net.URL.openConnection(URL.java:945) [:1.6.0_26]
>         ...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the jboss-osgi-issues mailing list