Issue Details (XML | Word | Printable)

Key: DERBY-2501
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Trivial Trivial
Assignee: John H. Embretsen
Reporter: John H. Embretsen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Batch scripts in bin\ report extraneous errors when DERBY_HOME is invalid

Created: 29/Mar/07 09:33 AM   Updated: 08/May/07 07:28 PM
Return to search
Component/s: Demos/Scripts
Affects Version/s: 10.2.1.6, 10.2.2.0
Fix Version/s: 10.3.1.4

Time Tracking:
Not Specified

File Attachments:
  Size
File d2501_v1.diff 2007-03-29 09:54 AM John H. Embretsen 0.6 kB
File Licensed for inclusion in ASF works d2501_v2.diff 2007-03-29 03:25 PM John H. Embretsen 0.8 kB
File Licensed for inclusion in ASF works derby-2501-check-javacmd.diff 2007-04-26 10:51 PM Andrew McIntyre 3 kB
Environment: Windows
Issue Links:
Reference
 

Urgency: Normal
Resolution Date: 04/May/07 12:31 AM


 Description  « Hide
If DERBY_HOME is set to an invalid location (for example a directory that does not contain lib\derby.jar), most .bat scripts in the bin directory (the ones that call derby_common.bat) report three distinct error messages, of which only one is of value to the user.

Reproduction:

C:\Derby_10\db-derby-10.2.2.0-bin>set DERBY_HOME=c:\temp

C:\Derby_10\db-derby-10.2.2.0-bin>echo %DERBY_HOME%
c:\temp

C:\Derby_10\db-derby-10.2.2.0-bin>bin\sysinfo
DERBY_HOME is set incorrectly or derby.jar could not be located. Please set DERBY_HOME.
The system cannot find the batch label specified - end
'""' is not recognized as an internal or external command,
operable program or batch file.


The distinct error messages are:

1) DERBY_HOME is set incorrectly or derby.jar could not be located. Please set DERBY_HOME.

2) The system cannot find the batch label specified - end

3) '""' is not recognized as an internal or external command, operable program or batch file.

Only 1) is relevant for the user, and should ideally be the only one displayed.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
John H. Embretsen added a comment - 29/Mar/07 09:40 AM
I filed this as a bug because error message 2) is caused by a bug in the derby_common.bat script. As mentioned in a post on the derby-user mailing list [1], a label "end" is called in the derby_common.bat script when the DERBY_HOME environment variable is not set to a valid location (label "noAntHome"), although this label ("end") does not exist in this script. The label "endcommon" should probably be used instead, which does exist.

The label for reporting invalid DERBY_HOME should be renamed from "noAntHome" to "noDerbyHome", as these scripts have nothing to do with Ant.

Error message 3) is caused by the _JAVACMD variable not being set (so the scripts execute "" instead of for example "c:\java6\bin\java") if DERBY_HOME is invalid.

[1] http://www.nabble.com/Re%3A-Setting-the-environment-variables-for-Derby-p9720589.html

John H. Embretsen added a comment - 29/Mar/07 09:54 AM
Attaching a patch 'd2501_v1.diff', which modifies the following file in trunk:

M bin\derby_common.bat

The patch renames the "noAntHome" label to "noDerbyHome" and goes to the label "endcommon" instead of the non-existing "end" after the noDerbyHome error message is displayed. This eliminates error message 2).

This patch does not do anything with error message 3), as I am not sure what the best way to handle this is. It could be removed by adding a check for _JAVACMD in all the scripts that call derby_common.bat, or perhaps by letting the derby_common.bat script call the "end" label of the parent scripts directly, but I fear that the latter option might be unnecessarily complicated to implement. Any comments or suggestions are appreciated!

Please review / commit this simple patch.

John H. Embretsen made changes - 29/Mar/07 09:54 AM
Field Original Value New Value
Attachment d2501_v1.diff [ 12354495 ]
John H. Embretsen made changes - 29/Mar/07 09:56 AM
Status Open [ 1 ] In Progress [ 3 ]
John H. Embretsen made changes - 29/Mar/07 09:56 AM
Derby Info [Patch Available]
John H. Embretsen made changes - 29/Mar/07 11:29 AM
Link This issue is related to DERBY-1032 [ DERBY-1032 ]
Laura Stewart added a comment - 29/Mar/07 03:08 PM
John - can we also expand the message that the user sees?
Perhaps to something like:

DERBY_HOME is set incorrectly or the derby.jar file could not be located. Set the DERBY_HOME environment variable to the path
where you installed Derby.


John H. Embretsen added a comment - 29/Mar/07 03:25 PM
Attaching new patch (d2501_v2.diff) incorporating Laura's suggestion. Error message 1) is now displayed on (at least) two lines:

DERBY_HOME is set incorrectly or derby.jar could not be located.
Please set the DERBY_HOME environment variable to the path where you installed Derby.

Please review the new patch instead of the old one.

John H. Embretsen made changes - 29/Mar/07 03:25 PM
Attachment d2501_v2.diff [ 12354526 ]
Andrew McIntyre added a comment - 26/Apr/07 10:51 PM
Attaching a patch which includes the check that _JAVACMD is set in the scripts where appropriate to prevent the last unnecessary error message. In most cases, it is expected that java.exe will be in your path on Windows, or if you don't want the last JDK / JRE you installed via a Windows installer, you should set JAVA_HOME.

Andrew McIntyre made changes - 26/Apr/07 10:51 PM
Attachment derby-2501-check-javacmd.diff [ 12356372 ]
John H. Embretsen added a comment - 02/May/07 06:53 AM
I have verified that the latest patch, derby-2501-check-javacmd.diff, will remove all unnecessary error messages mentioned in this Jira issue. I also verified that the default Java path can be overridden by setting JAVA_HOME. Tested on Win XP Pro, using JDK 1.4.2_12 and Java SE 6 (1.6.0) (default).

I think this patch is ready for commit.

Repository Revision Date User Message
ASF #535039 Fri May 04 00:31:07 UTC 2007 fuzzylogic DERBY-2501: Windows batch scripts should not report extraneous errors.

Original patch by John H. Embretsen <john.embretsen@sun.com>
Files Changed
MODIFY /db/derby/code/trunk/bin/dblook.bat
MODIFY /db/derby/code/trunk/bin/startNetworkServer.bat
MODIFY /db/derby/code/trunk/bin/ij.bat
MODIFY /db/derby/code/trunk/bin/derby_common.bat
MODIFY /db/derby/code/trunk/bin/sysinfo.bat
MODIFY /db/derby/code/trunk/bin/stopNetworkServer.bat
MODIFY /db/derby/code/trunk/bin/NetworkServerControl.bat

Andrew McIntyre added a comment - 04/May/07 12:31 AM
Thanks for the review, John! Committed -javacmd patch with revision 535039.

Andrew McIntyre made changes - 04/May/07 12:31 AM
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Derby Info [Patch Available]
John H. Embretsen added a comment - 08/May/07 07:28 PM
Thank you very much for the final patch work and the commit, Andrew!
I have verified the change by trying out a few of the scripts on Win XP.

John H. Embretsen made changes - 08/May/07 07:28 PM
Status Resolved [ 5 ] Closed [ 6 ]