Java.util.Map - NullPointerException

In my main application class, I have a public Map config<String, StringBuilder>. However, whenever I try to .put() some values in it, it gives me a NullPointerException. I try config.put("key","value") and config.put(new String("key"), new StringBuilder("value")) but it's just the same. What is it that I don't know?

config is null

Similar Messages

  • Java.util.Map and null key

    Hi,
    For information, according to the implementation, it is possible to put and get a null key when using a map.
    The null key can be added and retrieved when using a HashMap, an exception is thrown for a TreeMap.

    The documentation for java.util.Map states:
    Some map implementations have restrictions on the keys and values they may contain. For example, some implementations prohibit null keys and values, and some have restrictions on the types of their keys. Attempting to insert an ineligible key or value throws an unchecked exception, typically NullPointerException or ClassCastException.The documentation for java.util.TreeMap.put() states:
    Throws:
    NullPointerException - if the specified key is null and this map uses natural ordering, or its comparator does not permit null keysSo a Map generally may or may not support null keys and/or values and the decision is up to the concrete implementation. TreeMap states that it doesn't support null keys, unless a Comparator is used that permits null keys.

  • Error: java.util.map can not be inherited with different arguments

    Hi,
    I am getting following error while building the source code.
    C:\venus\src\com\martquest\messaging\msgio\MqMessageIOObjectCarrier.java:36: java.util.Map cannot be inherited with different arguments: <> and <java.lang.Object,java.lang.Object>
    [javac] public class MqMessageIOObjectCarrier extends Properties implements IMqMessageIOObjectCarrier
    What should I do to resolve this issue?
    Thanks
    Prachi

    Hi,
    I am getting following error while building the
    source code.whose source code? If it's yours, you'd better look at where you are defining and using Map. The error code tells you exactly what's wrong.

  • Java.util.map in a jar?

    My applet works on Netscape 6.1 presumably because the java.util.map class has capabilities that I'm using in my applet that isn't in other versions of java.util.map. Since I want to make my applet cross platform, is there any way to include java.util.map in my jar file so that people can use that version instead? Thanks.
    Denise

    Denise,
    I think that will break your license agreement with Sun, so you probably don't want to do that, right? ;)
    I think you should try to figure out what the exact cause of your problem is. Off hand, it almost sounds like your applet uses v1.3 api, but your still using the old <Applet> html tag and not the new <Object> tag. Is this right?
    -Ron

  • Message Mapping - java.util.Map

    Hi There
    I would like to know if there is any way, using java.util.Map map; to get the "data type" field name in a UDF? Passing a constant with the field name would not be practical.. I'm looking for a object oriented process to use in all my mappings.
    Also where could I look for the methods I can use in the map trace object?
    Regards,
    Jan

    But I'm still missing the field name..
    Let say I have a message mapping going from Field ACB to Field QAZ and a UDF called CheckLen.
    In my UDF I'm looking at the incoming field and if it's length is correct. if not I'm writing an entry into a table stating there was an incorrect field but what I can't get is the the field name so I can write to the table "Invalid length on field ACB" The only way to get this field name value is by passing a constant of "ACB" to the UDF and using that. But we have hundreds of MMs so implementing this would be much more difficult than a OOP way..

  • Java.util.Map and  java.util.HashMap samples

    Hi.
    Please, I need some code samples of java.util.Map and java.util.HashMap interfaces. I have problems to retreive objects in the map.
    Cheers,
    Cata

    Try the tutorial:
    http://java.sun.com/docs/books/tutorial/collections/index.html

  • Java.util.Map to as object

    Hi,
    I want to get java.util.Map object returned from server-side
    on the client-side. I don't know which flex data-type should I use
    for that. I tried Array but it dint help. Someone plz help...
    Thanks in advance,
    Cheree

    You can use a for-in ActionScript loop to examine any
    ActionScript Object:
    for(var i:String in someObject) {
    trace( i+" = "+someObject
    Within the loop, i assumes the name of all the public
    properties in the given object.

  • Java.util.Map type return in webservice method

    Wonder, how we can return a java.util.Map type from a webservice deployed on a
    weblogic 7.x environment..
    any input is appreciated.
    -Girish

    Thanks Michael. it helps.
    -Girish
    "Michael Wooten" <[email protected]> wrote:
    >
    Hi Girish,
    By definition, a Java object used as a input parameter (or return type)
    of a web
    service operation, must has a no-arg constructor in order for a Java-based
    Web
    Service Stack to serialize/deserialize it to/from XML. java.util.Map
    is an interface,
    so it does not meet this requirement :-)
    If your web service operation is just trying to return (or accept) a
    hash map
    of "arbitrary complex types", I recommend that you consider switching
    this to
    be an "array of arrays of specific complex types". The reason I say this
    is because,
    it allows even non-Java consumers to look at the <schema> elements in
    your web
    services' WSDL, and figure out all the possible "arbitrary complex types"
    that
    might be in this array. If you envision the consumer getting a box, where
    it can
    literally contain anything, you can probably see how much more code they
    would
    need to write, than if they knew the the box contained a box of these,
    and a box
    of these, and so on, and so on.
    Basically, all the "old school" type-safety rules still apply to web
    services
    computing. If you want web services with descent performance metrics,
    you're probably
    going to want to keep a lot of the "old school, distributed computing"
    practices
    in mind, when you design your stuff :-)
    That said, WLS 7.0 SP1 does not currently have a "built-in" HashMap codec.
    But,
    you could create one using the information at:
    http://edocs.bea.com/wls/docs70/webserv/customdata.html#1054435
    Regards,
    Mike Wooten
    "girish" <[email protected]> wrote:
    Wonder, how we can return a java.util.Map type from a webservice deployed
    on a
    weblogic 7.x environment..
    any input is appreciated.
    -Girish

  • Weird exception: Cannot instantiate non-persistent class: java.util.Map

    java.lang.UnsupportedOperationException: Cannot instantiate non-persistent class: java.util.Map
         at com.sleepycat.persist.impl.NonPersistentFormat.newInstance(NonPersistentFormat.java:45)
         at com.sleepycat.persist.impl.PersistEntityBinding.readEntity(PersistEntityBinding.java:89)
         at com.sleepycat.persist.impl.PersistEntityBinding.entryToObject(PersistEntityBinding.java:61)
         at com.sleepycat.persist.PrimaryIndex.put(PrimaryIndex.java:338)
         at com.sleepycat.persist.PrimaryIndex.put(PrimaryIndex.java:299)
         at com.xx.support.dbd.IdentityDataAccessor.insert(IdentityDataAccessor.java:33)
         at com.xx.support.dbd.BerkeleyDBAccountStorage.saveUser(BerkeleyDBAccountStorage.java:95)
         at com.xx.support.bdb.BerkeleyDBAccountStorageTests.initBerkeleyDBData(BerkeleyDBAccountStorageTests.java:38)
         at com.xx.support.bdb.BerkeleyDBAccountStorageTests.setUp(BerkeleyDBAccountStorageTests.java:28)
         at junit.framework.TestCase.runBare(TestCase.java:125)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:118)
         at junit.framework.TestSuite.runTest(TestSuite.java:208)
         at junit.framework.TestSuite.run(TestSuite.java:203)
    What's the root cause of this exception?

    I wrote a small test using the classes you included
    in your message and I am able to retrieve the user by
    key, as in the code above. So I'm not sure what
    you're doing that is causing the problem. Please
    send a small test that reproduces the problem.Oops, I forgot to include the source for the test I wrote. Here it is.
    import java.io.File;
    import java.util.HashMap;
    import java.util.Map;
    import com.sleepycat.je.DatabaseException;
    import com.sleepycat.je.Environment;
    import com.sleepycat.je.EnvironmentConfig;
    import com.sleepycat.persist.EntityStore;
    import com.sleepycat.persist.PrimaryIndex;
    import com.sleepycat.persist.StoreConfig;
    import com.sleepycat.persist.model.Entity;
    import com.sleepycat.persist.model.Persistent;
    import com.sleepycat.persist.model.PrimaryKey;
    public class Test {
        @Persistent
        public static class SimplePrincipal {
            protected String name;
            public SimplePrincipal(String username) {
                this.name = name;
            public SimplePrincipal() {}
        @Entity
        public static class SimpleUser extends SimplePrincipal {
            @PrimaryKey
            private String key;
            private Map properties;
            public SimpleUser() {
                super();
                this.properties = new HashMap();
            public SimpleUser(String username) {
                super(username);
                this.properties = new HashMap();
            public void setKey(String key){
                this.key = key;
            public void addPropertity(String name, String value) {
                this.properties.put(name, value);
            @Override
            public String toString() {
                return "[SimpleUser key: " + key + " name: " + name + ']';
        private Environment env;
        private EntityStore store;
        private PrimaryIndex<String, SimpleUser> primaryIndex;
        private void open()
            throws DatabaseException {
            EnvironmentConfig envConfig = new EnvironmentConfig();
            envConfig.setAllowCreate(true);
            envConfig.setTransactional(true);
            env = new Environment(new File("./data"), envConfig);
            StoreConfig storeConfig = new StoreConfig();
            storeConfig.setAllowCreate(true);
            storeConfig.setTransactional(true);
            store = new EntityStore(env, "test", storeConfig);
            primaryIndex = store.getPrimaryIndex(String.class, SimpleUser.class);
        private void close()
            throws DatabaseException {
            store.close();
            env.close();
        private void execute()
            throws DatabaseException {
            SimpleUser user = new SimpleUser("test");
            user.setKey("testkey");
            primaryIndex.put(user);
            user = primaryIndex.get("testkey");
            System.out.println(user);
        public static void main(String[] args)
            throws DatabaseException {
            Test test = new Test();
            test.open();
            test.execute();
            test.close();
    }Mark

  • BEA error: deleteTaskAttributes(int,java.util.Map)

    Hello,
    I have installed OIM 9100 on BEA with an Oracle Database.
    I got the following error message after starting OIM:
    <08.07.2008 11.07 Uhr CEST> <Warning> <EJB> <BEA-012034> <The Remote interface method: 'public abstract void com.thortec
    h.xl.scheduler.interfaces.SchedulerController.deleteTaskAttributes(int,java.util.Map) throws com.thortech.xl.scheduler.e
    xception.SchedulerGenericException,java.rmi.RemoteException' in EJB 'SchedulerController' contains a parameter of type:
    'java.util.Map' which is not Serializable. Though the EJB 'SchedulerController' has call-by-reference set to false, this
    parameter is not Serializable and hence will be passed by reference. A parameter can be passed using call-by-value only
    if the parameter type is Serializable.>
    Can anybody help me or tell me what it means?
    Thank you,
    Matthias

    BEA Weblogic normally throws a ton of these errors as it seems like OIM's ideas on what should be passed by reference and what should be passed by value does not play well with Weblogic.
    I have been told to ignore these warnings.
    Good luck
    /M

  • Compile error import java.util.map$entry

    Hi,
    I am trying to compile code which imports the following package
    import java.util.Map$Entry.
    The error thrown up is : cant resolve symbol Map$Entry. Why is there a $ in the package import path and is there some configuration required to compile the file.
    I am not allowed to change the code. Does anyone have an idea on how this problem can be solved.
    Thanks and regards
    Kumar Vellal

    Btw java docs for the interface are available at:
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.Entry.html
    Changing the import should probably help compile the code, but without changing the import .. need to check. This is just from what i remember now. Lets see if anyone else comments on this.

  • JPA - Columns to java.util.Map

    I need to map the columns of a DB table into a java.util.Map object.
    Any idea about how to implement this feature?
    These are the columns of my table:
       | ID | Value01 | Value02 | Value03 | ... | ValueN |I'd like to obtain a bean like this:
    public class MyBean {
      private String ID;
      private Map values;
    }I thought I could extend java.util.Map and redefine the get(Object) and put(Object, Object) methods
    (I did something like this in java 1.4) but I can't figure it out in 1.5 with JPA

    >
    hi i have the following method,when i click my button am geting this error java.lang.String cannot be cast to java.util.Map
    >
    And that is correct - you can't do that cast. Which is what this code is trying to do.
    >
    (Map)actionEvent.getComponent().getAttributes().get("test")
    >
    Ask yourself what object is supposed to be the 'Map' in that line of code?
    Is it 'actionEvent', 'getComponent()' or 'getAttributes()'?
    My guess is that it is the 'getAttributes' that returns a map. Which means you need to cast
    actionEvent.getComponent().getAttributes()as a Map. Which means you need to put that entire thing in parentheses so that the cast is performed on it. And then you have to put THAT entire thing in parentheses so you can call the 'get' method on it.
    So this is the 'Map'
    (Map) (actionEvent.getComponent().getAttributes())And this calls the Maps 'get' method
    ( (Map) (actionEvent.getComponent().getAttributes()) ).get("test")If you broke the line into pieces and stored each piece in its own variable you would see it. These object types may not be right but should give you the idea.
    //( (Map) (actionEvent.getComponent().getAttributes()).get("test") ).get("test")
    MyComponent myComponent = (MyComponent) actionEvent.getComponent();
    Map myMap = (Map) myComponent.getAttributes();
    myMap.get("test");

  • Servlet java.util.Map Help

    It's been a while since I have written any code and I am having an issue getting back into it.
    I am currently working on creating servlet to pass info from all my forms to my business logic. However, I am having an issue with getting the data. This may be a topic for a different forum, but I figured I would ask here.
    I tested out the servlet with the getParameter() method, and I can get the values. However, when I try to use the java.util.Map, I get blank values.
    I think the issue may be that I forgot how to use the Map object. Here is my code:
    out.println("<html>");
    out.println("<head>");
    out.println("<title>Servlet CalCartController</title>");
    out.println("</head>");
    out.println("<body>");
    for (int i = 0; i < formParamsMap.size(); i++) {
    Map.Entry entry = (Map.Entry) keyValuePairs.next();
    String key = (String)entry.getKey();
    String value = (String)entry.getValue();
    out.println(value);
    out.println("<h1>Servlet CalCartController </h1>");
    out.println("</body>");
    out.println("</html>");

    hacktorious wrote:
    OK, so if I replace the loop with the following:
    String firstName = (String)formParamsMap.get("firstName");
    out.println(firstName);
    this gives a blank result.If firstName is an actual parameter, it's probably throwing an exception, and you're swallowing it or otherwise not seeing it. I would expect a ClassCastException if the map contained "firstName".

  • Exposing java.util.Map data as RequiredModelMBean

    I'm trying to expose java.util.Map data but I can't quite figure how.
    I'd like the management interface to look like it has an attribute that is actually the key of the map.
    For example, calling:
    mBeanServer.getAttribute(new ObjectName("nomojomofo:type=mapBean"), "fubar");
    would get its data from the target object as:
    aMap.get("fubar");
    Edited by: nomojomofo on Oct 9, 2007 5:31 PM

    You can write a DynamicMBean for that:
    http://weblogs.java.net/blog/emcmanus/archive/2006/11/a_real_example.html
    However you should be aware that most JMX consoles do not expect that the MBeanInfo of a given MBean can change over time.
    If the content of your Map is fixed - you won't have any problem.
    If it can change over time, you might consider exposing the Map as a single attribute,
    for instance, as a CompositeData.
    You might also be interested in this article:
    http://blogs.sun.com/jmxetc/entry/dynamicmbeans%2C_modelmbeans%2C_and_pojos...
    Hope this helps,
    -- daniel
    http://blogs.sun.com/jmxetc

  • Create a java.util.Map in JNI

    hello all,
    Can anyone tell me how to create & use Java Maps in my C++ code...
    I've used java.util.Vector, it works fine.
    I work on a Sun Fire V440 machine.
    regards,
    gautam.

    Denise,
    I think that will break your license agreement with Sun, so you probably don't want to do that, right? ;)
    I think you should try to figure out what the exact cause of your problem is. Off hand, it almost sounds like your applet uses v1.3 api, but your still using the old <Applet> html tag and not the new <Object> tag. Is this right?
    -Ron

Maybe you are looking for

  • How to Migrate Sol 8/SDS 4.2 Raid 1 disks to Sol 10 VM

    I have a system running Solaris 8 with S/w mirrorring of the system & data disks that has to have the O/S upgraded to Solaris 10. Due to the size of a couple of system mount pts it looks like I'll have to do the Solaris 10 initial install option and

  • Succesful IDOC acknowledgements from ECC

    Dear MDM gurus, What is the best way to handle acknowledgements from ECC (INTO MDM) for inbound IDOCS from MDM (MDM->XI->ECC). We want it such that when an IDOC gets posted into ECC succesfully,it should send an acknowledgement signal back to MDM say

  • Microsoft Office 2003

    Hi,  I recently purchased a new computer to replace my other one that died of old age. I was running Windows XP professional and I had Microsoft Office 2003 on it. My new computer is running Windows 7 but no Office. So I installed my Microsoft Office

  • Lost data files, issue with re-capturing

    I deleted a project yesterday and mailed the finals to the client. Apparently there was still something that needed to be fixed. I've tried using a data restore program but it didnt do anything, so I opened up the last autosave. I am trying to re-cap

  • Photos taking up space but do not seem to be there.

    I have an iphone 5 and when I am plugged in and trying to sync to itunes it shows that roughly 6 gigs of space is taken up by photos.  I have deleted most of the photos off of my phone and as far as I can tell only 600 remain.  When I role over the s