Search in sources :

Example 11 with ContainerException

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;
}
Also used : ContainerException(org.apache.ofbiz.base.container.ContainerException) McastService(org.apache.catalina.tribes.membership.McastService)

Example 12 with ContainerException

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;
}
Also used : Tomcat(org.apache.catalina.startup.Tomcat) ContainerException(org.apache.ofbiz.base.container.ContainerException) StandardServer(org.apache.catalina.core.StandardServer) NamingException(javax.naming.NamingException) Property(org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property) InitialContext(javax.naming.InitialContext)

Example 13 with ContainerException

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);
    }
}
Also used : Delegator(org.apache.ofbiz.entity.Delegator) ContainerException(org.apache.ofbiz.base.container.ContainerException) GenericEntityException(org.apache.ofbiz.entity.GenericEntityException) ArrayList(java.util.ArrayList) EntityExpr(org.apache.ofbiz.entity.condition.EntityExpr)

Example 14 with ContainerException

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;
}
Also used : ContainerException(org.apache.ofbiz.base.container.ContainerException) MessagingException(javax.mail.MessagingException) URLName(javax.mail.URLName) Store(javax.mail.Store) NoSuchProviderException(javax.mail.NoSuchProviderException)

Example 15 with ContainerException

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);
    }
}
Also used : ContainerConfig(org.apache.ofbiz.base.container.ContainerConfig) ContainerException(org.apache.ofbiz.base.container.ContainerException) ContainerException(org.apache.ofbiz.base.container.ContainerException)

Aggregations

ContainerException (org.apache.ofbiz.base.container.ContainerException)15 File (java.io.File)4 ArrayList (java.util.ArrayList)4 URL (java.net.URL)3 NamingException (javax.naming.NamingException)3 ContainerConfig (org.apache.ofbiz.base.container.ContainerConfig)3 Delegator (org.apache.ofbiz.entity.Delegator)3 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)3 IOException (java.io.IOException)2 List (java.util.List)2 Map (java.util.Map)2 InitialContext (javax.naming.InitialContext)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 TestResult (junit.framework.TestResult)2 TestSuite (junit.framework.TestSuite)2 Container (org.apache.ofbiz.base.container.Container)2 Property (org.apache.ofbiz.base.container.ContainerConfig.Configuration.Property)2 StartupCommand (org.apache.ofbiz.base.start.StartupCommand)2 StartupCommandUtil (org.apache.ofbiz.base.start.StartupCommandUtil)2 Debug (org.apache.ofbiz.base.util.Debug)2