Minimal JBoss 5.1.0 GA Configuration with Tomcat 

Joined:
03/21/2010
Posts:
49

December 31, 2010 11:56:25    Last update: December 31, 2010 11:56:25
These are the steps to create a JBoss 5.1.0 configuration with Tomcat from the built-in minimal configuration.
  1. Change directory to $JBOSS_HOME/server. Make a copy of the minimal configuration.
    cp -R minimal tomcatonly
    

  2. Copy bindingservice.beans from the default configuration.
    cp -R default/conf/bindingservice.beans tomcatonly/conf/
    

  3. Copy login-config.xml from the default configuration.
    cp default/conf/login-config.xml tomcatonly/conf/
    

  4. Edit tomcatonly/conf/jboss-service.xml:
    Add jars from the common/lib directory:
    <!-- Load all jars from the JBOSS_DIST/server/<config>/lib directory. This
            can be restricted to specific jars by specifying them in the archives
            attribute.
        -->
       <classpath codebase="${jboss.server.lib.url}" archives="*"/>
       <classpath codebase="${jboss.common.lib.url}" archives="*"/>
    


    Add the JAAS security manager section (copy from the default profile, and yes, JBoss tomcat can't live without the JBoss JAAS manager).
    <!-- JAAS security manager and realm mapping -->
       <mbean code="org.jboss.security.plugins.JaasSecurityManagerService"
          name="jboss.security:service=JaasSecurityManager">
          <!-- A flag which indicates whether the SecurityAssociation server mode
          is set on service creation. This is true by default since the
          SecurityAssociation should be thread local for multi-threaded server
          operation.
          -->
          <attribute name="ServerMode">true</attribute>
          <attribute name="SecurityManagerClassName">org.jboss.security.plugins.JaasSecurityManager</attribute>
          <attribute name="DefaultUnauthenticatedPrincipal">anonymous</attribute>
          <!-- DefaultCacheTimeout: Specifies the default timed cache policy timeout
          in seconds.
          If you want to disable caching of security credentials, set this to 0 to
          force authentication to occur every time. This has no affect if the
          AuthenticationCacheJndiName has been changed from the default value.
          -->
           <attribute name="DefaultCacheTimeout">1800</attribute>
          <!-- DefaultCacheResolution: Specifies the default timed cache policy
          resolution in seconds. This controls the interval at which the cache
          current timestamp is updated and should be less than the DefaultCacheTimeout
          in order for the timeout to be meaningful. This has no affect if the
          AuthenticationCacheJndiName has been changed from the default value.
          -->
          <attribute name="DefaultCacheResolution">60</attribute>
          <!-- DeepCopySubjectMode: This set the copy mode of subjects done by the
          security managers to be deep copies that makes copies of the subject
          principals and credentials if they are cloneable. It should be set to
          true if subject include mutable content that can be corrupted when
          multiple threads have the same identity and cache flushes/logout clearing
          the subject in one thread results in subject references affecting other
          threads.
          -->
          <attribute name="DeepCopySubjectMode">false</attribute>
       </mbean>
    

  5. Copy the Tomcat (JBoss web) deployer from the default configuration.
    cp -R default/deployers/jbossweb.deployer tomcatonly/deployers/
    

  6. Copy metadata-deployer-jboss-beans.xml and security-deployer-jboss-beans.xml from the default profile.
    cp default/deployers/metadata-deployer-jboss-beans.xml tomcatonly/deployers/
    cp default/deployers/security-deployer-jboss-beans.xml tomcatonly/deployers/
    

  7. Copy the Tomcat (JBoss web) service archive from the default configuration.
    cp -R default/deploy/jbossweb.sar tomcatonly/deploy/
    

  8. Copy JBoss security beans from the default configuration:
    cp -R default/deploy/security tomcatonly/deploy/
    

  9. Edit tomcatonly/deploy/jbossweb.sar/server.xml and comment out CachedConnectionValve:
    <!--
        <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"
            cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
            transactionManagerObjectName="jboss:service=TransactionManager" />
    -->
    

  10. Edit tomcatonly/deploy/jbossweb.sar/META-INF/jboss-beans.xml, remove CachedConnectionManager and TransactionManager. Remove all the *MO beans (from WebServerMO till the end).

    Add a bean definition for PersistenceUnitDependencyResolver:
    <bean name="PersistenceUnitDependencyResolver"
          class="org.jboss.web.tomcat.service.deployers.DummyPersistenceUnitDependencyResolver">
    </bean>
    

    This is needed because JBoss WarDeployer will be looking for this bean by auto-wiring. And you can't simply define a null bean, which would cause NullPointerException down the road. None of the stock PersistenceUnitDependencyResolvers work because they will introduce more dependencies. Therefore, the only sensible solution is a dummy resolver, which does not exist in JBoss 5.1.0, you need to get it from the JBoss 6 distribution (or create your own!).

    The final contents of jboss-beans.xml should look like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <deployment xmlns="urn:jboss:bean-deployer:2.0">
       <bean name="WebServer"
             class="org.jboss.web.tomcat.service.deployers.TomcatService">
             
          <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.web:service=WebServer", exposedInterface=org.jboss.web.tomcat.service.deployers.TomcatServiceMBean.class,registerDirectly=true)</annotation>
    
          <!-- Inject the TomcatDeployer -->
          <property name="tomcatDeployer"><inject bean="WarDeployer"/></property>
    
          <!-- Set the securityManagerService used to flush the auth cache on session expiration -->
          <property name="securityManagerService">
             <inject bean="jboss.security:service=JaasSecurityManager" />
          </property>
    
       </bean>
    
       <bean name="PersistenceUnitDependencyResolver"
             class="org.jboss.web.tomcat.service.deployers.DummyPersistenceUnitDependencyResolver">
       </bean>
    </deployment>
    

  11. Grab DummyPersistenceUnitDependencyResolver from JBoss 6, and stuff it in tomcatonly/deployers/jbossweb.deployer/jboss-web-deployer.jar (hack! hack!).
  12. Start new configuration with:
    bin/run.sh -c tomcatonly
    

Share |
| Comment  | Tags