karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jean-Baptiste Onofré (JIRA) <j...@apache.org>
Subject [jira] [Comment Edited] (KARAF-3746) cluster:feature-install issue- HazelcastSerializationException: Problem when serializing type 1
Date Sun, 20 Sep 2015 18:59:04 GMT

    [ https://issues.apache.org/jira/browse/KARAF-3746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14563024#comment-14563024
] 

Jean-Baptiste Onofré edited comment on KARAF-3746 at 9/20/15 6:58 PM:
----------------------------------------------------------------------

This issue is fixed by adding the bundle class loader to Thread context in InstallFeatureCommand.java.

{code}
 protected Object doExecute() throws Exception {
        // check if the cluster group exists
        Group group = groupManager.findGroupByName(groupName);
        if (group == null) {
            System.err.println("Cluster group " + groupName + " doesn't exist");
            return null;
        }

        // check if the producer is ON
        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
            System.err.println("Cluster event producer is OFF");
            return null;
        }
        
        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
        try {
        	Thread.currentThread().setContextClassLoader(getClass().getClassLoader());

        	Map<String, FeatureState> clusterFeatures = clusterManager.getMap(Constants.FEATURES_MAP
+ Configurations.SEPARATOR + groupName);

        	// try to resolve the feature version if not provided
        	if (version == null) {
        		for (FeatureState state : clusterFeatures.values()) {
        			if (state.getName().equals(feature)) {
        				version = state.getVersion();
        			}
        		}
        	}

        	// check if the feature exists in the map
        	if (!clusterFeatures.containsKey(feature + "/" + version)) {
        		if (version != null)
        			System.err.println("Feature " + feature + "/" + version + " doesn't exist in the
cluster group " + groupName);
        		else System.err.println("Feature " + feature + " doesn't exist in the cluster group
" + groupName);
        		return null;
        	}

        	// check if the outbound event is allowed
        	if (!isAllowed(group, Constants.CATEGORY, feature, EventType.OUTBOUND)) {
        		System.err.println("Feature " + feature + " is blocked outbound for cluster group
" + groupName);
        		return null;
        	}

        	// update the features in the cluster group
        	FeatureState clusterFeatureState = clusterFeatures.get(feature + "/" + version);
        	if (clusterFeatureState == null) {
        		clusterFeatureState = new FeatureState();
        		clusterFeatureState.setName(feature);
        		clusterFeatureState.setVersion(version);
        	}
        	clusterFeatureState.setInstalled(Boolean.TRUE);
        	clusterFeatures.put(feature + "/" + version, clusterFeatureState);
        	// TODO does it make sense to also update the cluster bundles, I don't think so ...
        }finally {
        	Thread.currentThread().setContextClassLoader(originalClassLoader);
        }
        // broadcast the cluster event
        ClusterFeaturesEvent event = new ClusterFeaturesEvent(feature, version, noClean, noRefresh,
FeatureEvent.EventType.FeatureInstalled);
        event.setSourceGroup(group);
        eventProducer.produce(event);

        return null;
    }

    public EventProducer getEventProducer() {
        return eventProducer;
    }

    public void setEventProducer(EventProducer eventProducer) {
        this.eventProducer = eventProducer;
    }
{code}


was (Author: mgandra):
This issue is fixed by adding the bundle class loader to Thread context in InstallFeatureCommand.java.

{code}
 protected Object doExecute() throws Exception {
        // check if the cluster group exists
        Group group = groupManager.findGroupByName(groupName);
        if (group == null) {
            System.err.println("Cluster group " + groupName + " doesn't exist");
            return null;
        }

        // check if the producer is ON
        if (eventProducer.getSwitch().getStatus().equals(SwitchStatus.OFF)) {
            System.err.println("Cluster event producer is OFF");
            return null;
        }
        
        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
        try {
        	Thread.currentThread().setContextClassLoader(getClass().getClassLoader());

        	Map<String, FeatureState> clusterFeatures = clusterManager.getMap(Constants.FEATURES_MAP
+ Configurations.SEPARATOR + groupName);

        	// try to resolve the feature version if not provided
        	if (version == null) {
        		for (FeatureState state : clusterFeatures.values()) {
        			if (state.getName().equals(feature)) {
        				version = state.getVersion();
        			}
        		}
        	}

        	// check if the feature exists in the map
        	if (!clusterFeatures.containsKey(feature + "/" + version)) {
        		if (version != null)
        			System.err.println("Feature " + feature + "/" + version + " doesn't exist in the
cluster group " + groupName);
        		else System.err.println("Feature " + feature + " doesn't exist in the cluster group
" + groupName);
        		return null;
        	}

        	// check if the outbound event is allowed
        	if (!isAllowed(group, Constants.CATEGORY, feature, EventType.OUTBOUND)) {
        		System.err.println("Feature " + feature + " is blocked outbound for cluster group
" + groupName);
        		return null;
        	}

        	// update the features in the cluster group
        	FeatureState clusterFeatureState = clusterFeatures.get(feature + "/" + version);
        	if (clusterFeatureState == null) {
        		clusterFeatureState = new FeatureState();
        		clusterFeatureState.setName(feature);
        		clusterFeatureState.setVersion(version);
        	}
        	clusterFeatureState.setInstalled(Boolean.TRUE);
        	clusterFeatures.put(feature + "/" + version, clusterFeatureState);
        	// TODO does it make sense to also update the cluster bundles, I don't think so ...
        }finally {
        	Thread.currentThread().setContextClassLoader(originalClassLoader);
        }
        // broadcast the cluster event
        ClusterFeaturesEvent event = new ClusterFeaturesEvent(feature, version, noClean, noRefresh,
FeatureEvent.EventType.FeatureInstalled);
        event.setSourceGroup(group);
        eventProducer.produce(event);

        return null;
    }

    public EventProducer getEventProducer() {
        return eventProducer;
    }

    public void setEventProducer(EventProducer eventProducer) {
        this.eventProducer = eventProducer;
    }
{/code}

> cluster:feature-install issue- HazelcastSerializationException: Problem when serializing
type 1
> -----------------------------------------------------------------------------------------------
>
>                 Key: KARAF-3746
>                 URL: https://issues.apache.org/jira/browse/KARAF-3746
>             Project: Karaf
>          Issue Type: Bug
>          Components: cellar-hazelcast
>    Affects Versions: cellar-2.3.6
>         Environment: CentOS -6.6
>            Reporter: Manohar Gandra
>            Assignee: Jean-Baptiste Onofré
>            Priority: Blocker
>             Fix For: cellar-4.0.0, cellar-3.0.4, cellar-2.3.7
>
>
> we are setting up the cellar 2.3.6 with apache servicemix 5.3.2. we are installing the
features on cluster and seeing issues. We also tried the same with cellar 2.3.5 and apache
servicemix 5.3.0 and seeing same issue.
> 1. cluster:feature-url-add default <maven feature url>
>     This is working fine.
> 2. cluster:feature-install default <feature name>
>    This command is failing with following exception. 
>    Any help is appreciated.
> 2015-05-27 09:22:15,144 | ERROR | l Console Thread | Console                        
 | ?                                   ? | 20 - org.apache.karaf.shell.console - 2.4.0 | Exception
caught while executing command
> com.hazelcast.nio.HazelcastSerializationException: Problem when serializing type 1
> 	at com.hazelcast.nio.AbstractSerializer.toObject(AbstractSerializer.java:128)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.nio.AbstractSerializer.toObject(AbstractSerializer.java:156)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.nio.Serializer.readObject(Serializer.java:75)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.impl.ThreadContext.toObject(ThreadContext.java:135)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.nio.IOUtil.toObject(IOUtil.java:163)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.impl.base.KeyValue.getValue(KeyValue.java:85)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.impl.Entries$EntryIterator.setHasNext(Entries.java:134)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.impl.Entries$EntryIterator.hasNext(Entries.java:125)[195:com.hazelcast:2.6.9]
> 	at org.apache.karaf.cellar.features.shell.InstallFeatureCommand.doExecute(InstallFeatureCommand.java:70)[202:org.apache.karaf.cellar.features:2.3.5]
> 	at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)[20:org.apache.karaf.shell.console:2.4.0]
> 	at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)[20:org.apache.karaf.shell.console:2.4.0]
> 	at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[20:org.apache.karaf.shell.console:2.4.0]
> 	at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[20:org.apache.karaf.shell.console:2.4.0]
> 	at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)[20:org.apache.karaf.shell.console:2.4.0]
> 	at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[20:org.apache.karaf.shell.console:2.4.0]
> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[20:org.apache.karaf.shell.console:2.4.0]
> 	at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[20:org.apache.karaf.shell.console:2.4.0]
> 	at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)[20:org.apache.karaf.shell.console:2.4.0]
> 	at org.apache.karaf.shell.console.jline.Console.run(Console.java:196)[20:org.apache.karaf.shell.console:2.4.0]
> 	at org.apache.karaf.shell.console.jline.DelayedStarted.run(DelayedStarted.java:79)[20:org.apache.karaf.shell.console:2.4.0]
> Caused by: java.lang.ClassNotFoundException: org.apache.karaf.cellar.features.FeatureState
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)[:1.7.0_79]
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)[:1.7.0_79]
> 	at java.security.AccessController.doPrivileged(Native Method)[:1.7.0_79]
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)[:1.7.0_79]
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)[:1.7.0_79]
> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)[:1.7.0_79]
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_79]
> 	at com.hazelcast.nio.AbstractSerializer.loadClass(AbstractSerializer.java:81)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.nio.AbstractSerializer.loadClass(AbstractSerializer.java:56)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.nio.AbstractSerializer$1.resolveClass(AbstractSerializer.java:91)[195:com.hazelcast:2.6.9]
> 	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1612)[:1.7.0_79]
> 	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1517)[:1.7.0_79]
> 	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)[:1.7.0_79]
> 	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)[:1.7.0_79]
> 	at java.io.ObjectInputStream.readUnshared(ObjectInputStream.java:460)[:1.7.0_79]
> 	at com.hazelcast.nio.DefaultSerializer$ObjectSerializer.readNormal(DefaultSerializer.java:410)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.nio.DefaultSerializer$ObjectSerializer.read(DefaultSerializer.java:380)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.nio.DefaultSerializer.read(DefaultSerializer.java:138)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.nio.CustomSerializerAdapter.read(CustomSerializerAdapter.java:32)[195:com.hazelcast:2.6.9]
> 	at com.hazelcast.nio.AbstractSerializer.toObject(AbstractSerializer.java:121)[195:com.hazelcast:2.6.9]
> 	... 19 more



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message