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

  • Home
  • SEARCH
  • 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 7029883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:35:49+00:00 2026-05-28T00:35:49+00:00

Hey guys I’m running this code in Android: public ServiceServer(String serverName) { this.serverName =

  • 0

Hey guys I’m running this code in Android:

public ServiceServer(String serverName) {
    this.serverName = serverName;
    this.serverThread = new Thread() {
        public void run() {
            serverThreadProc();
        }
    };
}

private void serverThreadProc() {
    while (!this.stopRequested) {
        Socket sessionSocket = null;
        try {
            sessionSocket = this.serverSocket.accept();
            InetAddress sourceAddress = sessionSocket.getInetAddress();
            Log.i(LOG_TAG, "Accepted new incoming connection ... "
                    + sourceAddress.toString());
            if (clientMap.containsKey(sourceAddress)) {
                ClientProcessor legacyProcessor = clientMap
                        .get(sourceAddress);
                legacyProcessor.shutdown();
            }
            ClientProcessor processor = new ClientProcessor(sessionSocket);
            processor.start();
            clientMap.put(sourceAddress, processor);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

public int start() {

    try {
        this.serverSocket = new ServerSocket(0);
        this.serverPort = this.serverSocket.getLocalPort();
        Log.i(LOG_TAG, "Server " + serverName + " started at "
                + this.serverSocket.getLocalSocketAddress());
    } catch (IOException ex) {
        Log.i(LOG_TAG, ex.toString());
    }

    this.serverThread.start();

    return this.serverPort;
}

public void stop() {
    try {
        stopRequested = true;
        if (null != this.serverSocket) {
            this.serverSocket.close();
        }
    } catch (IOException ex) {
        Log.i(LOG_TAG, ex.toString());
    }

    Log.i(LOG_TAG, "The server " + this.serverName + " has been stopped.");
}

and I’m getting a null pointer exception error that has something to do with my thread? For some reason it gets hung up on the serverThreadProc() method. Here is the stack trace I’m getting from the issue:

01-10 02:10:13.361: I/ActivityThread(2216): Pub com.whooznear.android: com.whooznear.android.ProfileProvider
01-10 02:10:13.642: D/dalvikvm(2216): GC_FOR_ALLOC freed 44K, 4% free 6336K/6595K, paused 95ms
01-10 02:10:13.662: I/dalvikvm-heap(2216): Grow heap (frag case) to 6.805MB for 588816-byte allocation
01-10 02:10:13.801: D/dalvikvm(2216): GC_FOR_ALLOC freed 8K, 4% free 6903K/7175K, paused 109ms
01-10 02:10:14.051: D/dalvikvm(2216): GC_CONCURRENT freed <1K, 4% free 6903K/7175K, paused 8ms+15ms
01-10 02:10:17.462: D/dalvikvm(2216): GC_FOR_ALLOC freed 603K, 11% free 6666K/7431K, paused 81ms
01-10 02:10:17.622: D/dalvikvm(2216): GC_CONCURRENT freed <1K, 4% free 7167K/7431K, paused 5ms+13ms
01-10 02:10:17.971: W/Profile(2216): Invalid profile, java.lang.ArrayIndexOutOfBoundsException: index=1 length=1
01-10 02:10:31.801: I/ConnectActivity(2216): IP Address:0
01-10 02:10:31.812: I/ServiceServer(2216): java.net.SocketException: Permission denied
01-10 02:10:31.812: I/ConnectActivity(2216): Started at -1
01-10 02:10:31.861: W/dalvikvm(2216): threadid=9: thread exiting with uncaught     exception (group=0x40014760)
01-10 02:10:31.861: E/AndroidRuntime(2216): FATAL EXCEPTION: Thread-12
01-10 02:10:31.861: E/AndroidRuntime(2216): java.lang.NullPointerException
01-10 02:10:31.861: E/AndroidRuntime(2216):     at com.whooznear.android.ServiceServer.serverThreadProc(ServiceServer.java:61)
01-10 02:10:31.861: E/AndroidRuntime(2216):     at com.whooznear.android.ServiceServer.access$0(ServiceServer.java:57)
01-10 02:10:31.861: E/AndroidRuntime(2216):     at com.whooznear.android.ServiceServer$1.run(ServiceServer.java:52)
01-10 02:10:32.301: D/dalvikvm(2216): GC_CONCURRENT freed 397K, 7% free 7187K/7687K, paused 9ms+11ms
01-10 02:10:34.761: I/Process(2216): Sending signal. PID: 2216 SIG: 9
  • 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-05-28T00:35:49+00:00Added an answer on May 28, 2026 at 12:35 am

    You are getting NullPointerException at Line 61 in ServiceServer.java
    One of the objects on which you are making a call seems to be Null

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

Sidebar

Related Questions

Hey Guys, here is my code for this, the only help i get from
Hey guys, this bit of code works in IE but not in Chrome, any
Hey guys, I want to store a categorized list of URLs. This is an
Hey guys, trying to optimize this query to solve a duplicate user issue: SELECT
hey guys, how can I just achieve this simple layout? I'm hoping the answer
Hey guys, I'm trying to select a specific string out of a text, but
Hey guys! I have this little problem: I have one ViewController which adds 2
Hey guys. This is a follow-on from this question : After getting the right
Hey guys, I have a problem (again). This time I am trying to use
Hey guys, I always get confused by this so it's not exactly my strong

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.