Project

General

Profile

« Previous | Next » 

Revision 4da40839

Added by Andreas Kohlbecker about 13 years ago

improved error reporting and fixing #2193

View differences:

ide/eclipse/Bootloader.launch
7 7
<listEntry value="1"/>
8 8
</listAttribute>
9 9
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
10
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-remote&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-commons&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-ext&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-model&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-persistence&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-services&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-io&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
10
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-remote-webapp&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-remote&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-commons&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-ext&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-model&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-persistence&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-services&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;cdmlib-io&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
11 11
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="eu.etaxonomy.cdm.server.Bootloader"/>
12
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-webapp=D:\workspaces\cdmlib-trunk\cdmlib-remote\target\cdmserver\&#13;&#10;-jmx"/>
12
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-webapp=D:\workspaces\cdmlib-trunk\cdmlib-remote-webapp\target\cdmserver\&#13;&#10;-jmx"/>
13 13
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="cdm-server"/>
14 14
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx1024M&#13;&#10;&#13;&#10;-XX:PermSize=128m &#13;&#10;-XX:MaxPermSize=192m&#13;&#10;&#13;&#10;-XX:+UseConcMarkSweepGC &#13;&#10;-XX:+CMSClassUnloadingEnabled &#13;&#10;-XX:+CMSPermGenSweepingEnabled&#13;&#10;&#13;&#10;-Dorg.eclipse.jetty.util.log.DEBUG=false&#13;&#10;&#13;&#10;-Dcom.sun.management.jmxremote.ssl=false&#13;&#10;-Dcom.sun.management.jmxremote.authenticate=false&#13;&#10;-Dcom.sun.management.jmxremote.port=9999"/>
15 15
</launchConfiguration>
ide/eclipse/run cdm-server.jar in debugmode.launch
1 1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 2
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
3 3
<stringAttribute key="bad_container_name" value="run_cdm-server_jar"/>
4
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
5
<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
6
</listAttribute>
4 7
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="C:\Programme\Java\jdk1.6.0_11\bin\java.exe"/>
5
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n&#13;&#10;&#13;&#10;-Xmx1024M&#13;&#10;&#13;&#10;-XX:PermSize=128m &#13;&#10;-XX:MaxPermSize=192m&#13;&#10;&#13;&#10;-XX:+UseConcMarkSweepGC &#13;&#10;-XX:+CMSClassUnloadingEnabled &#13;&#10;-XX:+CMSPermGenSweepingEnabled&#13;&#10;&#13;&#10;-jar cdm-server-2.4.jar"/>
8
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n&#13;&#10;&#13;&#10;-Xmx1024M&#13;&#10;&#13;&#10;-XX:PermSize=128m &#13;&#10;-XX:MaxPermSize=192m&#13;&#10;&#13;&#10;-XX:+UseConcMarkSweepGC &#13;&#10;-XX:+CMSClassUnloadingEnabled &#13;&#10;-XX:+CMSPermGenSweepingEnabled&#13;&#10;&#13;&#10;-jar cdm-server-2.5.jar  -datasources &quot;C:\Dokumente und Einstellungen\a.kohlbecker.BGBM\.cdmLibrary\datasources-tdwg.xml&quot;"/>
6 9
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/cdm-server/target}"/>
7 10
</launchConfiguration>
ide/eclipse/run cdm-server.jar.launch
1 1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 2
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
3 3
<stringAttribute key="bad_container_name" value="run_cdm-server_jar"/>
4
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
5
<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
6
</listAttribute>
4 7
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="C:\Programme\Java\jdk1.6.0_11\bin\java.exe"/>
5
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-Xmx1500M&#13;&#10;&#13;&#10;-XX:PermSize=128m &#13;&#10;-XX:MaxPermSize=196m&#13;&#10;&#13;&#10;-XX:+UseConcMarkSweepGC &#13;&#10;-XX:+CMSClassUnloadingEnabled &#13;&#10;-XX:+CMSPermGenSweepingEnabled&#13;&#10;&#13;&#10;-Dlog4j.configDebug=true&#13;&#10;&#13;&#10;-jar cdm-server-2.4.jar -jmx"/>
8
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-Xmx1500M&#13;&#10;&#13;&#10;-XX:PermSize=128m &#13;&#10;-XX:MaxPermSize=196m&#13;&#10;&#13;&#10;-XX:+UseConcMarkSweepGC &#13;&#10;-XX:+CMSClassUnloadingEnabled &#13;&#10;-XX:+CMSPermGenSweepingEnabled&#13;&#10;&#13;&#10;-Dlog4j.configDebug=true&#13;&#10;&#13;&#10;-jar cdm-server-2.5.jar -jmx"/>
6 9
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/cdm-server/target}"/>
7 10
</launchConfiguration>
src/main/java/eu/etaxonomy/cdm/server/Bootloader.java
28 28
import java.net.URL;
29 29
import java.sql.Connection;
30 30
import java.sql.SQLException;
31
import java.util.Enumeration;
32
import java.util.List;
31 33
import java.util.Set;
32 34

  
33 35
import javax.naming.NamingException;
......
42 44
import org.apache.log4j.Logger;
43 45
import org.apache.log4j.PatternLayout;
44 46
import org.apache.log4j.RollingFileAppender;
47
import org.apache.tools.ant.types.CommandlineJava.SysProperties;
45 48
import org.eclipse.jetty.jmx.MBeanContainer;
49
import org.eclipse.jetty.server.Handler;
46 50
import org.eclipse.jetty.server.Server;
47 51
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
52
import org.eclipse.jetty.server.handler.ContextHandler.Context;
48 53
import org.eclipse.jetty.util.component.LifeCycle;
54
import org.eclipse.jetty.util.component.LifeCycle.Listener;
49 55
import org.eclipse.jetty.util.log.Log;
50 56
import org.eclipse.jetty.webapp.WebAppClassLoader;
51 57
import org.eclipse.jetty.webapp.WebAppContext;
......
74 80
public final class Bootloader {
75 81
	//private static final String DEFAULT_WARFILE = "target/";
76 82

  
83
	/**
84
	 * @author a.kohlbecker
85
	 * @date 03.02.2011
86
	 *
87
	 */
88
	private class WebAppContextListener implements Listener {
89
		
90
		WebAppContext cdmWebappContext;
91
		/**
92
		 * @param cdmWebappContext
93
		 */
94
		public WebAppContextListener(WebAppContext cdmWebappContext) {
95
			this.cdmWebappContext = cdmWebappContext;
96
		}
97

  
98
		@Override
99
		public void lifeCycleStopping(LifeCycle event) {
100
			logger.error("lifeCycleStopping");
101
		}
102

  
103
		@Override
104
		public void lifeCycleStopped(LifeCycle event) {
105
			logger.error("lifeCycleStopped");
106
			
107
		}
108

  
109
		@Override
110
		public void lifeCycleStarting(LifeCycle event) {
111
			logger.error("lifeCycleStarting");
112
		}
113

  
114
		@SuppressWarnings("unchecked")
115
		@Override
116
		public void lifeCycleStarted(LifeCycle event) {
117
			logger.error("lifeCycleStarted");
118
			
119
			List<String> messages = getServletContextAttribute(cdmWebappContext, ATTRIBUTE_ERROR_MESSAGES, List.class);
120
			String dataSourceName = getServletContextAttribute(cdmWebappContext, ATTRIBUTE_DATASOURCE_NAME, String.class);
121
			
122
			if(messages != null && dataSourceName != null){
123
				CdmInstanceProperties configAndStatus = findConfigAndStatusFor(dataSourceName);
124
				configAndStatus.getProblems().addAll(messages);
125
				configAndStatus.setStatus(Status.error);
126
				try {
127
					logger.warn("Stopping context '" + dataSourceName + "' due to errors reported in ServletContext");
128
					cdmWebappContext.stop();
129
				} catch (Exception e) {
130
					logger.error(e);
131
				}
132
			}
133
		}
134

  
135

  
136
		@Override
137
		public void lifeCycleFailure(LifeCycle event, Throwable cause) {
138
			logger.error("lifeCycleFailure");
139
		}
140
	}
141

  
77 142
	private static final Logger logger = Logger.getLogger(Bootloader.class);
78 143
	
79 144
	private static final String DATASOURCE_BEANDEF_FILE = "datasources.xml";
......
90 155
    private static final File CDM_WEBAPP_TEMP_FOLDER = new File(TMP_PATH + CDM_WEBAPP_WAR_NAME);
91 156
    
92 157
    private static final String ATTRIBUTE_JDBC_JNDI_NAME = "cdm.jdbcJndiName";
93
    private static final String CDM_LOGFILE = "cdm.logfile";
158
    private static final String ATTRIBUTE_DATASOURCE_NAME = "cdm.datasource";
159
    private static final String ATTRIBUTE_CDM_LOGFILE = "cdm.logfile";
160
    /**
161
     * same as in eu.etaxonomy.cdm.remote.config.DataSourceConfigurer
162
     */
163
    private static final String ATTRIBUTE_ERROR_MESSAGES = "cdm.errorMessages";
164

  
94 165
    
95 166
    // memory requirements
96 167
    private static final long MB = 1024 * 1024;
......
99 170
    
100 171
    private static final int KB = 1024;
101 172
    
102
    private Set<CdmInstanceProperties> configAndStatus = null;
173
    
174
    private Set<CdmInstanceProperties> configAndStatusSet = null;
103 175
    
104 176
    public Set<CdmInstanceProperties> getConfigAndStatus() {
105
		return configAndStatus;
177
		return configAndStatusSet;
106 178
	}
107 179

  
108 180
	private File webappFile = null;
......
126 198
    /* end of singleton implementation */
127 199
    
128 200
    private Set<CdmInstanceProperties> loadDataSources(){
129
    	if(configAndStatus == null){
201
    	if(configAndStatusSet == null){
130 202
    		File datasourcesFile = new File(USERHOME_CDM_LIBRARY_PATH, DATASOURCE_BEANDEF_FILE); 
131
    		configAndStatus = DataSourcePropertyParser.parseDataSourceConfigs(datasourcesFile);
132
        	logger.info("cdm server instance names loaded: "+ configAndStatus.toString());
203
    		configAndStatusSet = DataSourcePropertyParser.parseDataSourceConfigs(datasourcesFile);
204
        	logger.info("cdm server instance names loaded: "+ configAndStatusSet.toString());
133 205
    	}
134
    	return configAndStatus;
206
    	return configAndStatusSet;
135 207
    }
136 208

  
137 209
    public int writeStreamTo(final InputStream input, final OutputStream output, int bufferSize) throws IOException {
......
213 285
	private File extractWar(String warName) throws IOException, FileNotFoundException {
214 286
		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
215 287
		String warFileName = warName + WAR_POSTFIX;
216
    	URL resource = classLoader.getResource(warFileName);
288

  
289
		// 1. find in classpath
290
		URL resource = classLoader.getResource(warFileName);
217 291
    	if (resource == null) {
218 292
    		logger.error("Could not find the " + warFileName + " on classpath!");
219
    		System.exit(1);
293
    		
294
    		File pomxml = new File("pom.xml");
295
    		if(pomxml.exists()){
296
    			// 2. try finding in target folder of maven project
297
    			File warFile = new File("target" + File.separator + warFileName);
298
    			logger.debug("looging for war file at " + warFile.getAbsolutePath());
299
    			if (warFile.canRead()) {
300
    				resource = warFile.toURI().toURL();
301
    			} else {
302
    				logger.error("Also could not find the " + warFileName + " in maven project, try excuting 'mvn install'");
303
    			}
304
    		}	
305
    	}
306
    	
307
    	if (resource == null) {
308
    		// no way finding the war file :-(
309
    		System.exit(1);    		
220 310
    	}
221 311
    	
312
    	
222 313
    	File warFile = new File(TMP_PATH, warName + "-" + WAR_POSTFIX);
223 314
    	logger.info("Extracting " + warFileName + " to " + warFile + " ...");
224 315
    	
......
287 378
    	    	defaultWebAppFile = new File("./src/main/webapp");	
288 379
    	    	
289 380
    	     } else {
290
    	    	//defaultWebAppFile = extractWar(DEFAULT_WEBAPP_WAR_NAME);
381
    	    	defaultWebAppFile = extractWar(DEFAULT_WEBAPP_WAR_NAME);
291 382
    	     }
292 383
    	 } else {    	 
293 384
    		 webappFile = extractWar(CDM_WEBAPP_WAR_NAME);
......
357 448

  
358 449
			@Override
359 450
			public void lifeCycleFailure(LifeCycle event, Throwable cause) {
451
				logger.error("Jetty LifeCycleFailure", cause);
360 452
			}
361 453

  
362 454
			@Override
......
387 479
        logger.info("setting contexts ...");
388 480
        server.setHandler(contexts);
389 481
        logger.info("starting jetty ...");
390
        server.start();
482
//        try {
483
        	
484
        	server.start();
485
        	
486
//        } catch(org.springframework.beans.BeansException e){
487
//        	Throwable rootCause = null;
488
//        	while(e.getCause() != null){
489
//        		rootCause = e.getCause();
490
//        	}
491
//        	if(rootCause != null && rootCause.getClass().getSimpleName().equals("InvalidCdmVersionException")){
492
//        		
493
//        		logger.error("rootCause ----------->" + rootCause.getMessage());
494
////        		for(CdmInstanceProperties props : configAndStatus){
495
////        			if(props.getDataSourceName())
496
////        		}
497
//        	}
498
//        }
499
        
391 500
        if(cmdLine.hasOption(WIN32SERVICE.getOpt())){
392 501
        	logger.info("jetty has started as win32 service");
393 502
        } else {
......
410 519
	private void verifyMemoryRequirement(String memoryName, long requiredSpacePerIntance, long availableSpace) {
411 520
		
412 521

  
413
		long requiredSpace = configAndStatus.size() * requiredSpacePerIntance;
522
		long requiredSpace = configAndStatusSet.size() * requiredSpacePerIntance;
414 523
		
415 524
		if(requiredSpace > availableSpace){
416 525
			
417 526
			String message = memoryName + " (" 
418 527
				+ (availableSpace / MB)  
419 528
				+ "MB) insufficient for " 
420
				+ configAndStatus.size()
529
				+ configAndStatusSet.size()
421 530
				+ " instances. Increase " + memoryName + " by " 
422 531
				+ ((requiredSpace - availableSpace)/MB) 
423 532
				+ "MB";
......
426 535
			
427 536
			// disabling some instances 
428 537
			int i=0;
429
			for(CdmInstanceProperties instanceProps : configAndStatus){
538
			for(CdmInstanceProperties instanceProps : configAndStatusSet){
430 539
				i++;
431 540
				if(i * requiredSpacePerIntance > availableSpace){
432 541
					instanceProps.setStatus(Status.disabled);
......
459 568

  
460 569
	private void addCdmServerContexts(boolean austostart) throws IOException {
461 570
		
462
		for(CdmInstanceProperties conf : configAndStatus){
571
		for(CdmInstanceProperties conf : configAndStatusSet){
463 572
			
464 573
			if(!conf.isEnabled()){
465 574
				logger.info(conf.getDataSourceName() + " is disabled => skipping");
......
480 589
            	continue;
481 590
            }
482 591
            
592
            cdmWebappContext.setAttribute(ATTRIBUTE_DATASOURCE_NAME, conf.getDataSourceName());
483 593
            cdmWebappContext.setAttribute(ATTRIBUTE_JDBC_JNDI_NAME, conf.getJdbcJndiName());
484 594
	        setWebApp(cdmWebappContext, webappFile);
485 595
	        
486
			cdmWebappContext.setAttribute(CDM_LOGFILE,
596
			cdmWebappContext.setAttribute(ATTRIBUTE_CDM_LOGFILE,
487 597
					LOG_PATH + File.separator + "cdm-"
488 598
							+ conf.getDataSourceName() + ".log");
489 599
   
......
504 614
	        	classLoader.addClassPath(classPath);
505 615
	        	cdmWebappContext.setClassLoader(classLoader);
506 616
        	}
507
	        
617

  
618
	        cdmWebappContext.addLifeCycleListener(new WebAppContextListener(cdmWebappContext));
508 619
	        contexts.addHandler(cdmWebappContext);  
509 620
	        
510 621
	        if(austostart){
511 622
		        try {
512 623
		        	conf.setStatus(CdmInstanceProperties.Status.starting);
513 624
					cdmWebappContext.start();
514
					conf.setStatus(CdmInstanceProperties.Status.started);
625
					if(!conf.getStatus().equals(Status.error)){
626
						conf.setStatus(CdmInstanceProperties.Status.started);
627
					}
515 628
				} catch (Exception e) {
516 629
					logger.error("Could not start " + cdmWebappContext.getContextPath());
517 630
					conf.setStatus(CdmInstanceProperties.Status.error);
......
521 634
        }
522 635
	}
523 636

  
637
	/**
638
	 * @param context
639
	 * @param webApplicationResource
640
	 */
524 641
	private void setWebApp(WebAppContext context, File webApplicationResource) {
525 642
		if(webApplicationResource.isDirectory()){
526 643
			context.setResourceBase(webApplicationResource.getAbsolutePath());
......
531 648
		}
532 649
	}
533 650

  
651
	/**
652
	 * @return
653
	 */
534 654
	private boolean isRunningFromSource() {
535 655
		String webappPathNormalized = webappFile.getAbsolutePath().replace('\\', '/');
536 656
		return webappPathNormalized.endsWith("src/main/webapp") || webappPathNormalized.endsWith("cdmlib-remote/target/cdmserver");
537 657
	}
658
	
659
	/**
660
	 * @param dataSourceName
661
	 * @return
662
	 */
663
	private CdmInstanceProperties findConfigAndStatusFor(String dataSourceName){
664
		for(CdmInstanceProperties props : configAndStatusSet){
665
			if(props.getDataSourceName().equals(dataSourceName)){
666
				return props;
667
			}
668
		}
669
		return null;
670
	}
671
	
672
	/**
673
	 * @param <T>
674
	 * @param webAppContext
675
	 * @param attributeName
676
	 * @param type
677
	 * @return
678
	 */
679
	@SuppressWarnings("unchecked")
680
	private <T> T getServletContextAttribute(WebAppContext webAppContext, String attributeName, Class<T> type) {
681
		
682
		Context servletContext = webAppContext.getServletContext();
683
		Object value = servletContext.getAttribute(attributeName);
684
		if( value != null && type.isAssignableFrom(value.getClass())){	
685
			
686
		}
687
		return (T) value;
688
	}
538 689
}
src/main/webapp/index.jsp
52 52
									<div class="block" id="datasources">
53 53
										<h2 class="title block-title pngfix">CDM Server Instances</h2>
54 54
										<table>
55
											<tr><th>Path</th><th>Database Url</th><th>Status</th><th>OAI-PMH Provider</th></tr>
55
											<tr><th>Path</th><th> </th><th>Database Url</th><th>Status</th><th>OAI-PMH Provider</th></tr>
56 56
                                            <%
57 57
                                           // the servelt context must use the class loader of the Bootloader class otherwise 
58 58
                                           // getting the status will not work in mulithreading environments !!!
......
72 72
                                                   String noBottomBorder = props.getStatus().equals(CdmInstanceProperties.Status.error) ? " style=\"border-bottom:none;\"" : "";
73 73
                                                   
74 74
	                                        	   out.append("<tr class=\"entry " + oddOrEven + "\" " +noBottomBorder+ ">");
75
	                                        	   out.append("<td class=\"base-url\"><a href=\"" + fullURL + "/portal/classification\">" + basePath + "</a></td>");
75
	                                        	   out.append("<td class=\"base-url\"><a href=\"" + fullURL + "\">" + basePath + "</a></td>");
76
	                                        	   out.append("<td class=\"test-url\"><a href=\"" + fullURL + "/portal/classification\">Test</a></td>");
76 77
                                                   out.append("<td class=\"db-url\">" + props.getUrl() + "</td>");
77 78
                                                   out.append("<td class=\"status " + props.getStatus() + "\">" + props.getStatus() + "</td>");
78 79
                                                   
src/site/fml/troubleshooting.fml
13 13
        How can I get help?
14 14
      </question>
15 15
      <answer>
16
        <p>The troubelshooting section is still under construction. I order to get help, please contact us by email: editsupport@bgbm.org</p>
16
        <p>The troubelshooting section is still under construction. If you don't find the answer here, please contact us by email: editsupport@bgbm.org</p>
17 17
      </answer>
18 18
    </faq>
19 19

  
20
    <faq id="whats-bar">
20
    <faq id="cdm-incompatible-version">
21 21
      <question>
22
        What is Bar?
22
        The CDMServer reports incompatible versions, e.g.:<code>Incompatible version [cichorieae] expected version: 3.0.0.0.201011090000, data base version 2.4.1.2.201004231015</code>
23 23
      </question>
24 24
      <answer>
25
        <p>some markup goes here</p>
25
        <p>The version of the database to which the server is trying to connect is not compatible to the software version of the server. 
26
        Please connect to the database using the Taxonomic Editor and update the database to the current version.
27
        <strong>Please make sure that you are using the latest stable releases of both, the CDM Server and the Taxonomic Editor</strong></p>
26 28
      </answer>
27 29
    </faq>
28 30
  </part>

Also available in: Unified diff