Caucho Technology
  • resin 4.0
  • environment: class loaders, resources and jndi


    Resin organizes resources and classloaders into nested environments. Each environment context merges its own configuration with configuration inherited from the parent environment. Each environment context: server, host, web-app, etc. may be configured with any of the environment configuration tags.

    Classloaders

    class-loader

    child of resin, server, host-default, host, web-app-default, web-app

    Adds dynamic classloaders to the current environment.

    Each environment (<server>, <host>, <web-app>) etc, can add dynamic classloaders. The environment will inherit the parent classloaders. Each <class-loader> is comprised of several implementing loader items: library-loader for WEB-INF/lib, compiling-loader for WEB-INF/classes, even make-loader for more complex auto-compilation.

    <class-loader> in resin-web.xml
    <web-app xmlns="http://caucho.com/ns/resin">
      <prologue>
        <class-loader>
          <compiling-loader path="WEB-INF/classes"/>
    
          <library-loader path="WEB-INF/lib"/>
        </class-loader>
      </prologue>
    </web-app>
    

    compiling-loader

    child of class-loader

    Configures an auto-compiling WEB-INF/classes-style class loader.

    The compiling-loader will automatically compile Java code into .class files loading them.

    argsAdditional arguments to be passed to the Java compiler. Resin 3.0none
    batchIf true, multiple changed *.java files will be compiled in a single batch. Resin 3.0.7true
    encodingI18N encoding for the Java compiler. Since Resin 3.0none
    pathFilesystem path for the class loader. Since Resin 3.0required
    sourceJava source directory. Since Resin 3.0value of path
    require-sourceIf true, .class files without matching .java files will be deleted. Since Resin 3.0false

    library-loader

    child of class-loader

    Configures a jar library, WEB-INF/lib-style class loader.

    The library-loader will add jar files in its path to the current classpath. Jar files are recognized wihen they have a filename extension of .jar or .zip.

    pathFilesystem path for the class loader. Since Resin 3.0required

    See com.caucho.loader.DirectoryLoader.

    tree-loader

    child of class-loader

    Configures a jar library, WEB-INF/lib-style class loader similar to library-loader, but will also find .jar and .zip files in subdirectories.

    pathFilesystem path for the class loader. Since Resin 3.0required

    See com.caucho.loader.TreeLoader.

    make-loader

    child of class-loader

    Configures a custom make-style loader.

    servlet-hack

    child of class-loader

    Use of servlet-hack is discouraged. Using servlet-hack violates the JDK's classloader delegation model and can produce surprising ClassCastExceptions.

    servlet-hack reverses the normal class loader order. Instead of parent classloaders having priority, child classloaders have priority.

    simple-loader

    child of class-loader

    Configures a simple classes-style class loader.

    .class files in the specified directory will be loaded without any special compilation steps (in contrast with compiling-loader.)

    pathFilesystem path for the class loader. Since Resin 3.0required
    prefixClass package prefix to only load to a subset of classes. Resin 3.0none

    Clustering

    cluster

    child of resin, server, host-default, host, web-app-default, web-app

    Configures a cluster of Resin servers for load balancing and sharing state information.

    Each cluster is a collection of Resin servers. The servers will share session information if the sessions are configured for <cluster-store>.

    Each environment context is associated with a single cluster. If no cluster is defined for the context, it defaults to the parent cluster.

    Normally, the cluster will be configured in the <server> context, although a cluster could be defined in a web-app for finer load-balancing. Only clusters defined in the <server> context are used for listening to ports. Other clusters are only for outgoing load balancing.

    ididentifies the cluster for later reference. Since Resin 3.0none
    srunconfigures the srun port and protocol for a cluster server. Since Resin 3.0none
    cluster-groupspecialized configuration for sub-clusters. Since Resin 3.0none
    cluster-refan identifier for a previous cluster-definition to use for the cluster. Since Resin 3.0none
    <resin xmlns="http://caucho.com/ns/resin">
    <server>
      <cluster>
        <srun id='a' port='6810'/>
        <srun id='b' port='6811'/>
      </cluster>
      ...
    

    cluster-definition

    child of resin, server, host-default, host, web-app-default, web-app

    Defines a cluster for later use by cluster-ref.

    ididentifies the cluster for later reference. Since Resin 3.0required
    srunconfigures the srun port and protocol for a cluster server. Since Resin 3.0none
    cluster-groupspecialized configuration for sub-clusters. Since Resin 3.0none

    Resources

    connector

    child of resin, server, host-default, host, web-app-default, web-app

    Configures a JCA resource adapter and its associated connection factories.

    The resource adapter/connector will have been added as a rar file (see resource-deploy. The <connector> configures that rar resource.

    Connector Example
    <connector connector-name="Test Resource">
      <connection-factory jndi-name="eis/test">
        <init>
          <value>b</value>
        </init>
      </connection-factory>
    </connector>
    
    connectorConfigures a connectorrequired
    connector-nameSpecifies the rar connector's display-namerequired
    resource-adapterConfigures the resource-adapteroptional
    connection-factoryConfigures a connection-factoryoptional
    jndi-nameJNDI name for a resource-adapter or connection-factoryrequired
    typeFor connectors with multiple connection-factories, specifies the connection-factoryoptional
    local-transaction-optimizationEnables the local transaction optimization. Resin 3.0.7true
    initBean-style initializationoptional
    connector schema
    element connector {
      connector-name { string }
    
      & resource-adapter?
    
      & connection-factory*
    }
    
    element connection-factory {
      jndi-name,
    
      type?,
    
      element init { any }?
    }
    
    element resource-adapter {
      jndi-name,
    
      element init { any }?
    }
    

    database

    child of resin, server, host-default, host, web-app-default, web-app

    Defines a database resource.

    The database configuration section has more details on the configuration. A code pattern for using databases is in a DataSource tutorial.

    <database jndi-name='jdbc/test_mysql'>
      <driver 
        type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
        <url>jdbc:mysql://localhost:3306/test</url>
        <user></user>
        <password></password>
      </driver>
    </database>
    

    ejb-server

    child of resin, server, host-default, host, web-app-default, web-app

    Configures an EJB/CMP server. See the CMP configuration for more details.

    env-entry

    child of resin, server, host-default, host, web-app-default, web-app

    Configures a JNDI scalar value for JNDI-based application configuration.

    Some application beans prefer to retrieve configuration data from JNDI, including String, Integer, and Double constants. env-entry configures that data in the current context. As with other Resin configuration, the value can use JSP-EL expressions.

    env-entry-nameJNDI name to store the value. Since Servlet 2.1required
    env-entry-typeJava type for the value. Since Servlet 2.1required
    env-entry-valueValue to be stored. Since Servlet 2.1required

    The example configuration stores a string in java:comp/env/greeting. Following the J2EE spec, the env-entry-name is relative to java:comp/env. If the env-entry is in the <host> context, it will be visible to all web-apps in the host.

    Example resin.xml fragment
    <env-entry>
      <env-entry-name>greeting</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
      <env-entry-value>Hello, World</env-entry-value>
    </env-entry>
    

    The following servlet fragment is a typical use in a servlet. The servlet only looks up the variable once and stores it for later use.

    GreetingServlet.java
    import java.io.*;
    import javax.naming.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    
    public class TestServlet extends HttpServlet {
      private String greeting;
    
      public void init()
        throws ServletException
      {
        try {
          Context env = 
            (Context) new InitialContext().lookup("java:comp/env");
          greeting = (String) env.lookup("greeting");
        } catch (NamingException e) {
          throw new ServletException(e);
        }
      }
    
      ...
    }
    
    env-entry schema
    element env-entry {
      (attribute env-entry-name { string } | 
       element env-entry-name { string }),
    
      (attribute env-entry-type { string } | 
       element env-entry-type { string }),
    
      (attribute env-entry-value { string } | 
       element env-entry-value { string })
    }
    

    jndi-link

    child of resin, server, host-default, host, web-app-default, web-app

    Links a foreign JNDI contexts or JNDI object.

    Resin's JNDI can link to foreign JNDI contexts. For example, third-party EJB servers will often expose their EJB beans through a JNDI context. jndi-link will create the appropriate InitialContextFactory, configure it, and lookup the foreign JNDI objects.

    jndi-nameThe JNDI name where the foreign context should be linked. Resin 3.0required
    factoryClass name of the JNDI InitialContextFactory. Since Resin 1.2optional
    foreign-nameSub-context of the foreign JNDI context. Since Resin 1.2none
    init-paramConfiguration parameters for the JNDI environment passed to InitialContextFactory. Since Resin 1.2none
    Linking a WebLogic EJB client bean
    <jndi-link>
      <jndi-name>java:comp/env/ejb/traderHome</jndi-name>
      <factory>weblogic.jndi.WLInitialContextFactory</factory>
      <init-param java.naming.provider.url="t3://localhost:7001"/>
      <foreign-name>statelessSession/TraderHome</foreign-name>
    </jndi-link>
    
    A JNDI symbolic link EJB client bean
    <jndi-link>
      <jndi-name>java:comp/env/ejb/MyBean</jndi-name>
      <foreign-name>/SampleBean</foreign-name>
    </jndi-link>
    

    reference

    child of resin, server, host-default, host, web-app-default, web-app

    Configures a JNDI ObjectFactory.

    JNDI ObjectFactories are used to create objects from JNDI references. The <reference> tag configures the ObjectFactory and stores it in JNDI.

    jndi-nameJNDI name for the reference. Since Resin 3.0required
    factoryClass name of the ObjectFactory. Resin 3.0required
    initBean-style initialization for the factorynone
    <reference>
      <jndi-name>hessian/hello</jndi-name>
      <factory>com.caucho.hessian.client.HessianProxyFactory</factory>
      <init url="http://localhost:8080/ejb/hello"/>
            type="test.HelloHome"/>
    </reference>
    

    resource

    child of resin, server, host-default, host, web-app-default, web-app

    Configures a custom bean resource and stores in JNDI.

    Resources are beans stored in JNDI. The resources can be created from any Java class that conforms to the bean conventions. Configuration of the resource is in the <init> section. Field values may use JSP-EL expressions as well as constant strings or even complex sub-beans.

    jndi-nameJNDI name for the resource. Since Resin 3.0required
    typeBean class implementing the resource. Since Resin 3.0required
    argArguments to the resource's constructor. Since Resin 3.0optional
    mbean-nameJMX name for management registration. Resin 3.0optional
    initBean-style initialization for the beanoptional
    listenerRegisters the bean as a listener for a JMX emitter. Resin 3.0optional
    local-transaction-optimizationEnables the local transaction optimization. Resin 3.0.7true
    <resource jndi-name="env/test">
      <type>test.MyBean</type>
      <init>
        <greeting>Hello</greeting>
        <server>${'${'}serverId}</server>
        <sub-bean>
          <value>${'${2'} + 2}</value>
        </sub-bean>
      </init>
    </resource>
    
    schema
    r_listener-Resource = element listener {
      r_mbean-name,
    
      r_handback*
    }
    
    r_resource = element resource {
      (r_jndi-name?
    
      & r_mbean-name?
    
      & r_mbean-interface?),
    
      (r_type,
    
      r_arg*)?,
    
      (r_init*
    
      & r_listener-Resource*)
    }
    

    resource-deploy

    child of resin, server, host-default, host, web-app-default, web-app

    Defines a deployment directory for .rar files.

    Connectors and resources defined in .rar files must be deployed before they can be configured by connector. The <resource-deploy> tag specifies the directory for that deployment.

    example resource-deploy
    <host>
      <resource-deploy path="deploy"/>
    
      ...
    </host>
    
    resource-deployConfigures .rar deploymentrequired
    pathConfigures the path where users will place .rar filesrequired
    expand-pathConfigures the directory where Resin will expand rar filesthe path value
    schema
    element resource-deploy {
      (attribute path { string } | element path { string })
    
      & (attribute expand-path { string } | 
             element expand-path { string })?
    }
    

    resource-ref

    child of resin, server, host-default, host, web-app-default, web-app

    Declares that the application needs a resouce configuration.

    resource-ref is not directly used by Resin. It's a servlet configuration item intended to tell GUI tools which resources need configuration. Resource configuration in Resin uses the resource, reference, database, and ejb-server tags.

    For backwards compatibility, Resin 2.1-style configuration files may still use resource-ref to configure resources, but it's recommended to convert the configuration.

    Logging

    log

    child of resin, server, host-default, host, web-app-default, web-app

    Configures JDK 1.4 java.util.logger logging.

    The log configuration describes log in detail.

    stderr-log

    child of resin, server, host-default, host, web-app-default, web-app

    Configures the destination for System.err.

    The log configuration describes stderr-log in detail.

    stdout-log

    child of resin, server, host-default, host, web-app-default, web-app

    Configures the destination for System.out.

    The log configuration describes stderr-log in detail.

    Authenticator

    authenticator

    child of resin, server, host-default, host, web-app-default, web-app, login-config

    Configures an authentication resource for the current context.

    Resin's servlet authentication uses an authentication resource to validate user login and to provide single-signon capability. The authenticator is configured in the environment context where it is shared. So an authenticator configured in the web-app only applies to the web-app, but an authenticator configured in the host will apply to all hosts.

    The authenticator class is selected with the type attribute. It can be any custom class extending com.caucho.server.security.AbstractAuthenticator. Configuration of the authenticator uses bean-style configuration in the <init> tag.

    jndi-nameThe JNDI name where the authenticator is stored. Since Resin 3.0java:comp/env/caucho/auth
    typeThe implementing class for the authenticator. Since Resin 3.0required
    initA bean-style configuration section. Since Resin 3.0none

    Miscellaneous

    system-property

    child of resin, server, host-default, host, web-app-default, web-app

    Sets a Java system property. The effect is the same as if you had called java.lang.System before starting Resin.

    <resin>
      <system-property foo="bar"/>
    </resin>
    

    javac

    child of resin, server, host-default, host, web-app-default, web-app

    Configures the Java compiler for automatically compiled files.

    The javac configuration is used for JSP, XSL, EJB and compiling-loader configuration.

    compilerConfigures the Java compiler to use. Since Resin 3.0internal
    argsAny additional arguments for the compiler. Since Resin 3.0none
    encodingAny encoding valued for the compiler. Since Resin 3.0none

    dependency

    child of resin, server, host-default, host, web-app-default, web-app

    Configures a path as a file which should force a reload when changed, like web.xml and resin.xml.

    pathFilesystem path to the dependent file. Since Resin 3.0required
    web.xml
    <web-app xmlns="http://caucho.com/ns/resin">
      <dependency path="WEB-INF/struts-config.xml"/>
      ...
    </web-app>
    

    dependency-check-interval

    child of resin, server, host-default, host, web-app-default, web-app
    default 2s

    Configures how often the environment context should be checked for changes.

    Resin automatically checks each environment for updates, generally class or configuration updates. Because these checks can take a considerable amount of time, deployment servers should use high values like 60s or more while development machines will want low values like 2s.

    The interval defaults to the parent's interval. So the web-app will default to the host's value.

    character-encoding

    child of resin, server, host-default, host, web-app-default, web-app
    default The default value is ISO-8859-1.

    Specifies the default character encoding for the environment.

    <web-app id='/'>
      <character-encoding>shift_jis</character-encoding>
      ...
    
    </web-app>
    

    case-insensitive

    child of resin, server, host-default, host, web-app-default, web-app
    default true on Windows, false on Unix.

    Specifies whether the environment context is case sensitive or insensitive.

    Because some operating systems are case-insensitive, it is important for security reasons for Resin to behave differently for case-sensitive and case-insensitive directories. For example, when case-insensitive is true, url-patterns will match in a case-insensitive manner, so TEST.JSP will work like test.jsp.

    temp-dir

    child of resin, server, host-default, host, web-app-default, web-app
    default Defaults to WEB-INF/tmp

    Application temp directory. This is the path used in javax.servlet.context.tempdir.

    work-dir

    child of resin, server, host-default, host, web-app-default, web-app
    default Defaults to WEB-INF/work

    Application work directory. This is the directory used for generated code like JSP, XSL and EJB classes.

    <authenticator>

    child of resin, cluster, host, web-app, login-config

    <authenticator> configures an authentication resource for the current environment context. The authenticator is used for login and also for the getUserPrincipal and isUserInRole methods of the HttpServletRequest object.

    The authenticators are scoped to their containing environment. An authenticator defined in WEB-INF/resin-web.xml applies only to the web-app, while an authenticator defined in the <cluster> section of the resin.xml applies to the entire cluster. The <management> configuration provides an authenticator which is available to all applications.

    Resin's servlet authentication uses an authentication resource to validate user login and to provide single-signon capability. The authenticator is configured in the environment context where it is shared. An authenticator configured in the web-app only applies to the web-app, but an authenticator configured in the host will apply to all hosts.

    The authenticator class is selected with the uri or class attribute. The class can be any custom class extending com.caucho.server.security.AbstractAuthenticator. The uri is a symbolic name for the authenticator class. More details on the predefined authenticators are in the Resin security documentation.

    • properties: Java properties-style authentication.
    • jaas: JAAS authentication.
    • jdbc: JDBC password-based authentication.
    • xml: XML JDBC password-based authentication.

    Configuration of the authenticator uses bean-style configuration in the <init> tag.

    See also: the Resin security section.

    <authenticator> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    bindingCustom WebBeans binding. Since Resin 3.1.5
    classThe implementing class for the authenticator. Since Resin 3.0
    jndi-nameThe JNDI name where the authenticator is stored. Since Resin 3.0
    nameThe Resin-IoC name where the authenticator is stored. Since Resin 3.1.5
    urishortcut alias for the authenticator class. Can also include inline parameters. Examples include xml:, property:, jdbc:, jndi:.
    initA bean-style configuration section. Since Resin 3.0
    <authenticator> schema
    r_authenticator = element authenticator {
      (r_class | r_uri)
      & r_binding*
      & r_init?
      & r_jndi-name?
      & r_name?
      & r_scope?
    }
    
    Example: WEB-INF/resin-web.xml properties-based authenticator
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <authenticator uri="properties:password-digest=none">
        <init>
    harry=quidditch,user
    ron=cannons,user,prefect
        </init>
      </authenticator>
    
    </web-app>
    

    <bam-service>

    child of resin, cluster, host, web-app

    <bam-service> configures a BamService to listen for messages. The service is always a single instance.

    <bam-service> can be used as a simple queueing service, replacing JMS queues and ejb-message-bean. By default the queue is consumed with a single thread. Unlike EJB message driven beans, <bam-service> uses a single instance like a servlet, not a pool of instances.

    The bean has full access to Resin-IoC capabilities, including dependency injection, transaction attributes, and aspect interception.

    <bam-service> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classClassname of the BamService beanrequired
    initIoC configuration for the listener bean
    nameThe JID of the service, used by clients to send messages to
    thread-maxThe number of threads to handle the queue. If 0, the service is not queued, but handles messages directly.1
    uriA shortcut name for the service, defined in META-INF/caucho/com.caucho.uri/com.caucho.bam.BamService.
    <bam-service> schema
    element ejb-message-bean {
      class
      & init?
      & name?
      & uri?
    }
    
    Example: Log service in WEB-INF/resin-web.xml
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <bam-service uri="caucho.log:">
        <name>log</name>
        <init>
          <name>test.Log<name>
        </init>
      </bam-service>
    
    </web-app>
    

    <bean>

    child of resin, cluster, host, web-app

    <bean> configures a custom singleton bean and stores in the WebBeans registry. <bean> is a primary configuration tag for Resin's IoC capabilities. The bean can also be optional registered in JNDI.

    Custom configuration of the bean is in the <init> section. Field values may use JSP-EL expressions as well as constant strings or even complex sub-beans. More details for configuring singleton beans are in Resin IoC.

    <bean> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classApplication class implementing the resource. Since Resin 3.0required
    initIoC configuration for the bean
    jndi-nameJNDI name for the resource. Since Resin 3.0
    mbean-nameJMX name for management registration. Resin 3.0
    nameThe name of the bean, used for @Named injection. Resin 3.1.4.
    scoperequest, session, conversational, application, singleton. Resin 3.1.4.singleton
    <bean> schema
    r_bean = element bean {
      r_class?
      & r_binding*
      & r_init?
      & r_jndi-name?
      & r_mbean-name?
      & r_mbean-interface?
      & r_name?
      & r_scope?
    }
    
    Example: WEB-INF/resin-web.xml singleton bean
    <web-app xmlns="http://caucho.com/ns/resin">
      <bean name="test">
        <type>test.MyBean</type>
        <init>
          <greeting>Hello</greeting>
          <server>${serverId}</server>
          <sub-bean>
            <value>${2 + 2}</value>
          </sub-bean>
        </init>
      </bean>
    </web-app>
    

    <case-insensitive>

    child of resin, cluster, host, web-app
    default true on Windows, false on Unix.

    <case-insensitive> specifies whether the environment context is case sensitive or insensitive.

    Because some operating systems are case-insensitive, it is important for security reasons for Resin to behave differently for case-sensitive and case-insensitive directories. For example, when case-insensitive is true, url-patterns will match in a case-insensitive manner, so TEST.JSP will work like test.jsp.

    <case-insensitive> schema
    r_case-insensitive = element case-insensitive {
      r_boolean-Type
    }
    

    <character-encoding>

    child of resin, cluster, host, web-app
    default The default value is ISO-8859-1.

    <character-encoding> specifies the default character encoding for the environment.

    <character-encoding> schema
    r_character-encoding = element character-encoding {
      string
    }
    
    Example: utf-8 as default character encoding
    <resin xmlns="http://caucho.com/ns/resin">
      <character-encoding>utf-8</character-encoding>
      ...
    
    </resin>
    

    <class-loader>

    child of resin, cluster, host, web-app

    <class-loader> configures a dynamic classloader for the current environment.

    Each environment (<cluster>, <host>, <web-app>) etc, can add dynamic classloaders. The environment will inherit the parent classloaders. Each <class-loader> is comprised of several implementing loader items: library-loader for WEB-INF/lib, compiling-loader for WEB-INF/classes.

    For web-apps, the classloaders generally belong in a <prologue> section, which ensures that Resin evaluates them first. The evaluation order is particularly important in cases like resin-web.xml vs web.xml, because the resin-web.xml is evaluated after the web.xml.

    classloader types
    ELEMENTDESCRIPTION
    <compiling-loader>Automatically compiles sources code to classes. It its the default loader for WEB-INF/classes.
    <library-loader>Loads jar files from a directory. It is the default loader for WEB-INF/lib.
    <simple-loader>Loads classes from a directory, but does not compile them automatically.
    <tree-loader>Loads jar files from a directory, recursively searching subdirectories.
    <class-loader> schema
    r_class-loader = element class-loader {
      r_compiling-loader*
    
      & r_library-loader*
    
      & r_simple-loader*
    
      & r_tree-loader*
    }
    
    Example: WEB-INF/resin-web.xml defined <class-loader>
    <web-app xmlns="http://caucho.com/ns/resin">
      <prologue>
        <class-loader>
          <compiling-loader path="WEB-INF/classes"/>
    
          <library-loader path="WEB-INF/lib"/>
        </class-loader>
      </prologue>
    </web-app>
    

    <compiling-loader>

    child of class-loader

    <compiling-loader> automatically compiles Java code into .class files before loading them.

    <compiling-loader> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    argsAdditional arguments to be passed to the Java compiler. Resin 3.0
    batchIf true, multiple changed *.java files will be compiled in a single batch. Resin 3.0.7true
    encodingI18N encoding for the Java compiler. Since Resin 3.0
    pathFilesystem path for the class loader. Since Resin 3.0required
    sourceJava source directory. Since Resin 3.0value of path
    require-sourceIf true, .class files without matching .java files will be deleted. Since Resin 3.0false
    Example: WEB-INF/resin-web.xml <compiling-loader>
    <web-app xmlns="http://caucho.com/ns/resin">
      <prologue>
        <class-loader>
          <compiling-loader path="WEB-INF/classes"
                            source="WEB-INF/src"/>
        </class-loader>
      </prologue>
    </web-app>
    

    <component>

    child of resin, cluster, host, web-app

    <component> configures a component bean template and stores in the WebBeans registry. Injection of a <component> will generally create a new bean instance in constrast to the singleton <bean>. <component> is a primary configuration tag for Resin's IoC capabilities. The bean can also be optionally registered in JNDI.

    Custom configuration of the component is in the <init> section. Field values may use JSP-EL expressions as well as constant strings or even complex sub-beans. More details for configuring singleton beans are in Resin IoC.

    <component> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classApplication class implementing the resource. Since Resin 3.0required
    initIoC configuration for the bean
    jndi-nameJNDI name for the resource. Since Resin 3.0
    nameThe name of the bean, used for @Named injection. Resin 3.1.4.
    scopedependent, request, session, conversational, application, singleton. Resin 3.1.4.dependent
    <component> schema
    r_component = element component {
      r_class?
      & r_binding*
      & r_init?
      & r_jndi-name?
      & r_name?
      & r_scope?
    }
    
    Example: WEB-INF/resin-web.xml component bean
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <component name="test">
        <type>test.MyBean</type>
        <init>
          <greeting>Hello</greeting>
          <server>${serverId}</server>
          <sub-bean>
            <value>${2 + 2}</value>
          </sub-bean>
        </init>
      </component>
    
    </web-app>
    

    <connection-factory>

    child of resin, cluster, host, web-app
    Parallels to JDBC
    JDBC CLASSCONNECTOR CLASS
    ConnectionConnection (driver-defined class)
    DataSourceConnectionFactory (driver-defined class)
    DriverManagedConnectionFactory
    n/aResourceAdapter
    <connection-factory> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classManagedConnectionFactory driver for the resourcerequired or uri
    initIoC configuration for the ManagedConnectionFactory
    local-transaction-optimizationEnables the local transaction optimization during committrue
    max-active-timeConfigures the maximum time allowed for a connectioninfinite
    max-connectionsConfigures the maximum connections available1024
    jndi-nameJNDI name for the ConnectionFactory
    nameThe IoC name for the ConnectionFactory, used for @Named injection. Resin 3.1.4.
    resource-adapterThe driver's ResourceAdapter
    shareableEnables sharing of Connection objects in a transactiontrue
    uriShortcut alias for the ManagedConnectionFactoryrequired or class
    <connection-factory> schema
    r_connection-factory = element connection-factory {
      (r_class | r_uri)
      & r_binding*
      & r_init?
      & r_jndi-name?
      & r_name?
    
      & local-transaction-optimization?
      & max-active-time?
      & max-connections?
      & resource-adapter?
      & shareable?
    }
    

    <database>

    child of resin, cluster, host, web-app

    <database> defines a database (i.e. DataSource) resource.

    The database configuration section has more details on the configuration. A code pattern for using databases is in a DataSource tutorial.

    <database> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    backup-driverConfigures a backup database driver. If Resin can't connect to any of the main drivers, it will use one of the. backups
    close-dangling-connectionsIf an application does not close a Connection by the end of the request, Resin will close it automatically an issue a warning.true
    connectionDefines initialization attributes for new connections, e.g. setting the transaction-isolation.true
    connection-wait-timeWhen max-connections has been reached, how long Resin will wait for a connection to become idle before giving up.10min
    driverConfigures the database driver, giving the driver's class name as well as its JDBC URL and any other configuration.required
    jndi-nameThe JNDI name to register the connection's DataSource under. If the name can be relative to java:comp/env.
    max-active-timeThe maximum time Resin will allow a connection to remain open before forcing a close.6 hours
    max-close-statementsThe maximum number of Statements Resin will hold to automatically close when the Connection closes.256
    max-connectionsThe maximum number of Connections allowed.128
    max-create-connectionsThe maximum number of connection creation allowed at one time.5
    max-idle-countThe maximum number of Connections in the idle pool.1024
    max-idle-timeThe maximum time a connection will spend in the idle pool before closing.30s
    max-overflow-connectionsThe number of extra connection creation if the number of connections exceeds to pool size.0
    max-pool-timeThe total time a connection can be used before it is automatically closed instead of returned to the idle pool.24h
    nameThe IoC name to save the ConnectionFactory as, used with @Named to inject the resource.
    passwordThe JDBC password for the connection.
    pingIf true, Resin will ping the database before returning a connection from the pool (if ping-interval is exceeded).false
    ping-intervalHow often an idle connection should ping the database to ensure it is still valid.1s
    ping-queryA custom query used to ping the database connection.
    ping-tableA table used to ping the database connection.
    prepared-statement-cache-sizeHow many PreparedStatements to save in the prepared statement cache.0
    save-allocation-stack-traceIf true, saves the location of the connection allocation as a stack trace.false
    spyEnables spy logging of database statements. The logging occurs with name="com.caucho.sql" and level="fine".false
    transaction-timeoutSets the transaction timeout.none
    userSets the authentication user.
    wrap-statementsIf true, Resin wraps statements and automatically closes them on connection close.true
    xaEnables automatic enlistment of Connections with any UserTransaction. Disabling <xa> means the connection are independent of transactions, useful for read-only connections.true
    xa-forbid-same-rmWorkaround flag to handle certain database drivers that do not properly implement the XAResource API.false
    <database> schema
    database = element database {
      backup-driver*
      & close-dangling-connections?
      & connection?
      & connection-wait-time?
      & driver+
      & jndi-name?
      & max-active-time?
      & max-close-statements?
      & max-connections?
      & max-create-connections?
      & max-idle-count?
      & max-idle-time?
      & max-overflow-connections?
      & max-pool-time?
      & name?
      & password?
      & ping?
      & ping-interval?
      & ping-query?
      & ping-table?
      & prepared-statement-cache-size?
      & save-allocation-stack-trace?
      & spy?
      & transaction-timeout?
      & user?
      & wrap-statements?
      & xa?
      & xa-forbid-same-rm?
    }
    
    backup-driver = element backup-driver {
      class?
      & url?
      & element * { * }?
    }
    
    connection = element connection {
      catalog?
      & read-only?
      & transaction-isolation?
    }
    
    driver = element driver {
      class?
      & url?
      & element * { * }?
    }
    
    
    Example: WEB-INF/resin-web.xml database
    <web-app xmlns="http://caucho.com/ns/resin">
    
    <database jndi-name='jdbc/test_mysql'>
      <driver class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
        <url>jdbc:mysql://localhost:3306/test</url>
        <user></user>
        <password></password>
      </driver>
    </database>
    
    </web-app>
    

    <database-default>

    child of resin, cluster, host, web-app

    <database-default> defines default database values to be used for any <database> definition, or runtime database creation (see DatabaseManager).

    <database-default> schema
    element database-default {
      r_database-Content
    }
    
    Example: WEB-INF/resin-web.xml idle-time defaults
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <database-default>
        <max-idle-time>10s</max-idle-time>
      </database-default>
    
    </web-app>
    

    <dependency>

    child of resin, cluster, host, web-app

    <dependency> adds dependent files which should force a reload when changed, like web.xml and resin-web.xml.

    <dependency> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    pathFilesystem path to the dependent file. Since Resin 3.0required
    <dependency> schema
    element dependency {
      string
    }
    
    Example: struts dependency
    <web-app xmlns="http://caucho.com/ns/resin">
      <dependency path="WEB-INF/struts-config.xml"/>
      ...
    </web-app>
    

    <dependency-check-interval>

    child of resin, cluster, host, web-app
    default 2s

    <dependency-check-interval> Configures how often the environment context should be checked for changes. The default value is set low for development purposes, deployments should use something larger like 5m or 1h.

    Resin automatically checks each environment for updates, generally class or configuration updates. Because these checks can take a considerable amount of time, deployment servers should use high values like 60s or more while development machines will want low values like 2s.

    The interval defaults to the parent's interval. So the web-app will default to the host's value.

    <dependency-check-interval> schema
    element dependency-check-interval {
      string
    }
    
    Example: deployment dependency-check-interval
    <resin xmlns="http://caucho.com/ns/resin">
      <cluster id="app-tier">
        <dependency-check-interval>1h<dependency-check-interval>
    
        <server id="app-a" .../>
    
        <host id=""/>
          ...
      </cluster>
    </resin>
    

    <ejb-message-bean>

    child of resin, cluster, host, web-app

    <ejb-message-bean> configures a bean as a message listener. The listener can be a simple bean that just implements the javax.jms.MessageListener interface. No other packaging or complications are necessary. Resin will retrieve messages from a configured queue and pass them to the listener as they arrive. The listeners are typically pooled.

    The bean has full access to Resin-IoC capabilities, including dependency injection, transaction attributes, and aspect interception.

    The message bean can plug into custom messaging systems. The application will need to define a ResourceAdapter and an ActivationSpec. More details are available in the Resin Messaging section.

    <ejb-message-bean> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    activation-specConfigures a custom message-listener driver
    classClassname of the listener beanrequired
    destinationQueue or Topic for JMS message receiving
    destination-typejavax.jms.Queue or javax.jms.Topic
    initIoC configuration for the listener bean
    message-consumer-maxThe number of listener instances to create for the pool.5
    <ejb-message-bean> schema
    element ejb-message-bean {
      class
      & init?
      & (activation-spec?
         | (destination?
            & destination-type?
            & destination-name?
            & message-consumer-max?)
        )
    }
    
    Example: JMS listener in WEB-INF/resin-web.xml
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <jms-connection-factory uri="resin:"/>
      <jms-queue name="my_queue" uri="memory:"/>
    
      <ejb-message-bean class="qa.MyListener">
        <destination>${my_queue}</destination>
      </ejb-message-bean>
    
    </web-app>
    
    Example: ActiveMQ in WEB-INF/resin-web.xml
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <resource-adapter uri="activemq:"/>
    
      <ejb-message-bean class="qa.MyListener">
        <activation-spec uri="activemq:">
           <init physical-name="queue.test"/>
        </activation-spec uri="activemq:">
      </ejb-message-bean>
    
    </web-app>
    

    <ejb-server>

    child of resin, cluster, host, web-app

    Configures an EJB server. See Resin EJB for more details.

    <ejb-server> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    auto-compileenables auto-compilation of EJB stubs and skeletonstrue
    create-database-schemaenables JPA auto-creation of missing database tablesfalse
    data-sourcespecifies the default database for JPA
    config-directoryspecifies a directory containing *.ejb configuration files
    ejb-descriptorpath to a *.ejb file to load
    ejb-jarpath to a jar file containing a META-INF/ejb-jar.xml with EJBs
    jndi-prefixprefix for JNDI registration of EJBs
    validate-database-schemaverifies the actual database tables against the JPA definitionstrue
    jms-connection-factoryspecifies the default JMS ConnectionFactory for message beans
    xa-data-sourcespecifies a separate database for transactionsdata-source
    <ejb-server> schema
    element ejb-server {
      auto-compile
      & create-database-schema
      & data-source
      & config-directory
      & ejb-descriptor
      & ejb-jar
      & jndi-prefix
      & validate-database-schema
      & jms-connection-factory
      & xa-data-source
    }
    

    <ejb-stateful-bean>

    child of resin, host-default, host, web-app-default, web-app

    <ejb-stateful-bean> configures an EJB @Stateful bean. The @Stateful bean is a single-threaded component bean suitable for transaction processing. See Resin EJB for more details.

    The stateful-bean is registered in the Resin-IoC/WebBeans context and optionally with JNDI.

    Since @Stateful beans are components, they are created at the request of the application and destroyed by the application. @Stateful beans are never singletons. For singleton-style beans, either use a <bean> or a @Stateless session bean.

    @Stateful beans may optionally implement a SessionSynchronization interface for transaction callbacks.

    <ejb-stateful-bean> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classthe classname of the bean implementationrequired
    initIoC initialization for each bean instance
    jndi-nameA JNDI name to store the bean as.
    nameThe Resin-IoC/WebBeans @Named registrationThe classname
    scopeThe Resin-IoC/WebBeans scope: dependent, request, session, conversaiondependent classname
    <ejb-stateful-bean> schema
    element ejb-stateful-bean {
      class
      & init?
      & jndi-name?
      & name?
      & scope?
    }
    

    <ejb-stateless-bean>

    child of resin, host-default, host, web-app-default, web-app

    <ejb-stateless-bean> configures an EJB @Stateless bean. The @Statelesss bean is a pooled, proxied, singleton component bean suitable. See Resin EJB for more details.

    The stateless-bean is registered in the Resin-IoC/WebBeans context and optionally with JNDI.

    @Stateless beans are similar to <bean> singletons, but pool instances. Each instance executes a single thread at a time, unlike <bean> singletons which are multithreaded like servlets. Both styles can use the same aspect capabilities like dependency injection, transactions, and interceptors. Because @Stateless beans are singletons, they do not have a scope attribute.

    <ejb-stateless-bean> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classthe classname of the bean implementationrequired
    initIoC initialization for each bean instance
    jndi-nameA JNDI name to store the bean as.
    nameThe Resin-IoC/WebBeans @Named registrationThe classname
    <ejb-stateless-bean> schema
    element ejb-stateless-bean {
      class
      & init?
      & jndi-name?
      & name?
    }
    

    <env-entry>

    child of resin, host-default, host, web-app-default, web-app

    <env-entry> configures a JNDI scalar value for JNDI-based application configuration.

    Some application beans prefer to retrieve configuration data from JNDI, including String, Integer, and Double constants. env-entry configures that data in the current context. As with other Resin configuration, the value can use JSP-EL expressions.

    <env-entry> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    env-entry-nameJNDI name to store the value. Since Servlet 2.1required
    env-entry-typeJava type for the value. Since Servlet 2.1required
    env-entry-valueValue to be stored. Since Servlet 2.1required
    <env-entry> schema
    element env-entry {
      description*,
    
      env-entry-name,
    
      env-entry-type,
    
      env-entry-value
    }
    

    The example configuration stores a string in java:comp/env/greeting. Following the J2EE spec, the env-entry-name is relative to java:comp/env. If the env-entry is in the <host> context, it will be visible to all web-apps in the host.

    Example: WEB-INF/resin-web.xml with env-entry
    <web-app xmlns="http://caucho.com/ns/resin">
      <env-entry>
        <env-entry-name>greeting</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>Hello, World</env-entry-value>
      </env-entry>
    
      <servlet ...>
      </servlet>
    </web-app>
    

    The following servlet fragment is a typical use in a servlet. The servlet only looks up the variable once and stores it for later use.

    Example: GreetingServlet.java
    import java.io.*;
    import javax.naming.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    
    public class TestServlet extends HttpServlet {
      private String greeting;
    
      public void init()
        throws ServletException
      {
        try {
          Context env = 
            (Context) new InitialContext().lookup("java:comp/env");
          greeting = (String) env.lookup("greeting");
        } catch (NamingException e) {
          throw new ServletException(e);
        }
      }
    
      ...
    }
    

    <fileset>

    <fileset> provides the ability to match a set of files. It is modelled after the ant tag by the same name. The fileset matches files from a base directory defined by 'dir'. Files can be included by patterns defined by <include> tags or excluded by patterns defined in <exclude> tags.

    <fileset> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    dirthe starting directoryrequired
    includean include patterndo not include all files
    excludean exclude patterndo not exclude any files
    <fileset> schema
    element fileset {
      dir
      & exclude*
      & include*
    

    fileset patterns

    A pattern can contain two special characters: '*' and '**'. '*' matches any part of path, but does not match the path separator. '**' matches any part of a path, including the path separator.

    The following example matches .jar files in WEB-INF/lib. Since it does not search the lib directory recursively, WEB-INF/lib/foo/bar.jar will not match.

    Example: fileset pattern '*'
    <fileset dir="WEB-INF/lib">
      <include name="*.jar"/>
    </fileset>
    
    MATCH    lib/foo.jar
    MATCH    lib/bar.jar
    NO MATCH lib/baz/foo.jar
    

    The following example matches .jar files in WEB-INF/lib recursively, so a deeper file like WEB-INF/lib/foo/bar.jar will match.

    Example: fileset pattern '**'
    <fileset dir="WEB-INF/tree">
      <include name="**/*.jar"/>
    </fileset>
    
    MATCH    lib/foo.jar
    MATCH    lib/bar.jar
    MATCH    lib/baz/foo.jar
    

    <javac>

    child of resin, cluster, host, web-app

    <javac> configures the Java compiler for automatically compiled files.

    The javac configuration is used for JSP, PHP, EJB and compiling-loader configuration.

    <javac> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    argsextra arguments to pass to the compiler
    compilerthe compiler name: eclipse, groovyc, internal, or a command-line
    encodingthe character encoding to useutf-8
    max-batchthe maximum number of source files to batch into one compilation64
    <javac> schema
    element javac {
      args*
      & compiler
      & encoding?
      & max-batch?
    }
    

    The eclipse compiler requires the presence of $RESIN_HOME/lib/eclipse-compiler.jar (which is included with Resin). It is a very fast compiler that was developed as part of the Eclipse project.

    Example: eclipse compiler
    <resin xmlns="http://caucho.com/ns/resin">
    
     <javac compiler="eclipse" args="-source 1.5"/>
    
      ...
    
    </resin>
    

    The internal compiler requires tools.jar from the JDK installation, so a JDK must be used (not a JRE). Sometimes the internal compiler causes errors, creating exceptions or simply hanging and taking up a thread. The solution is to change the compiler to use an external compiler.

    Internal compiler
    <resin xmlns="http://caucho.com/ns/resin">
    
     <javac compiler="internal" args=""/>
    
    </resin>
    

    The javac compiler is included with the JDK. It executes that same as the internal compiler, however it is executed as an external process and is less prone to the problems described for the internal compiler. In resin.xml with the javac configuration option:

    javac JDK compiler
    <resin xmlns="http://caucho.com/ns/resin">
    
     <javac compiler="javac" args=""/>
    
      ...
    
    </resin>
    

    <jms-connection-factory>

    child of resin, cluster, host, web-app

    <jms-connection-factory> configures a JMS ConnectionFactory and registers it with Resin-IoC/WebBeans. The ConnectionFactory can be specified by it's class or a URI alias.

    See Resin messaging for more information.

    jms-connection-factory URIs
    SCHEMEDESCRIPTION
    resin:Resin's ConnectionFactory implementation
    <jms-connection-factory> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classclass name of the ConnectionFactory implementationrequired (or uri)
    initIoC initialization configuration for the factory
    jndi-nameName for registering in JNDI, relative to java:comp/env
    name@Named binding in Resin-IoC
    uriURI alias for the ConnectionFactory class
    <jms-connection-factory> schema
    element jms-connection-factory {
      (class | uri)
      & init?
      & jndi-name?
      & name?
    }
    

    <jms-queue>

    child of resin, cluster, host, web-app

    <jms-queue> configures a JMS Queue and registers it with Resin-IoC/WebBeans. Resin's JMS Queues implement the BlockingQueue interface and can be used directly or with the JMS ConnectionFactory.

    See Resin messaging for more information.

    The Queue can either be identified by the implementing class name or with a URI alias. Third-party queues using JCA will use the <resource-adapter> and either <connection-factory> or <activation-spec>.

    Code sending messages to a Queue will typically use either the BlockingQueue API or JMS. Code receiving from a queue will generally use an EJB message bean.

    <jms-queue> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classclass name of the Queue implementationrequired (or uri)
    initIoC initialization for the Queue
    jndi-nameJNDI name for storing the Queue
    name@Named binding for Resin-IoC
    Queue URI aliases
    URIDESCRIPTION
    file:Persistent, file-backed Queue
    memory:Simple, memory-based Queue
    server:Server side of a clustered Queue
    client:Client side of a clustered Queue
    <jms-queue> schema
    element jms-queue {
      (class | uri)
      & init
      & jndi-name
      & name
    }
    

    <jms-topic>

    child of resin, cluster, host, web-app

    <jms-topic> configures a JMS Topic and registers it with Resin-IoC/WebBeans. Resin's JMS Topics implement the BlockingTopic interface and can be used directly or with the JMS ConnectionFactory.

    See Resin messaging for more information.

    The Topic can either be identified by the implementing class name or with a URI alias. Third-party topics using JCA will use the <resource-adapter> and either <connection-factory> or <activation-spec>.

    Code sending messages to a Topic will typically use either the BlockingTopic API or JMS. Code receiving from a topic will generally use an EJB message bean.

    <jms-topic> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classclass name of the Topic implementationrequired (or uri)
    initIoC initialization for the Topic
    jndi-nameJNDI name for storing the Topic
    name@Named binding for Resin-IoC
    Topic URI aliases
    URIDESCRIPTION
    file:Persistent, file-backed Topic
    memory:Simple, memory-based Topic
    server:Server side of a clustered Topic
    client:Client side of a clustered Topic
    <jms-topic> schema
    element jms-topic {
      (class | uri)
      & init
      & jndi-name
      & name
    }
    

    <jndi-link>

    child of resin, cluster, host, web-app

    <jndi-link> creates a symbolic link from one jndi name to another, or links to a foreign JNDI context.

    Resin's JNDI can link to foreign JNDI contexts. For example, third-party EJB servers will often expose their EJB beans through a JNDI context. jndi-link will create the appropriate InitialContextFactory, configure it, and lookup the foreign JNDI objects.

    <jndi-link> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    factoryClass name of the JNDI InitialContextFactory. Since Resin 1.2optional
    foreign-nameThe target name of the symbolic link, or the sub-context of the foreign JNDI context. Since Resin 1.2none
    init-paramConfiguration parameters for the JNDI environment passed to InitialContextFactory. Since Resin 1.2none
    jndi-nameThe JNDI name to use for the link. Resin 3.0required
    <jndi-link> schema
    element jndi-link {
      jndi-name
      & factory?
      & foreign-name?
      & init-param*
    }
    
    Example: A JNDI symbolic link for a DataSource
    <web-app xmlns="http://caucho.com/ns/resin"dd>
      <database jndi-name="jdbc/oracle">
        ...
      </database>
    
      <jndi-link jndi-name="java:comp/env/jdbc/gryffindor">
        <foreign-name>java:comp/env/jdbc/oracle</foreign-name>
      </jndi-link>
    
      <jndi-link jndi-name="java:comp/env/jdbc/slytherin">
        <foreign-name>java:comp/env/jdbc/oracle</foreign-name>
      </jndi-link>
    </web-app>
    
    Example: A JNDI foreign context for all EJB
    <web-app xmlns="http://caucho.com/ns/resin">
      <jndi-link jndi-name='java:comp/env/ejb'>
        <factory>com.caucho.ejb.hessian.HessianContextFactory</factory>
        <init-param java.naming.provider.url='http://ejb.hogwarts.com:80/hessian'/>
      </jndi-link>
    </web-app>
    
    Example: A JNDI foreign context for selected EJB
    <web-app xmlns="http://caucho.com/ns/resin">
      <jndi-link jndi-name='java:comp/env/remote-ejb'>
        <factory>com.caucho.ejb.hessian.HessianContextFactory</factory>
        <init-param java.naming.provider.url='http://ejb.hogwarts.com:80/hessian'/>
      </jndi-link>
    
      <jndi-link jndi-name="java:comp/env/ejb/Foo">
        <foreign-name>java:comp/env/remote-ejb/Foo</foreign-name>
      </jndi-link>
    
      <jndi-link jndi-name="java:comp/env/ejb/Bar">
        <foreign-name>java:comp/env/local-ejb/Bar</foreign-name>
      </jndi-link>
    </web-app>
    

    <jpa-persistence>

    child of resin, cluster, host, web-app

    <jpa-persistence> configures JPA persistence defaults. More details on JPA are available on the Amber page.

    <jpa-persistence> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    create-database-schemaIf true, Amber will automatically create the database schemafalse
    cache-sizeSize of the entity cache32k
    data-sourcedatabase used for JTA
    jdbc-isolationJDBC isolation level used for connections
    read-data-sourceData source to be used for read-only queriesdata-source
    validate-database-schemaenables validation of the database tables on startupfalse
    xa-data-sourcedatabase to use in transactionsdata-source
    <jpa-persistence> schema
    element jpa-persistence {
      create-database-schema?
      & cache-size?
      & cache-timeout?
      & data-source?
      & jdbc-isolation?
      & persistence-unit*
      & persistence-unit-default*
      & read-data-source?
      & validate-database-schema?
      & xa-data-source?
    }
    
    element persistence-unit {
      name
      & jta-data-source?
      & non-jta-data-source?
      & provider?
      & transaction-type?
      & properties?
    }
    
    element persistence-unit-default {
      & jta-data-source?
      & non-jta-data-source?
      & provider?
      & transaction-type?
      & properties?
    }
    
    element properties {
      element property {
         name
         & value
      }*
    }
    

    <library-loader>

    child of class-loader

    <library-loader> configures a jar library, WEB-INF/lib-style class loader.

    The library-loader will add jar files in its path to the current classpath. Jar files are recognized wihen they have a filename extension of .jar or .zip.

    ATTRIBUTEDESCRIPTIONDEFAULT
    filesetAn ant-style fileset
    pathFilesystem path for the class loader. Since Resin 3.0required
    <library-loader> schema
    element library-loader {
      fileset
      | path
    }
    
    element fileset {
      dir
      & exclude*
      & include*
    }
    

    See DirectoryLoader.

    <log>

    child of resin, cluster, host, web-app

    <log> configures JDK 1.4 java.util.logger handler.

    The log configuration describes log in detail.

    <log> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    archive-formatdefines a format string for log rollover
    formatdefines the output formatting
    formatterdefines a custom formatter
    handlerdefines a custom handler
    levelsets the logging level of the handlerinfo
    mbean-namesets an mbean-name to register the logger for runtime management
    pathsets the VFS path for the log file
    path-formatsets a pattern for creating the VFS path for the messages
    rollover-countsets the maximum number of rollover files
    rollover-periodsets the number of days before a log file rollover 1m
    rollover-sizesets the maximum log size before a rollover1g
    timestampsets the formatting string for the timestamp label
    use-parent-handlersif true, the log is also copied to parent handlerstrue
    <log> schema
    element log {
      archive-format?
      & format?
      & formatter?
      & handler?
      & level?
      & mbean-name?
      & name
      & path?
      & path-format?
      & rollover-count?
      & rollover-period?
      & rollover-size?
      & timestamp?
      & use-parent-handlers?
    }
    

    <logger>

    child of resin, cluster, host, web-app

    <log> configures JDK 1.4 java.util.logger Logger level.

    The log configuration describes log in detail.

    <logger> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    levelthe java.util.logging level: finest, finer, fine, config, info, warning, severeinfo
    namethe java.util.logging name, typically a classnamerequired
    use-parent-handlersif true, parent handlers are also invokedtrue
    <logger> schema
    element logger {
      name
      & level?
      & use-parent-handlers?
    }
    
    Example: compilation logging
    <resin xmlns="http://caucho.com/ns/resin">
      <log name="" level="all" path="log/debug.log"/>
      <logger name="com.caucho.java" level="fine"/>
    
      <cluster id="app-tier">
        ...
      </cluster>
    </resin>
    

    <mail>

    child of resin, cluster, host, web-app

    <mail> configures a javax.mail.Session object and makes it available in Resin-IoC/WebBeans. Mail properties can be configured using the properties attribute. Some of the most common properties can be configured directly on the <mail> tag.

    <mail> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    authenticatorsets a custom javamail authenticator, either with EL or a custom resin:type bean
    debugsets the mail.debug flag
    fromsets the mail.from property
    hostsets the mail.host property
    imap-hostsets the mail.imap.host property
    imap-portsets the mail.imap.port property
    imap-usersets the mail.imap.user property
    initIoC configuration for other properties
    jndi-nameJNDI name to store the mail Session
    nameResin-IoC/WebBeans @Named value
    passwordsets the password for authentication
    pop3-hostsets the mail.pop3.host property
    pop3-portsets the mail.pop3.port property
    pop3-usersets the mail.pop3.user property
    propertiesgeneral mail properties in property file format
    smtp-hostsets the mail.smtp.host property
    smtp-portsets the mail.smtp.port property
    smtp-usersets the mail.smtp.user property
    store-protocolsets the mail.store.protocol property
    transport-protocolsets the mail.transport.protocol property
    usersets the mail.user property
    <mail> schema
    element mail {
      authenticator?
      & debug?
      & from?
      & host?
      & imap-host?
      & imap-port?
      & imap-user?
      & init?
      & jndi-name?
      & name?
      & pop3-host?
      & pop3-port?
      & pop3-user?
      & smtp-host?
      & smtp-port?
      & smtp-user?
      & store-protocol?
      & transport-protocol?
      & user?
    }
    
    Example: mail
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <mail jndi-name="java:comp/env/mail">
        <from>noreply@foo.com</from>
        <smtp-host>localhost</smtp-host>
        <smtp-port>25</smtp-port>
    
        <properties>
          mail.smtp.starttls.enable=true
        </properties>
      </mail>
    </web-app>
    

    <reference>

    child of resin, cluster, host, web-app

    <reference> configures a JNDI ObjectFactory. Some legacy resources are configured using an ObjectFactory syntax. The <reference> tag provides a compatible way to configure those objects. More modern resources should use <bean> or <component> for IoC configuration.

    JNDI ObjectFactories are used to create objects from JNDI references. The <reference> tag configures the ObjectFactory and stores it in JNDI.

    <reference> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    jndi-nameJNDI name for the reference. Since Resin 3.0required
    factoryClass name of the ObjectFactory. Resin 3.0required
    initBean-style initialization for the factorynone
    <reference> schema
    element reference {
      factory 
      & jndi-name
      & init-param*
    }
    
    Example: Hessian client reference
    <web-app xmlns="http://caucho.com/ns/resin">
    
    <reference>
      <jndi-name>hessian/hello</jndi-name>
      <factory>com.caucho.hessian.client.HessianProxyFactory</factory>
      <init url="http://localhost:8080/ejb/hello"/>
            type="test.HelloHome"/>
    </reference>
    
    </web-app>
    

    <remote-client>

    child of cluster, host, web-app

    <remote-client> configures a proxy to a web-service. It uses a Java interface and a URI to select the web-service.

    The URI is defined as: protocol:url=location, where location is typically a HTTP URL.

    <remote-client> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classClass name of the protocol implementationrequired (or uri)
    initIoC initialization for the protocol implementation
    name@Named binding for Resin-IoC
    jndi-nameJNDI binding name
    uriShortcut alias name for the protocol class
    remote-client protocols
    URIDescription
    cxf:url=http://foo.com/hello/cxfDefines a cxf service. See http://wiki.caucho.com/CXF for more information.
    burlap:url=http://foo.com/hello/burlapDefines a burlap service at http://foo.com/hello/burlap
    hessian:url=http://foo.com/hello/hessianDefines a hessian service at http://foo.com/hello/hessian
    xfire:url=http://foo.com/hello/cxfDefines a xfire client. See http://wiki.caucho.com/XFire for more information.
    remote-client
    element remote-client {
      (class|uri)
      & name?
      & jndi-name?
      & interface
    }
    

    <resin:choose>

    resin:choose implements an if, elsif, else.

    <resin:choose> Attributes
    ATTRIBUTEDESCRIPTION
    resin:whenA configuration section executed when matching a test condition
    resin:otherwiseA fallback section executed when the tests fail

    The <resin:choose> schema is context-dependent. A <resin:choose> in a <web-app> will have <web-app> content, while a <resin:choose> in a <host> will have <host> content.

    <resin:choose> schema
    element resin:choose {
      resin:when*,
      resin:otherwise
    }
    
    element resin:when {
      attribute test { string },
    
      context-dependent content
    }
    
    element resin:otherwise {
      context-dependent content
    }
    
    Example: resin:choose usage pattern
    <resin:choose>
      <resin:when test="${expr1}">
        ...
      </resin:when>
    
      <resin:when test="${expr2}">
        ...
      </resin:when>
    
      <resin:otherwise>
        ...
      </resin:otherwise>
    <resin:choose>
    

    <resin:when>

    child of resin:choose

    <resin:when> conditionally configures a block within a <resin:choose> block. If the test matches, Resin will use the enclosed configuration.

    <resin:when> Attributes
    ATTRIBUTEDESCRIPTION
    testthe test to perform
    <resin:when> schema
    element resin:when {
      attribute test { string },
    
      context-dependent content
    }
    

    <resin:otherwise>

    child of resin:choose

    <resin:otherwise> is the catch-all configuration for a <resin:choose> block when none of the <resin:when> items match.

    <resin:otherwise> schema
    element resin:otherwise {
      context-dependent content
    }
    

    <resin:if>

    resin:if executes part of the configuration file conditionally. resin:if can be particularly useful in combination with Java command-line properties like -Dfoo=bar to enable development mode or testing configuration.

    <resin:if> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    testthe test to performrequired

    The resin:if schema is context-dependent. For example, resin:if in a <web-app> will have web-app content while resin:if in a <host> will have host content.

    <resin:if> schema
    element resin:if {
      attribute test { string }
    
      context-dependent content
    }
    
    Example: enable debugging for -Ddevelopment
    <resin xmlns="http://caucho.com/ns/resin"
            xmlns:core="http://caucho.com/ns/resin/core">
    
      <resin:if test="${system['development']}">
        <logger name="com.foo" level="finer"/>
      </resin:if>
    
      ...
    </resin>
    

    <resin:import>

    <resin:import> reads configuration from another file or set of files. For example, the WEB-INF/web.xml and WEB-INF/resin-web.xml files are implemented as <resin:import> in the app-default.xml.

    The target file is validated by the schema of the including context. So a resin:import in <web-app-default> will have a target with a top-level of <web-app>, and a resin:import in <cluster> will have a top-level tag of <cluster>.

    <resin:import> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    patha path to a fileeither path or fileset is required
    fileseta fileset describing all the files to import.either path or fileset is required
    optionalif true, no error when file does not existfalse
    <resin:import> schema
    element import {
      (path | fileset)
      & optional?
    }
    
    element fileset {
      dir
      & exclude*
      & include*
    }
    

    The following example shows how Resin implements the WEB-INF/web.xml and WEB-INF/resin-web.xml files. Both are simply resin:import in a web-app-default. When Resin configures the web-app, it will process the web-app-default program, and call resin:import for the web.xml file.

    Example: import implementation of WEB-INF/web.xml
    <resin xmlns="http://caucho.com/ns/resin"
           xmlns:resin="http://caucho.com/ns/resin/core">
      <cluster id="app-tier">
    
        <web-app-default>
          <resin:import path="WEB-INF/web.xml" optional="true"/>
          <resin:import path="WEB-INF/resin-web.xml" optional="true"/>
        </web-app-default>
    
      </cluster>
    </resin>
    

    Virtual hosts can use resin:import to add a custom host.xml file. The host.xml can use any <host> attribute, including <host-name> and <host-alias> to customize the virtual host configuration.

    Example: adding host.xml in host-deploy
    <resin xmlns="http://caucho.com/ns/resin"
           xmlns:resin="http://caucho.com/ns/resin/core">
      <cluster id="app-tier">
    
        <host-deploy path="/var/www/hosts">
          <host-default>
            <resin:import path="host.xml" optional="true"/>
    
            <web-app-deploy path="webapps"/>
          </host-default>
        </web-app-default>
    
      </cluster>
    </resin>
    

    Some applications may want to split their configuration into multiple files using the fileset. For example, a Resin-IoC application might want to define beans in WEB-INF/beans/*.xml and give the web-app flexibility in which bean files to create.

    Example: Bean IoC fileset in resin-web.xml
    <web-app xmlns="http://caucho.com/ns/resin"
              xmlns:core="http://caucho.com/ns/resin/core">
    
      <resin:import>
        <fileset dir="WEB-INF/beans">
          <include>*.xml</include>
        </fileset>
      </resin:import>
    
    </web-app>
    

    <resin:message>

    Logs a message to the given log file. The content of the element is the message.

    <resin:message> schema
    element resin:message {
      string
    }
    
    logging in resin-web.xml
    <web-app xmlns="http://caucho.com/ns/resin"
             xmlns:resin="http://caucho.com/ns/resin/core">
    
      <resin:message>Starting server ${server.name}</resin:message>
    
    </web-app>
    

    <resin:set>

    resin:set adds an EL variable to the current context.

    <resin:set> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    varname of the variable to setrequired
    valuevaluerequired
    <resin:set> schema
    element set {
      name
      & value
      & default
      & attribute * { string }
    }
    
    Example: resin:set in resin.xml
    <resin xmlns="http://caucho.com/ns/resin"
              xmlns:resin="http://caucho.com/ns/resin/core">
      <resin:set name="root" value="/var/www"/>
    
      <cluster id="app-tier">
        <root-directory>${root}</root-directory>
    
        ...
      </cluster>
    </resin>
    

    <resource>

    child of resin, cluster, host, web-app

    <resource> is an obsolete synonym for <bean> to define custom singletons. Applications should use the <bean> syntax instead.

    <resource-adapter>

    child of resin, cluster, host, web-app

    <resource-adapter> configures a JCA ResourceAdapter in combination with <connection-factory> for connections or <activation-spec for message listeners. See Resin messaging for typical uses.

    ResourceAdapters can be deployed in .rar files, but this is not required by Resin. Instead, you can configure the ResourceAdapter directly.

    A symbolic URI can be used in place of the ResourceAdapter's class name.

    <resource-adapter> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    classThe classname of the ResourceAdapter implementation classrequired (or uri)
    initIoC initialization for the ResourceAdapter
    jndi-nameJNDI name for binding the ResourceAdapter
    name@Named binding for Resin-IoC injection.
    uriAlias schema for the ResourceAdapter class name
    <resource-adapter> schema
    element resource-adapter {
      (class | uri)
      & init?
      & name?
      & jndi-name?
    }
    

    <resource-deploy>

    child of resin, cluster, host-default, host, web-app-default, web-app

    <resource-deploy> defines a deployment directory for .rar files.

    Connectors and resources defined in .rar files must be deployed before they can be configured by connector. The <resource-deploy> tag specifies the directory for that deployment.

    <resource-deploy> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    resource-deployConfigures .rar deploymentrequired
    pathConfigures the path where users will place .rar filesrequired
    expand-pathConfigures the directory where Resin will expand rar filesthe path value
    <resource-deploy> schema
    element resource-deploy {
      path
      & expand-directory?
      & expand-path?
      & resource-default?
    }
    
    Example: resource-deploy
    <resin xmlns="http://caucho.com/ns/resin">
      <cluster id="app-tier">
    
        <host id="">
          <resource-deploy path="deploy"/>
        </host>
      </cluster>
    </resin>
    

    <resource-ref>

    child of resin, cluster, host, web-app

    <resource-ref> declares that the application needs a resouce configuration.

    resource-ref is not directly used by Resin. It's a servlet configuration item intended to tell GUI tools which resources need configuration. Resource configuration in Resin uses the resource, reference, database, and ejb-server tags.

    For backwards compatibility, Resin 2.1-style configuration files may still use resource-ref to configure resources, but it's recommended to convert the configuration.

    <resource-ref> schema
    element resource-ref {
      attribute id?,
      description*,
      res-ref-name,
      ref-type,
      res-auth,
      res-sharing-scope?
    }
    

    <scheduled-task>

    <scheduled-task> schedules a job to be executed at specific times or after specific delays. The times can be specified by a cron syntax or by a simple delay parameter. The job can be either a Runnable bean, a method specified by an EL expression, or a URL.

    When specified as an IoC bean, the bean task has full IoC capabilities, including injection, @TransactionAttribute aspects, interception and @Observes.

    <scheduled-task> Attributes
    ATTRIBUTEDESCRIPTION
    classthe classname of the singleton bean to create
    crona cron-style scheduling description
    delaya simple delay-based execution
    initIoC initialization for the bean
    mbean-nameoptional MBean name for JMX registration
    methodEL expression for a method to be invoked as the task
    nameoptional IoC name for registering the task
    periodhow often the task should be invoked in simple mode
    taskalternate task assignment for predefined beans
    <scheduled-task> schema
    element scheduled-task {
      class?
      & cron?
      & delay?
      & init?
      & mbean-name?
      & method?
      & name?
      & period?
      & task?
    }
    

    bean-style job configuration

    The most common and flexible job configuration uses standard IoC bean-style configuration. The bean must implement Runnable. Like the <bean> tag, the class attribute specifies the Runnable class, and any init section configures the bean using Resin IoC configuration.

    Example: 5min cron bean task
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <scheduled-task class="qa.MyTask">
        <cron>*/5</cron>
      </scheduled-task>
    
    </web-app>
    

    task reference job configuration

    The task bean can also be passed to the <scheduled-task> using a Resin-IoC EL reference. The name of the task bean would be defined previously, either in a <bean> or <component> or picked up by classpath scanning. Like the bean-style job configuration, the reference bean must implement Runnable.

    Example: midnight cron bean task
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <scheduled-task task="#{taskBean}">
        <cron>0 0 *</cron>
      </scheduled-task>
    
    </web-app>
    

    method reference job configuration

    <scheduled-task> can execute a method on a defined bean as the scheduler's task. The method is specified using EL reference syntax. At each trigger time, <scheduled-task> will invoke the EL method expression.

    In the following example, the task invokes myMethod() on the myBean singleton every 1 hour.

    Example: 1h period method task
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <bean name="myBean" class="qa.MyBean"/>
    
      <scheduled-task method="#{myBean.myMethod}">
        <delay>10m</delay>
        <period>1h</period>
      </scheduled-task>
    
    </web-app>
    

    url job configuration

    In a <web-app>, the <scheduled-task> can invoke a servlet URL at the trigger times. The task uses the servlet RequestDispatcher and forwards to the specified URL. The URL is relative to the <web-app> which contains the <scheduled-task.

    Example: sunday cron url task
    <web-app xmlns="http://caucho.com/ns/resin">
    
      <scheduled-task url="/cron.php">
        <cron>0 15 * * 0</cron>
      </scheduled-task>
    
    </web-app>
    

    <servlet-hack>

    child of class-loader

    Use of servlet-hack is discouraged. Using servlet-hack violates the JDK's classloader delegation model and can produce surprising ClassCastExceptions.

    servlet-hack reverses the normal class loader order. Instead of parent classloaders having priority, child classloaders have priority.

    <servlet-hack> schema
    element servlet-hack {
      boolean
    }
    

    <simple-loader>

    child of class-loader

    <simple-loader> Configures a simple WEB-INF/classes-style class loader.

    .class files in the specified directory will be loaded without any special compilation steps (in contrast with compiling-loader.)

    <simple-loader> attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    pathFilesystem path for the class loader. Since Resin 3.0required
    prefixClass package prefix to only load to a subset of classes. Resin 3.0none
    <simple-loader> schema
    element simple-loader {
      path
      & prefix?
    }
    

    <stderr-log>

    child of resin, cluster, host-default, host, web-app-default, web-app

    Configures the destination for System.err.

    The log configuration describes stderr-log in detail.

    <stderr-log> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    archive-formatdefines a format string for log rollover
    pathsets the VFS path for the log file
    path-formatsets a pattern for creating the VFS path for the messages
    rollover-countsets the maximum number of rollover files
    rollover-periodsets the number of days before a log file rollover 1m
    rollover-sizesets the maximum log size before a rollover1g
    timestampsets the formatting string for the timestamp label
    <stderr-log> schema
    element stderr-log {
      (path | path-format)
      & archive-format?
      & rollover-period?
      & rollover-size?
      & rollover-count?
      & timestamp?
    }
    

    <stdout-log>

    child of resin, cluster, host-default, host, web-app-default, web-app

    Configures the destination for System.out.

    The log configuration describes stderr-log in detail.

    <stdout-log> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    archive-formatdefines a format string for log rollover
    pathsets the VFS path for the log file
    path-formatsets a pattern for creating the VFS path for the messages
    rollover-countsets the maximum number of rollover files
    rollover-periodsets the number of days before a log file rollover 1m
    rollover-sizesets the maximum log size before a rollover1g
    timestampsets the formatting string for the timestamp label
    <stdout-log> schema
    element stdout-log {
      (path | path-format)
      & archive-format?
      & rollover-period?
      & rollover-size?
      & rollover-count?
      & timestamp?
    }
    

    <system-property>

    child of resin, cluster, host, web-app

    Sets a Java system property. The effect is the same as if you had called java.lang.System before starting Resin.

    <system-property> schema
    element system-property {
      attribute * { string }+
    }
    
    Example: setting system property
    <resin xmlns="http://caucho.com/ns/resin">
      <system-property foo="bar"/>
    </resin>
    

    <temp-dir>

    child of resin, cluster, host-default, host, web-app-default, web-app
    default Defaults to WEB-INF/tmp

    <temp-dir> configures the application temp directory. This is the path used in javax.servlet.context.tempdir.

    <temp-dir> schema
    element temp-dir {
      string
    }
    

    <tree-loader>

    child of class-loader

    <tree-loader> configures a jar library, WEB-INF/lib-style class loader similar to library-loader, but will also find .jar and .zip files in subdirectories.

    <tree-loader> Attributes
    ATTRIBUTEDESCRIPTIONDEFAULT
    pathFilesystem path for the class loader. Since Resin 3.0required
    <tree-loader> schema
    element tree-loader {
      path
    }
    

    <work-dir>

    child of resin, config, host, web-app
    default Defaults to WEB-INF/work

    <work-dir> configures a work directory for automatically generated code, e.g. for JSP, PHP, and JPA classes.

    <work-dir> schema
    element work-dir {
      string
    }
    

    Copyright © 1998-2010 Caucho Technology, Inc. All rights reserved.
    Resin ® is a registered trademark, and Quercustm, Ambertm, and Hessiantm are trademarks of Caucho Technology.