use of org.apache.ofbiz.base.container.ContainerException in project ofbiz-framework by apache.
the class CatalinaContainer method prepareChannelMcastService.
private McastService prepareChannelMcastService(Property clusterProp) throws ContainerException {
McastService mcast = new McastService();
String mcb = ContainerConfig.getPropertyValue(clusterProp, "mcast-bind-addr", null);
String mca = ContainerConfig.getPropertyValue(clusterProp, "mcast-addr", null);
int mcp = ContainerConfig.getPropertyValue(clusterProp, "mcast-port", -1);
int mcf = ContainerConfig.getPropertyValue(clusterProp, "mcast-freq", 500);
int mcd = ContainerConfig.getPropertyValue(clusterProp, "mcast-drop-time", 3000);
if (mca == null || mcp == -1) {
throw new ContainerException("Cluster configuration requires mcast-addr and mcast-port properties");
}
if (mcb != null) {
mcast.setMcastBindAddress(mcb);
}
mcast.setAddress(mca);
mcast.setPort(mcp);
mcast.setMcastDropTime(mcd);
mcast.setFrequency(mcf);
return mcast;
}
use of org.apache.ofbiz.base.container.ContainerException in project ofbiz-framework by apache.
the class CatalinaContainer method prepareTomcatServer.
private Tomcat prepareTomcatServer(ContainerConfig.Configuration cc, ContainerConfig.Configuration.Property engineConfig) throws ContainerException {
System.setProperty(Globals.CATALINA_HOME_PROP, System.getProperty("ofbiz.home") + "/" + ContainerConfig.getPropertyValue(cc, "catalina-runtime-home", "runtime/catalina"));
System.setProperty(Globals.CATALINA_BASE_PROP, System.getProperty(Globals.CATALINA_HOME_PROP));
Tomcat tomcat = new Tomcat();
tomcat.setBaseDir(System.getProperty("ofbiz.home"));
Property defaultHostProp = engineConfig.getProperty("default-host");
if (defaultHostProp == null) {
throw new ContainerException("default-host element of server property is required for catalina!");
}
tomcat.setHostname(defaultHostProp.value);
if (ContainerConfig.getPropertyValue(cc, "use-naming", false)) {
tomcat.enableNaming();
}
StandardServer server = (StandardServer) tomcat.getServer();
try {
server.setGlobalNamingContext(new InitialContext());
} catch (NamingException e) {
throw new ContainerException(e);
}
return tomcat;
}
use of org.apache.ofbiz.base.container.ContainerException in project ofbiz-framework by apache.
the class EntityDataLoadContainer method getTenantList.
private List<GenericValue> getTenantList(Property delegatorNameProp) throws ContainerException {
if (!EntityUtil.isMultiTenantEnabled()) {
throw new ContainerException("Multitenant is disabled, must be enabled in general.properties -> multitenant=Y");
}
Delegator delegator = getDelegator(delegatorNameProp, null);
List<EntityExpr> expr = new ArrayList<EntityExpr>();
expr.add(EntityCondition.makeCondition("disabled", EntityOperator.EQUALS, "N"));
expr.add(EntityCondition.makeCondition("disabled", EntityOperator.EQUALS, null));
try {
return EntityQuery.use(delegator).from("Tenant").where(expr, EntityOperator.OR).queryList();
} catch (GenericEntityException e) {
throw new ContainerException(e);
}
}
use of org.apache.ofbiz.base.container.ContainerException in project ofbiz-framework by apache.
the class JavaMailContainer method getStore.
protected Store getStore(Session session) throws ContainerException {
// create the store object
Store store;
try {
store = session.getStore();
} catch (NoSuchProviderException e) {
throw new ContainerException(e);
}
// re-write the URLName including the password for this store
if (store != null && store.getURLName() != null) {
URLName urlName = this.updateUrlName(store.getURLName(), session.getProperties());
if (Debug.verboseOn()) {
Debug.logVerbose("URLName - " + urlName.toString(), module);
}
try {
store = session.getStore(urlName);
} catch (NoSuchProviderException e) {
throw new ContainerException(e);
}
}
if (store == null) {
throw new ContainerException("No store configured!");
}
// test the store
try {
store.connect();
store.close();
} catch (MessagingException e) {
Debug.logError("Unable to connect to mail store : " + store.getURLName().toString() + " : " + e.getMessage(), module);
}
return store;
}
use of org.apache.ofbiz.base.container.ContainerException in project ofbiz-framework by apache.
the class ServiceContainer method init.
@Override
public void init(List<StartupCommand> ofbizCommands, String name, String configFile) throws ContainerException {
this.name = name;
// initialize the LocalDispatcherFactory
ContainerConfig.Configuration cfg = ContainerConfig.getConfiguration(name, configFile);
ContainerConfig.Configuration.Property dispatcherFactoryProperty = cfg.getProperty("dispatcher-factory");
if (dispatcherFactoryProperty == null || UtilValidate.isEmpty(dispatcherFactoryProperty.value)) {
throw new ContainerException("Unable to initialize container " + name + ": dispatcher-factory property is not set");
}
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Class<?> c = loader.loadClass(dispatcherFactoryProperty.value);
dispatcherFactory = (LocalDispatcherFactory) c.newInstance();
} catch (Exception e) {
throw new ContainerException(e);
}
}
Aggregations