users@glassfish.java.net

Error when trying to restart Glassfish with osgi bundles - server crashes

From: Peter Penzov <peter.penzov_at_gmail.com>
Date: Wed, 11 Jul 2012 22:10:27 +0300

Hi,
    I created osgi bundle with this activator:

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.HashMap;

import java.util.Properties;
import org.DX_57.osgi.SB_27.api.SessionBuffer;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.util.tracker.ServiceTracker;

public class SessionBufferActivator implements BundleActivator {

    public static final String DSNAME = "jdbc/Oracle";
    public ServiceTracker st;
    private SessionBufferImpl sh = new SessionBufferImpl();
    // Generate HashMap with settings values when the bundle is loaded
    public HashMap<String, String> getSettings() {
        return (HashMap<String, String>) sh.getSettings();
    }

    // Register the bundle as OSGI service
    @Override
    public void start(final BundleContext bc) throws Exception {
        debug("Session Buffer 27 Activator started");

        // Get Datasource Datasource is registered as OSGI service
        Filter filter = bc.createFilter("(&" + "(" + Constants.OBJECTCLASS
                + "=" + DataSource.class.getName() + ")" + "(jndi-name="
                + DSNAME + ")" + ")");
        st = new ServiceTracker(bc, filter, null) {

            @Override
            public Object addingService(ServiceReference reference) {
                DataSource ds = (DataSource) bc.getService(reference);
                try {
                    debug(ds.getConnection().toString());

                    sh.setDataSource(ds);
                    ServiceRegistration registerService =
bc.registerService(SessionBuffer.class.getName(), sh, new Properties());

                } catch (SQLException e) {
                }

                return super.addingService(reference);
            }

            @Override
            public void removedService(ServiceReference reference,
                    Object service) {
                super.removedService(reference, service);
            }
        };
        st.open();
        // Unitialize the settings values from Oracle when the module is
loaded
        sh.initSettings();

    }

    // Unregister the bundle
    @Override
    public void stop(BundleContext bc) throws Exception {
        boolean ungetService =
bc.ungetService(bc.getServiceReference(SessionBuffer.class.getName()));
        st.close();
        debug("Session Buffer 27 Activator stopped");
    }

    private void debug(String msg) {
        System.out.println("BundleActivator: " + msg);
    }
}

I successfully deployed the bundle on Glassfish 3.1.2 but when I restart
the server I get this error message and the server crashes:

[#|2012-07-08T12:38:16.568+0300|INFO|glassfish3.1.2|org.glassfish.osgijavaeebase|_ThreadID=67;_ThreadName=Thread-2;|Expanded
at file:/tmp/osgiapp5717459413008665895/|#]

[#|2012-07-08T12:38:17.205+0300|SEVERE|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=50;_ThreadName=Thread-2;|Critical
error during deployment:
com.sun.faces.config.ConfigurationException:
java.util.concurrent.ExecutionException: java.net.MalformedURLException:
Unknown protocol: jndi
    at
com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:674)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:324)
    at
com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
    at
org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4750)
    at
com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:550)
    at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5366)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
    at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at
com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)
    at
com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:210)
    at
com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:108)
Caused by: java.util.concurrent.ExecutionException:
java.net.MalformedURLException: Unknown protocol: jndi
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
    at java.util.concurrent.FutureTask.get(FutureTask.java:111)
    at
com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:672)
    ... 19 more
Caused by: java.net.MalformedURLException: Unknown protocol: jndi
    at java.net.URL.<init>(URL.java:617)
    at java.net.URL.<init>(URL.java:480)
    at java.net.URL.<init>(URL.java:429)
    at java.net.URI.toURL(URI.java:1096)
    at
com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:922)
    at
com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:867)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at
com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:658)
    ... 19 more
Caused by: java.lang.IllegalStateException: Unknown protocol: jndi
    at
org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:372)
    at java.net.URL.<init>(URL.java:612)
    ... 27 more
|#]

[#|2012-07-08T12:38:17.233+0300|SEVERE|glassfish3.1.2|org.apache.catalina.core.StandardContext|_ThreadID=50;_ThreadName=Thread-2;|PWC1306:
Startup of context failed due to previous errors|#]

[#|2012-07-08T12:38:17.244+0300|SEVERE|glassfish3.1.2|org.apache.catalina.core.StandardContext|_ThreadID=50;_ThreadName=Thread-2;|PWC1305:
Exception during cleanup after start failed
org.apache.catalina.LifecycleException: PWC2769: Manager has not yet been
started
    at
org.apache.catalina.session.StandardManager.stop(StandardManager.java:873)
    at
org.apache.catalina.core.StandardContext.stop(StandardContext.java:5571)
    at com.sun.enterprise.web.WebModule.stop(WebModule.java:527)
    at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5384)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
    at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at
com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)
    at
com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:210)
    at
com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:108)
|#]

[#|2012-07-08T12:38:17.245+0300|SEVERE|glassfish3.1.2|org.apache.catalina.core.ContainerBase|_ThreadID=50;_ThreadName=Thread-2;|ContainerBase.addChild:
start:
org.apache.catalina.LifecycleException: java.lang.RuntimeException:
com.sun.faces.config.ConfigurationException:
java.util.concurrent.ExecutionException: java.net.MalformedURLException:
Unknown protocol: jndi
    at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5389)
    at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
    at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
    at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at
com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)
    at
com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:210)
    at
com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:108)
Caused by: java.lang.RuntimeException:
com.sun.faces.config.ConfigurationException:
java.util.concurrent.ExecutionException: java.net.MalformedURLException:
Unknown protocol: jndi
    at
com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:292)
    at
org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4750)
    at
com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:550)
    at
org.apache.catalina.core.StandardContext.start(StandardContext.java:5366)
    ... 14 more
Caused by: com.sun.faces.config.ConfigurationException:
java.util.concurrent.ExecutionException: java.net.MalformedURLException:
Unknown protocol: jndi
    at
com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:674)
    at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:324)
    at
com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
    ... 17 more
Caused by: java.util.concurrent.ExecutionException:
java.net.MalformedURLException: Unknown protocol: jndi
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
    at java.util.concurrent.FutureTask.get(FutureTask.java:111)
    at
com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:672)
    ... 19 more
Caused by: java.net.MalformedURLException: Unknown protocol: jndi
    at java.net.URL.<init>(URL.java:617)
    at java.net.URL.<init>(URL.java:480)
    at java.net.URL.<init>(URL.java:429)
    at java.net.URI.toURL(URI.java:1096)
    at
com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:922)
    at
com.sun.faces.config.ConfigManager$ParseTask.call(ConfigManager.java:867)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at
com.sun.faces.config.ConfigManager.getConfigDocuments(ConfigManager.java:658)
    ... 19 more
Caused by: java.lang.IllegalStateException: Unknown protocol: jndi
    at
org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:372)
    at java.net.URL.<init>(URL.java:612)
    ... 27 more
|#]

[#|2012-07-08T12:38:17.250+0300|INFO|glassfish3.1.2|org.apache.catalina.startup.ContextConfig|_ThreadID=12;_ThreadName=Thread-2;|No
default web.xml|#]

[#|2012-07-08T12:38:17.253+0300|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=50;_ThreadName=Thread-2;|java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
java.lang.RuntimeException: com.sun.faces.config.ConfigurationException:
java.util.concurrent.ExecutionException: java.net.MalformedURLException:
Unknown protocol: jndi
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: java.lang.RuntimeException:
com.sun.faces.config.ConfigurationException:
java.util.concurrent.ExecutionException: java.net.MalformedURLException:
Unknown protocol: jndi
    at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:921)
    at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2018)
    at
com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at
com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)
    at
com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:210)
    at
com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:108)
|#]

[#|2012-07-08T12:38:17.254+0300|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=50;_ThreadName=Thread-2;|Exception
while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException:
ContainerBase.addChild: start: org.apache.catalina.LifecycleException:
java.lang.RuntimeException: com.sun.faces.config.ConfigurationException:
java.util.concurrent.ExecutionException: java.net.MalformedURLException:
Unknown protocol: jndi
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:138)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
    at
org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
    at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
    at
com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:375)
    at
com.sun.enterprise.v3.admin.adapter.InstallerThread.load(InstallerThread.java:210)
    at
com.sun.enterprise.v3.admin.adapter.InstallerThread.run(InstallerThread.java:108)
|#]

[#|2012-07-08T12:38:17.254+0300|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=50;_ThreadName=Thread-2;|Exception
while loading the app|#]

[#|2012-07-08T12:38:17.258+0300|INFO|glassfish3.1.2|org.glassfish.osgihttp|_ThreadID=12;_ThreadName=Thread-2;|standardContext
=
StandardEngine[glassfish-web].StandardHost[__asadmin].StandardContext[/osgi]|#]

[#|2012-07-08T12:38:17.301+0300|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=50;_ThreadName=Thread-2;|Exception
while loading the app|#]

Can you tell me how I can fix this problem?

Best wishes
Peter