Project

General

Profile

« Previous | Next » 

Revision 4269efd3

Added by Andreas Kohlbecker almost 3 years ago

ref #9602 preventing instances from starting up in case of db connection problems

View differences:

src/main/java/eu/etaxonomy/cdm/server/instance/CdmInstance.java
44 44
        return problems;
45 45
    }
46 46

  
47
    public void setProblems(List<String> problems) {
48
        this.problems = problems;
47
    public void clearProblems() {
48
        getProblems().clear();
49 49
    }
50 50

  
51 51
    public boolean onError() {
......
147 147
    public void lifeCycleStarting(LifeCycle event) {
148 148
        logger.info("lifeCycleStarting");
149 149
        setStatus(Status.starting);
150
        setProblems(null);
151 150
    }
152 151

  
153 152
    @SuppressWarnings("unchecked")
......
213 212
                connection = datasource.getConnection();
214 213
                connection.close();
215 214
            } catch (SQLException e) {
216
                sqlerror = e.getMessage() + "["+ e.getSQLState() + "]";
215
                sqlerror = "Can not establish connection to data base " + configuration.getDataSourceUrl() + " [sql error code: "+ e.getSQLState() + "]";
217 216
                getProblems().add(sqlerror);
218 217
                setStatus(Status.error);
219 218
                if(connection !=  null){
src/main/java/eu/etaxonomy/cdm/server/instance/InstanceManager.java
100 100
     * @throws Exception
101 101
     */
102 102
    public void start(CdmInstance instance) {
103
        instance.clearProblems();
103 104
        if (instance.getWebAppContext() != null) {
104 105
            // instance.unbindJndiDataSource();
105 106
            // instance.bindJndiDataSource();
106 107
            if (!instance.bindJndiDataSource()) {
107 108
                // a problem with the datasource occurred skip this webapp
108
                // cdmWebappContext = null;
109 109
                logger.error("a problem with the datasource occurred -> aboarding startup of /" + instance.getName());
110 110
                instance.setStatus(Status.error);
111
                // return cdmWebappContext;
112
            }
113
            if (logger.isDebugEnabled()) {
114
                logger.debug("starting " + instance.getName());
111
            } else {
112
                // ready for startup add to queue
113
                if (logger.isDebugEnabled()) {
114
                    logger.debug("starting " + instance.getName());
115
                }
116
                queue.add(instance);
115 117
            }
116
            // instance.getWebAppContext().start();
117
            queue.add(instance);
118 118
        }
119 119
    }
120 120

  

Also available in: Unified diff