Don't continue platform startup if Adempiere.properties file is missing.
This commit is contained in:
parent
6f2f78cd11
commit
d4be04bd12
|
|
@ -533,7 +533,7 @@ public final class Ini implements Serializable
|
||||||
* @param tryUserHome get user home first
|
* @param tryUserHome get user home first
|
||||||
* @return file name
|
* @return file name
|
||||||
*/
|
*/
|
||||||
private static String getFileName (boolean tryUserHome)
|
public static String getFileName (boolean tryUserHome)
|
||||||
{
|
{
|
||||||
if (System.getProperty("PropertyFile") != null)
|
if (System.getProperty("PropertyFile") != null)
|
||||||
return System.getProperty("PropertyFile");
|
return System.getProperty("PropertyFile");
|
||||||
|
|
@ -740,20 +740,24 @@ public final class Ini implements Serializable
|
||||||
public static String getAdempiereHome()
|
public static String getAdempiereHome()
|
||||||
{
|
{
|
||||||
String env = System.getProperty (ENV_PREFIX + ADEMPIERE_HOME);
|
String env = System.getProperty (ENV_PREFIX + ADEMPIERE_HOME);
|
||||||
if (env == null)
|
if (env == null || env.trim().length() == 0)
|
||||||
env = System.getProperty (ADEMPIERE_HOME);
|
env = System.getProperty (ADEMPIERE_HOME);
|
||||||
if (env == null && ! isClient()) {
|
if (env == null || env.trim().length() == 0)
|
||||||
InitialContext context;
|
{
|
||||||
try {
|
//client - user home, server - current working directory
|
||||||
context = new InitialContext();
|
String current = isClient() ? System.getProperty("user.home")
|
||||||
env = (String) context.lookup("java:comp/env/"+ADEMPIERE_HOME);
|
: System.getProperty("user.dir");
|
||||||
} catch (NamingException e) {
|
if (current != null && current.trim().length() > 0)
|
||||||
// teo_sarca: if you uncomment the line below you will get an NPE when generating models
|
{
|
||||||
//getLogger().fine( "Not found 'java:comp/env/"+ADEMPIERE_HOME+"' in Initial Context. " +e.getMessage());
|
//check directory exists and writable
|
||||||
|
File file = new File(current);
|
||||||
|
if (file.exists() && file.canWrite())
|
||||||
|
{
|
||||||
|
env = current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (env == null || "".equals(env) ) // Fallback
|
if (env == null || env.trim().length() == 0 ) // Fallback
|
||||||
env = File.separator + "Adempiere";
|
env = File.separator + "Adempiere";
|
||||||
return env;
|
return env;
|
||||||
} // getAdempiereHome
|
} // getAdempiereHome
|
||||||
|
|
@ -774,35 +778,7 @@ public final class Ini implements Serializable
|
||||||
*/
|
*/
|
||||||
public static String findAdempiereHome()
|
public static String findAdempiereHome()
|
||||||
{
|
{
|
||||||
String ch = getAdempiereHome();
|
return getAdempiereHome();
|
||||||
if (ch != null)
|
|
||||||
return ch;
|
|
||||||
|
|
||||||
File[] roots = File.listRoots();
|
|
||||||
for (int i = 0; i < roots.length; i++)
|
|
||||||
{
|
|
||||||
if (roots[i].getAbsolutePath().startsWith("A:"))
|
|
||||||
continue;
|
|
||||||
File[] subs = roots[i].listFiles();
|
|
||||||
if (subs == null)
|
|
||||||
continue;
|
|
||||||
for (int j = 0; j < subs.length; j++)
|
|
||||||
{
|
|
||||||
if (!subs[j].isDirectory())
|
|
||||||
continue;
|
|
||||||
String fileName = subs[j].getAbsolutePath();
|
|
||||||
// globalqss, it's leaving log in first directory with lib subdirectory. i.e. Oracle
|
|
||||||
// if (fileName.indexOf("Adempiere") != 1)
|
|
||||||
if (fileName.indexOf("Adempiere") != -1)
|
|
||||||
{
|
|
||||||
String libDir = fileName + File.separator + "lib";
|
|
||||||
File lib = new File(libDir);
|
|
||||||
if (lib.exists() && lib.isDirectory())
|
|
||||||
return fileName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ch;
|
|
||||||
} // findAdempiereHome
|
} // findAdempiereHome
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.util;
|
package org.compiere.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
@ -158,6 +159,12 @@ public class WebEnv
|
||||||
info.append("\n").append(name).append("=").append(value);
|
info.append("\n").append(name).append("=").append(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String propertyFile = Ini.getFileName(false);
|
||||||
|
File file = new File(propertyFile);
|
||||||
|
if (!file.exists())
|
||||||
|
{
|
||||||
|
throw new java.lang.IllegalStateException("Adempiere.properties is not setup. PropertyFile="+propertyFile);
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
s_initOK = Adempiere.startup(false);
|
s_initOK = Adempiere.startup(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue