Enable User Code Namespaces

For security reasons, you must enable User Code Namespaces using static configuration. You can do this programmatically, or using the Hazelcast configuration file.

If using dynamic persistence, this must be enabled in the Hazelcast configuration file. For further information persisting changes, see the Dynamic Configuration Overview topic under the Configure and Manage Clusters section.

Enable Programmatically

To enable User Code Namespaces programmatically, create a Member.java file, add the following, then save the file to your configuration folder:

package com.hazelcast.namespace.staticconfig.classconfig;

import com.hazelcast.config.Config;
import com.hazelcast.config.UserCodeNamespaceConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
HazelcastInstance hz = Hazelcast.newHazelcastInstance(config);

public class Member {

    public static void main(String[] args) {
        Config config = new Config();
        config.getNamespacesConfig().setEnabled(true);
    }
}

Enable in Configuration File

To enable User Code Namespaces using the hazelcast configuration file, complete the following steps:

  1. Open the hazelcast configuration file in your preferred editor

    The hazelcast configuration file can be either an XML or YAML file.

  2. Scroll to the bottom of the file

  3. Add the following:

    • XML

    • YAML

    <user-code-namespaces enabled="true">
    </user-code-namespaces>
    user-code-namespaces:
       enabled: true

Complete the Configuration

You can continue your configuration as follows: