You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Piet Blok <pb...@wanadoo.nl> on 2006/04/01 12:40:33 UTC

DRDA_InvalidReplyTooShort.S:Invalid reply from network server: Insufficient data.

Hi list,

When stress testing a mechanism to simultaneously start the Derby network 
server from different applications at the same time, I sometimes get the 
following exception:

DRDA_InvalidReplyTooShort.S:Invalid reply from network server: Insufficient 
data.

Is this possibly a bug?

If needed, I can show the source code.

The exception is thrown when executing 
instanceOfNetworkserverControl.getCurrentProperties() at a moment when, to 
my best knowledge, a derby network server has issued the message:

Server is ready to accept connections on port 1527.

Here a clip from the stacktrace:

Thread 2: jdbc:derby://localhost:1527/
Thread 5: jdbc:derby://localhost:1527/
Thread 23: DRDA_InvalidReplyTooShort.S:Invalid reply from network server: 
Insuff
icient data.
java.lang.Exception: DRDA_InvalidReplyTooShort.S:Invalid reply from network 
serv
er: Insufficient data.
        at 
org.apache.derby.impl.drda.NetworkServerControlImpl.consolePropertyMe
ssageWork(Unknown Source)
        at 
org.apache.derby.impl.drda.NetworkServerControlImpl.consolePropertyMe
ssage(Unknown Source)
        at 
org.apache.derby.impl.drda.NetworkServerControlImpl.fillReplyBuffer(U
nknown Source)
        at 
org.apache.derby.impl.drda.NetworkServerControlImpl.readBytesReply(Un
known Source)
        at 
org.apache.derby.impl.drda.NetworkServerControlImpl.getCurrentPropert
ies(Unknown Source)
        at 
org.apache.derby.drda.NetworkServerControl.getCurrentProperties(Unkno
wn Source)
        at org.pbjar.derby.Derby.formatURL(Derby.java:72)
        at org.pbjar.derby.Derby.getClientURL(Derby.java:57)
        at org.pbjar.derby.TestDerby$1.run(TestDerby.java:35)
        at java.lang.Thread.run(Unknown Source)
Thread 4: jdbc:derby://localhost:1527/
Thread 15: jdbc:derby://localhost:1527/
Thread 21: jdbc:derby://localhost:1527/

Here the sysinfo:

------------------ Java Information ------------------
Java Version:    1.5.0_06
Java Vendor:     Sun Microsystems Inc.
Java home:       C:\Program Files\Java\jre1.5.0_06
Java classpath: 
.;C:\PROGRA~1\JMF21~1.1E\lib\sound.jar;C:\PROGRA~1\JMF21~1.1E\l
ib\jmf.jar;C:\PROGRA~1\JMF21~1.1E\lib;C:\WINDOWS\java\classes;C:\WorkSpace\PB 
3.
0\bin;C:\WorkSpace\Filipe\bin;C:\Documents and Settings\Piet\My 
Documents\Resour
ces\Jars\ImgrRdr130.jar;C:\Documents and Settings\Piet\My 
Documents\Resources\Ja
rs\lucene-1.4.1.jar;C:\Documents and Settings\Piet\My 
Documents\Resources\Jars\M
ultivalent20040415.jar;C:\Workspace\Database\bin;
OS name:         Windows XP
OS architecture: x86
OS version:      5.1
Java user name:  Piet
Java user home:  C:\Documents and Settings\Piet
Java user dir:   C:\Documents and Settings\Piet\My Documents\StickFolder
java.specification.name: Java Platform API Specification
java.specification.version: 1.5
--------- Derby Information --------
JRE - JDBC: J2SE 5.0 - JDBC 3.0
[/org/apache/derby/info/DBMS.properties] 10.1.2.1 - (330608)
[/org/apache/derby/info/tools.properties] 10.1.2.1 - (330608)
[/org/apache/derby/info/net.properties] 10.1.2.1 - (330608)
[/org/apache/derby/info/dnc.properties] 10.1.2.1 - (330608)
------------------------------------------------------
----------------- Locale Information -----------------
Current Locale :  [Nederlands/Nederland [nl_NL]]
Found support for locale: [de_DE]
         version: 10.1.2.1 - (330608)
Found support for locale: [es]
         version: 10.1.2.1 - (330608)
Found support for locale: [fr]
         version: 10.1.2.1 - (330608)
Found support for locale: [it]
         version: 10.1.2.1 - (330608)
Found support for locale: [ja_JP]
         version: 10.1.2.1 - (330608)
Found support for locale: [ko_KR]
         version: 10.1.2.1 - (330608)
Found support for locale: [pt_BR]
         version: 10.1.2.1 - (330608)
Found support for locale: [zh_CN]
         version: 10.1.2.1 - (330608)
Found support for locale: [zh_TW]
         version: 10.1.2.1 - (330608)
------------------------------------------------------


Kind regards,

Piet Blok



Re: Storing/Accessing a Derby database inside a JAR

Posted by Susan Cline <ho...@pacbell.net>.
Hi Daniel,

I have not tried this myself, but looking at the documentation 
and looking at the error I wonder if the the path to the database 
from within the jar file is correct.

Please see my specific comments below.

Susan

--- Daniel Morton <dj...@yahoo.com> wrote:

[ snip ]
> 
> I created a jar using:
> 
> jar cf NameGenerator.jar djm NameDB
> 
> so that the database, and the NameGenerator class in
> the djm package is put in to the jar.  However, if I
> run a test.java program to create a NameGenerator
> object, it errors when trying to connect to the
> database:  SQLException: Database '/NameDB' not found.
> 
> My connection string (per the Derby Documentation) is:
> DriverManager.getConnection("jdbc:derby:/NameDB");
> I've tried multiple varitions on this (ie. NameDB,
> /NameDB, /NameDB/ etc.)
> 
> And in the above, the NameGenerator.jar is in the
> classpath.

I believe trying to access the database this way will not work
as per the documentation, you need to use the jdbc:derby:jar
syntax as you have below.

> 
> I've also tried specicifying the explicit path (ala
> the Derby Manual):
> DriverManager.getConnection("jdbc:derby:jar:(C:/project/NameList/NameGenerator.jar)/NameDB");
> 
> Which results in the SQLException: Failed to start
> database
> 'jar:(C:/project/NameList/NameGenerator.jar)/NameDB'
> Java Exception: The system cannot find the file
> specified: java.util.zip.ZipException.

This error looks more hopeful :-)  At least it is looking
for the /NameDB in the jar file.  But I'm thinking that
the path to the NameDB relative to the jar file is the
problem.  When you "unjar" the NameGenerator.jar file
what is the path to NameDB?  What happens if you try
this URL instead;

'jar:(C:/project/NameList/NameGenerator.jar)NameDB'
> 
[ snip ]
> Also, once I get this
> sorted out, is there a way to include derby.jar inside
> NameGenerator.jar so that just the one file could be
> distributed?
> 
I don't know the answer to this, but it seems like it might
be tough since it would be a chicken-and-egg situation.  In 
order to use the Derby JDBC connection URL it would need to
have derby.jar in the classpath first.  Hopefully someone else
can help you with this one.

Storing/Accessing a Derby database inside a JAR

Posted by Daniel Morton <dj...@yahoo.com>.
Hello all:

I have created a derby database called NameDB which
contains a table which contains a list of 10000 names.
 I also have a class called djm.NameGenerator which
when constructed, connects to the database.  Methods
in the class then get names from the database.  It
works fine seperately, but I wish to put the database,
and the class (and eventually the derby.jar if
possible) into a jar file that is easily distributable
so the whole thing is self contained.

I created a jar using:

jar cf NameGenerator.jar djm NameDB

so that the database, and the NameGenerator class in
the djm package is put in to the jar.  However, if I
run a test.java program to create a NameGenerator
object, it errors when trying to connect to the
database:  SQLException: Database '/NameDB' not found.

My connection string (per the Derby Documentation) is:
DriverManager.getConnection("jdbc:derby:/NameDB");
I've tried multiple varitions on this (ie. NameDB,
/NameDB, /NameDB/ etc.)

And in the above, the NameGenerator.jar is in the
classpath.

I've also tried specicifying the explicit path (ala
the Derby Manual):
DriverManager.getConnection("jdbc:derby:jar:(C:/project/NameList/NameGenerator.jar)/NameDB");

Which results in the SQLException: Failed to start
database
'jar:(C:/project/NameList/NameGenerator.jar)/NameDB'
Java Exception: The system cannot find the file
specified: java.util.zip.ZipException.

I'm really at a loss here.  Can anyone tell me what
I'm doing wrong?  I've read through all the relevant
sections of the Derby documentation, and I'm not
really sure what to do next.  Also, once I get this
sorted out, is there a way to include derby.jar inside
NameGenerator.jar so that just the one file could be
distributed?

Any help that anyone can offer would be greatly
appreciated.

Daniel Morton

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: DRDA_InvalidReplyTooShort.S:Invalid reply from network server: Insufficient data.

Posted by Piet Blok <pb...@wanadoo.nl>.
Strange, it seems not to be the Derby network server that is having 
problems, only the client.

1) From an application (JVM 1) if NetworkServerControl.ping() throws an 
Exception, I start a second JVM that is to contain the network server: as 
follows:


    private void startNetwork() throws Exception {
        synchronized (sync) {
            if (processWaiter == null) {
                processWaiter = new ProcessWaiter(Runtime.getRuntime().exec(
                        new String[] { "java", 
"org.pbjar.derby.AtomicDerby" }));
            }
        }
        processWaiter.join();
    }

2) ProcessWaiter is a class that encapsulates the Process and a Thread that 
starts reading "out" from the Process. If the first line it receives equals 
"OK", then the network server is up and running. When the first line is 
read, it shows a gui that displays all output on "out" and "err". All output 
that I myself send to "out" and "err" from the second JVM appear on this 
gui.

3) The started process "AtomicDerby" starts the Network Server as follows:

serverControl = new NetworkServerControl();
serverControl.start(new PrintWriter(pipedWriter));

The pipedWriter is connected to a pipedReader which is wrapped in a 
BufferedReader.

4) After the first line is read from this reader, I must hope that it is the 
"Server is ready to accept connections on port 1527." message. Because I 
don't want to rely on just a constant string, I format an expected value 
from ResourceBundle.getBundle("org/apache/derby/loc/drda/messages") as 
follows:
        Properties props = serverControl.getCurrentProperties();
        return MessageFormat.format(bundle.getString("DRDA_Ready.I"),
                new Object[] { 
props.getProperty("derby.drda.portNumber") });

5) Of course this may fail, because I am not yet sure that the server is up 
and running. But if it fails, I know that it is not up and have to take 
other measures. If it does not fail I can compare the received message with 
the ready line. If these are equal, I am sure that it is the server that I 
started that is in control now. In that case I send an "OK" message to 
standard out, else an "ERROR" message.

6) The message is received in the first JVM that initiated it all. On 
receiving the OK message, it invokes the getCurrentProperties method on 
NetworkServerControl, in order to format an adequate database url, with the 
correct hostname and portnumber. This is the spot where sometimes
I get a failure. Nothing suspicious to be seen on out, err, consoleWriter or 
derby.log in the network server.

It is very hard to reproduce the problem. Sometimes I get them in a row, 
sometimes everything runs smoothly, irrespective of the number of threads 
that are in use.

Anyone an idea?

Kind regards,

Piet Blok

----- Original Message ----- 
From: "Piet Blok" <pb...@wanadoo.nl>
To: "Derby Discussion" <de...@db.apache.org>
Sent: Sunday, April 02, 2006 11:23 AM
Subject: Re: DRDA_InvalidReplyTooShort.S:Invalid reply from network server: 
Insufficient data.


> The mechanisme I described attempts to ensure that one and only one 
> Network Server will become active, even if, in multiple JVM's (on the same 
> machine) an attempt is made to start a server. The design goal is to 
> enable any application to request that a Network Server is available. If 
> there was no Network Server ready , a Server is launched in a separate JVM 
> and the application waits until that Server, or any other server, is 
> ready.
>
> (About a half year ago there was a long running thread in this forum on 
> how to start a server on the fly and wait for it to become ready, that 
> intrigued me)
>
> Yes, all sorts of problems, like port in use, arise, but the mechanisme is 
> designed to detect these situations and cope with them. There will be only 
> one winner that will serve all others. The loosers just die.
>
> The problem I described does not always occurr. In fact it only happended 
> once when simultaneously trying to start 30 servers. Other stress 
> attempts, including starting 100 servers, worked just fine.
>
> I will try to implement a capture of the winning Server err and out 
> streams in order to provide the requested information when the problem 
> occurrs again.
>
> Thanks very much for your answer.
>
> Kind regards,
>
> Piet Blok
>
> ----- Original Message ----- 
> From: "Bryan Pendleton" <bp...@amberpoint.com>
> To: "Derby Discussion" <de...@db.apache.org>
> Sent: Saturday, April 01, 2006 9:27 PM
> Subject: Re: DRDA_InvalidReplyTooShort.S:Invalid reply from network 
> server: Insufficient data.
>
>
>>> When stress testing a mechanism to simultaneously start the Derby 
>>> network server from different applications at the same time, I sometimes 
>>> get the following exception:
>>>
>>> DRDA_InvalidReplyTooShort.S:Invalid reply from network server: 
>>> Insufficient data.
>>>
>>> Is this possibly a bug?
>>
>> I'm not sure I understand the first paragraph above very well, but I 
>> can't
>> think of any reason you should be getting the ReplyTooShort response 
>> other
>> than a bug, so I would say yes, this sounds like a bug to me.
>>
>> When this happens, can you look on the server side, and find your 
>> derby.log,
>> and look there? Are there interesting messages there?
>>
>> Also, can you capture the actual console (System.out and System.err) from 
>> the
>> server side, and see if there are any interesting messages there?
>>
>> I suspect that the problem is happening on the server side, and the stack
>> trace and error message on the client side aren't going to be all that 
>> helpful.
>>
>> If you are trying to simultaneously start multiple instances of the 
>> network
>> server at the same time, aren't you going to get "port number in use" 
>> conflicts,
>> and the like?
>>
>> Perhaps, in addition to letting us know what you can learn from crawling 
>> around
>> in your server-side logs, you could also explain a bit more about what 
>> behavior
>> you are expecting to see from your server-starting mechanism that you are 
>> testing.
>>
>> thanks,
>>
>> bryan
>>
>>
>>
>>
>
>
> 



Re: DRDA_InvalidReplyTooShort.S:Invalid reply from network server: Insufficient data.

Posted by Piet Blok <pb...@wanadoo.nl>.
The mechanisme I described attempts to ensure that one and only one Network 
Server will become active, even if, in multiple JVM's (on the same machine) 
an attempt is made to start a server. The design goal is to enable any 
application to request that a Network Server is available. If there was no 
Network Server ready , a Server is launched in a separate JVM and the 
application waits until that Server, or any other server, is ready.

(About a half year ago there was a long running thread in this forum on how 
to start a server on the fly and wait for it to become ready, that intrigued 
me)

Yes, all sorts of problems, like port in use, arise, but the mechanisme is 
designed to detect these situations and cope with them. There will be only 
one winner that will serve all others. The loosers just die.

The problem I described does not always occurr. In fact it only happended 
once when simultaneously trying to start 30 servers. Other stress attempts, 
including starting 100 servers, worked just fine.

I will try to implement a capture of the winning Server err and out streams 
in order to provide the requested information when the problem occurrs 
again.

Thanks very much for your answer.

Kind regards,

Piet Blok

----- Original Message ----- 
From: "Bryan Pendleton" <bp...@amberpoint.com>
To: "Derby Discussion" <de...@db.apache.org>
Sent: Saturday, April 01, 2006 9:27 PM
Subject: Re: DRDA_InvalidReplyTooShort.S:Invalid reply from network server: 
Insufficient data.


>> When stress testing a mechanism to simultaneously start the Derby network 
>> server from different applications at the same time, I sometimes get the 
>> following exception:
>>
>> DRDA_InvalidReplyTooShort.S:Invalid reply from network server: 
>> Insufficient data.
>>
>> Is this possibly a bug?
>
> I'm not sure I understand the first paragraph above very well, but I can't
> think of any reason you should be getting the ReplyTooShort response other
> than a bug, so I would say yes, this sounds like a bug to me.
>
> When this happens, can you look on the server side, and find your 
> derby.log,
> and look there? Are there interesting messages there?
>
> Also, can you capture the actual console (System.out and System.err) from 
> the
> server side, and see if there are any interesting messages there?
>
> I suspect that the problem is happening on the server side, and the stack
> trace and error message on the client side aren't going to be all that 
> helpful.
>
> If you are trying to simultaneously start multiple instances of the 
> network
> server at the same time, aren't you going to get "port number in use" 
> conflicts,
> and the like?
>
> Perhaps, in addition to letting us know what you can learn from crawling 
> around
> in your server-side logs, you could also explain a bit more about what 
> behavior
> you are expecting to see from your server-starting mechanism that you are 
> testing.
>
> thanks,
>
> bryan
>
>
>
> 



Re: DRDA_InvalidReplyTooShort.S:Invalid reply from network server: Insufficient data.

Posted by Bryan Pendleton <bp...@amberpoint.com>.
> When stress testing a mechanism to simultaneously start the Derby 
> network server from different applications at the same time, I sometimes 
> get the following exception:
> 
> DRDA_InvalidReplyTooShort.S:Invalid reply from network server: 
> Insufficient data.
> 
> Is this possibly a bug?

I'm not sure I understand the first paragraph above very well, but I can't
think of any reason you should be getting the ReplyTooShort response other
than a bug, so I would say yes, this sounds like a bug to me.

When this happens, can you look on the server side, and find your derby.log,
and look there? Are there interesting messages there?

Also, can you capture the actual console (System.out and System.err) from the
server side, and see if there are any interesting messages there?

I suspect that the problem is happening on the server side, and the stack
trace and error message on the client side aren't going to be all that helpful.

If you are trying to simultaneously start multiple instances of the network
server at the same time, aren't you going to get "port number in use" conflicts,
and the like?

Perhaps, in addition to letting us know what you can learn from crawling around
in your server-side logs, you could also explain a bit more about what behavior
you are expecting to see from your server-starting mechanism that you are testing.

thanks,

bryan