Ignore:
Timestamp:
2024-03-21T20:02:29+13:00 (8 weeks ago)
Author:
anupama
Message:

Testing if usersDB exists should use the full path. There was an error message about no driver being found for the jdbc url going into the tomcat log that I hadn't noticed before. This is because createDatabaseIfNeeded tested if usersDB existed, and if not tried to create it. The problem was that the file usersDB that it tested for existence is now being created with the relative string of usersDB instead of the full path inside web/etc, so it couldn't locate that.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DerbyWrapper.java

    r38769 r38856  
    3333import org.greenstone.util.GlobalProperties;
    3434
     35import org.apache.log4j.*;
    3536/**
    3637 * The UserDB stores the groups in the "roles" table in expanded form, i.e. expandedGroups.
     
    4243    static final String PORT;
    4344    static final String DERBYSERVER;
    44     static final String PROTOCOL;   
    45 
     45    static final String PROTOCOL;
     46    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.util.DerbyWrapper.class.getName());
    4647    static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver";
    4748    static final String USERSDB = "usersDB";
     
    104105        protocol_str = PROTOCOL + USERSDB_DIR;
    105106        File usersDB_file = new File(USERSDB_DIR);
     107
     108        // to test for file existence, ensure we have full path to it,
     109        // as "usersDB" on its own may not exist at the level we're testing this from
     110        if(!USERSDB_DIR.startsWith(GlobalProperties.getGSDL3Home())) {
     111            usersDB_file = new File(GlobalProperties.getGSDL3Home() + File.separatorChar + "etc" + File.separatorChar + USERSDB_DIR);
     112        }
     113       
    106114        if (!usersDB_file.exists())
    107115        {
     
    118126            try
    119127            {
     128                //Class.forName(DRIVER).getDeclaredConstructor().newInstance();
    120129                DerbyWrapper.createDatabase(DriverManager.getConnection(protocol_str + ";create=true"));
    121130            }
Note: See TracChangeset for help on using the changeset viewer.