Minimal JBoss 5.1.0 GA Configuration with Tomcat
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.
- Change directory to
$JBOSS_HOME/server. Make a copy of theminimalconfiguration.cp -R minimal tomcatonly
- Copy
bindingservice.beansfrom thedefaultconfiguration.cp -R default/conf/bindingservice.beans tomcatonly/conf/
- Copy
login-config.xmlfrom thedefaultconfiguration.cp default/conf/login-config.xml tomcatonly/conf/
- 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 thedefaultprofile, 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>
- Copy the Tomcat (JBoss web) deployer from the
defaultconfiguration.cp -R default/deployers/jbossweb.deployer tomcatonly/deployers/
- Copy
metadata-deployer-jboss-beans.xmlandsecurity-deployer-jboss-beans.xmlfrom the default profile.cp default/deployers/metadata-deployer-jboss-beans.xml tomcatonly/deployers/ cp default/deployers/security-deployer-jboss-beans.xml tomcatonly/deployers/
- Copy the Tomcat (JBoss web) service archive from the
defaultconfiguration.cp -R default/deploy/jbossweb.sar tomcatonly/deploy/
- Copy JBoss security beans from the
defaultconfiguration:cp -R default/deploy/security tomcatonly/deploy/
- Edit
tomcatonly/deploy/jbossweb.sar/server.xmland comment outCachedConnectionValve:<!-- <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve" cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager" transactionManagerObjectName="jboss:service=TransactionManager" /> -->
- Edit
tomcatonly/deploy/jbossweb.sar/META-INF/jboss-beans.xml, removeCachedConnectionManagerandTransactionManager. Remove all the*MObeans (fromWebServerMOtill the end).
Add a bean definition forPersistenceUnitDependencyResolver:<bean name="PersistenceUnitDependencyResolver" class="org.jboss.web.tomcat.service.deployers.DummyPersistenceUnitDependencyResolver"> </bean>
This is needed because JBossWarDeployerwill be looking for this bean by auto-wiring. And you can't simply define a null bean, which would causeNullPointerExceptiondown the road. None of the stockPersistenceUnitDependencyResolvers 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 ofjboss-beans.xmlshould 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>
- Grab
DummyPersistenceUnitDependencyResolverfrom JBoss 6, and stuff it intomcatonly/deployers/jbossweb.deployer/jboss-web-deployer.jar(hack! hack!). - Start new configuration with:
bin/run.sh -c tomcatonly