NullPointerException in ThreadedServer$Acceptor.run

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

NullPointerException in ThreadedServer$Acceptor.run

Russell Neufeld
Just came across this null pointer exception in a log file while running
Jetty 5.1.2:

01/21 14:49:26.227 00001726 000                  
java.lang.NullPointerException
01/21 14:49:26.227 00001726 001                          at
org.mortbay.util.ThreadedServer$Acceptor.run(ThreadedServer.java:647)

It appears this happend bacause _acceptor is set outside of a lock, but
read inside of a lock.

On line 647 of ThreadedServer.java, _acceptor is checked for null inside
the lock:
                synchronized(threadedServer)
                {
                    if (_acceptor!=null)
                    {
                        for (int a=0;a<_acceptor.length;a++)
                            if (_acceptor[a]==this)
                                _acceptor[a]=null;
                    }
                    threadedServer.notifyAll();
                }



However on line 558 _acceptor is set to null, and done outside the lock

    public void stop()
        throws InterruptedException
    {
...
       // Done outsite the lock
        _acceptor=null;

Obvious thing to do is put the setting of _acceptor = null inside the
same lock, although without being familiar with the code there's always
the possibility it was done this way to avoid a deadlock.

    Russ


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

MissingResourceException when extending ThreadPoolMBean

Anastasios Angelidis
12:07:15,056 DEBUG [ModelMBeanImpl] java.util.MissingResourceException:
Can't find resource for bundle java.util.PropertyResourceBundle, key
ThreadedServerImpl.started <----- This is from my package....
12:07:15,056 DEBUG [ModelMBeanImpl] java.util.MissingResourceException:
Can't find resource for bundle java.util.PropertyResourceBundle, key
ThreadedServer.started <---- This is already in the jetty jar. So why
would it complain?
12:07:15,056 DEBUG [ModelMBeanImpl] Look for: org/mortbay/util/jmx/mbean


I noticed that jetty uses reflection to load the resource
mbean_en.properties or at least what I saw in the comments. how could I
overcome this?

Thanks


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: MissingResourceException when extending ThreadPoolMBean

Greg Wilkins-5

Are you saying that something is not working or are you simply asking
about the exceptions reported?

The jetty mbean mechanism does a search for resources in multiple
locations which can result in exceptions that are reported in debug
statements.

If there is a real problem, jetty should should a warning rather
than a debug.

regards


Anastasios Angelidis wrote:

> 12:07:15,056 DEBUG [ModelMBeanImpl] java.util.MissingResourceException:
> Can't find resource for bundle java.util.PropertyResourceBundle, key
> ThreadedServerImpl.started <----- This is from my package....
> 12:07:15,056 DEBUG [ModelMBeanImpl] java.util.MissingResourceException:
> Can't find resource for bundle java.util.PropertyResourceBundle, key
> ThreadedServer.started <---- This is already in the jetty jar. So why
> would it complain?
> 12:07:15,056 DEBUG [ModelMBeanImpl] Look for: org/mortbay/util/jmx/mbean
>
>
> I noticed that jetty uses reflection to load the resource
> mbean_en.properties or at least what I saw in the comments. how could I
> overcome this?
>
> Thanks
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: Re: MissingResourceException when extending ThreadPoolMBean

Anastasios Angelidis
If thats the case! Then I'm simply asking about the exceptions reported lol

Thanks

Greg Wilkins wrote:

>
> Are you saying that something is not working or are you simply asking
> about the exceptions reported?
>
> The jetty mbean mechanism does a search for resources in multiple
> locations which can result in exceptions that are reported in debug
> statements.
> If there is a real problem, jetty should should a warning rather
> than a debug.
>
> regards
>
> Anastasios Angelidis wrote:
>
>> 12:07:15,056 DEBUG [ModelMBeanImpl]
>> java.util.MissingResourceException: Can't find resource for bundle
>> java.util.PropertyResourceBundle, key ThreadedServerImpl.started
>> <----- This is from my package....
>> 12:07:15,056 DEBUG [ModelMBeanImpl]
>> java.util.MissingResourceException: Can't find resource for bundle
>> java.util.PropertyResourceBundle, key ThreadedServer.started <----
>> This is already in the jetty jar. So why would it complain?
>> 12:07:15,056 DEBUG [ModelMBeanImpl] Look for: org/mortbay/util/jmx/mbean
>>
>>
>> I noticed that jetty uses reflection to load the resource
>> mbean_en.properties or at least what I saw in the comments. how could
>> I overcome this?
>>
>> Thanks
>>
>>
>> -------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc. Do you grep through
>> log files
>> for problems?  Stop!  Download the new AJAX search engine that makes
>> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
>> _______________________________________________
>> Jetty-support mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/jetty-support
>>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

WARN [ThreadPool] No thread for Socket

Anastasios Angelidis
I'm using the ThreadedServer for my own application. Everything looks to
be working ok, except when the server is left idle for 1-2 hours.

WARN  [ThreadPool] No thread for Socket

What does this warning mean? Or more particular why is it happening? I
left my server running while I went to lunch and when I came back and
started testing again I got this warning... When I looked at the jmx
console the idle thread count was down to zero, instead of being equal
to the minThread count.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

ThreadedServer handleConnection. Exceptions handeling.

Anastasios Angelidis
In reply to this post by Greg Wilkins-5
Should I catch exceptions in the handleConnection(InputStream in,
OutputStream out) or should I trhow them up the stack?

Thanks


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Off topic: The right way to read data from a socket?

Anastasios Angelidis
Since some of you guys are good at this whole socket thing... Just
wondering if you could help.

This is related to Jetty's ThreadedServer handleConnection method.

This is how I plan to read the incomming data on the socket. Let me know
if what I'm doing is right/wrong. For now we can ignore the fact that
there is no message protocol. So there is no logic to check for
terminating characters or what not...

    protected void handleConnection(InputStream in, OutputStream out)
    {      
        BufferedReader bin = new BufferedReader(new InputStreamReader(in));
        PrintWriter pw = new PrintWriter(out);

        String request = new String();

        try
        {
            // Check stream for data.
            while(!bin.ready())
            {
                sleep(1);
            };

            // Data found in stream.
            while(bin.ready())
            {
                int available = in.available();
                char inBuffer[] = new char[available];
               
                bin.read(inBuffer, 0, available);
               
                String tempString = new String(inBuffer);
                request += tempString;
         
                sleep(1);
            }

            // Parse the request here and do what ever...

            pw.print("Request processed!");
            pw.flush();
        }
        catch(IOException e)
        {
             ...
        }
        finally
        {
            if(pw != null)
                pw.close();          
           
            try
            {
                bin.close();
            }
            catch(IOException e)
            {
                ...
            }
        }
    }


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support