Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7741665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:04:58+00:00 2026-06-01T09:04:58+00:00

I confused with extends, i went with theory n solved some examples, But when

  • 0

I confused with extends, i went with theory n solved some examples,
But when i come to my main project still i am doing something wrong and i am not able to find it.

Can any one help me.

ConnectionServiceImpl is called by RPC

When the client call the COnnectionServiceImpl the connectionParameter is set .I checked it by display in the

Map<String, String>

but when second rpc call is done to the ObjectStore by client
its give me error NullPointerException for the same parameter which was set in the super class

public class ConnectionServiceImpl extends RemoteServiceServlet{
// some code including initialization
private ConnectionParameter connectionParameter ;
private Map<String, String> parameter;
public String connection() {
        connectionParameter = new ConnectionParameter("abc","xyz",repositoryName);
        setConnectionParameter();
        setSession();
        return getConnected();
   }

protected  Map<String, String> getConnectionParameter() {
Iterator iterator = parameter.keySet().iterator();
         while(iterator.hasNext()){

                String key = iterator.next().toString();  
                String value = parameter.get(key);
                System.out.println("key  " + key  + " value "+value);

    }
            return parameter;
}

private void setConnectionParameter(){

    this.parameter=connectionParameter.getParameter();
}
}

This above class is working fine.

now,

public class ObjectStore extends ConnectionServiceImpl {
// some code
public ObjectStore() {
    // TODO Auto-generated constructor stub
    this.parameter = getConnectionParameter(); **<--- NullPointer Error**
            }
}

Can anybody explain this or tell the mistake

public class ConnectionParameter {

    private String repositoryID;
    private static String username;
    private static String password;
    private static String AtomPubUrl;
    private static String bindingType;
    private Map<String, String> parameter = new HashMap<String, String>();

    public ConnectionParameter(String username, String password,
            String repositoryId) {
        // TODO Auto-generated constructor stub

        AtomPubUrl = "http://192.168.1.32:9083/CaseManager/resources/Service";
        bindingType = BindingType.ATOMPUB.value();
        this.username = username;
        this.password = password;
        this.repositoryID=repositoryId;

        setConnectionParameter();
    }
      Map<String, String> getParameter() {
        return parameter;
    }

    private void setConnectionParameter() {
        parameter.put(SessionParameter.USER,username);
        parameter.put(SessionParameter.PASSWORD, password);

        parameter.put(SessionParameter.ATOMPUB_URL,AtomPubUrl);
        parameter.put(SessionParameter.BINDING_TYPE, bindingType);

        parameter.put(SessionParameter.REPOSITORY_ID, repositoryID);
    }

}

Stacktrace

java.lang.NullPointerException
    at com.server.ConnectionServiceImpl.getConnectionParameter(ConnectionServiceImpl.java:107)
    at com.server.ObjectStore.<init>(ObjectStore.java:27)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at org.mortbay.jetty.servlet.Holder.newInstance(Holder.java:153)
    at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:428)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:05:00+00:00Added an answer on June 1, 2026 at 9:05 am

    You seem to have a problem with initialization order and ownerhsip of member fields.

    1. Have you initialized ConnectionServiceImpl.parameter in its constructor? You don’t show any constructor there – do you have any? If not, then right after constructing the object, parameter is uninitialized. Which means that calling getConnectionParameter before connection gives you a null pointer. (Although it should not result in an NPE – is the code you show us really producing an NPE as you claim?).

    2. From the above follows that your call to getConnectionParameter from the constructor of ObjectStore is an error, unless you have initialized ConnectionServiceImpl.parameter before (in the parent class constructor).

    3. Apparently you either have a field called parameter in ObjectStore (which duplicates ConnectionServiceImpl.parameter, thus is highly discouraged), or ConnectionServiceImpl.parameter – whose declaration is not shown in your code – is not private, thus accessible from the subclass, and you are trying to initialize it from the subclass constructor (which is wrong in general – the base class should take care of initializing its fields properly). And if this is the case, you are actually attempting “circular initialization”: to initialize the field in the subclass with its own value taken via the superclass getter, which is foolish.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've read similar questions here but I'm still a little confused. MyCollection extends ArrayList<MyClass>
This could be something very simple but I'm totally confused. I have a JScrollPane
I'm confused by the following code: class MyException extends Exception {} class AnotherException extends
Bit confused here, I have an on-demand instance but do I get charged even
i'm confused with the term global in AS3. within my main controller class, i've
I'm a bit confused, I set up my app as a simple converter but
i'm pretty confused over the following issue and would be grateful for some clarity.
call_user_func_array() 's PHP manual's examples can only make me more confused with those foo
I am a bit confused with the android SQLite database handling. I went through
Ok so I found this article and I am confused by some parts of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.