Java7
JBoss AS
JBoss AS Redeployment giving java.lang.OutOfMemoryError: PermGen space
Apr 1st
I have been using Jboss As 6 a lot lately and it seems that with the new edition of application server from JBoss, it quite often runs into PermGen space issue. To rectify the problem each time, i had to bring down the development server only to bring it up again. It becomes quite haphazard and tedious especially with a slower machine.
A search on Google found some great articles, but the comments left behind by this particular user nailed it (Raghav http://blog.yannis-lionis.gr/?p=8). There were even some silly suggestions like switching to JRockit. Well ignore those.
PermGen space out of memory error when redeploying a JSF 2.0 web application through Maven Cargo plugin
To minimize this, one has to effectively “optimize” the JVM settings which JBoss runs on.
Step 1: Locate and open up run.conf
run.conf is usually found in the bin folder of your application server.
Location of my run.conf file
It is recommended that you modify the settings of the JVM through this file, and not through the .bat itself unless you have specific requirements.
Sample run.conf file
Step 2: Locate and change out the settings below the line that says “rem # JVM memory allocation pool parameters”
Original content
rem # JVM memory allocation pool parameters
set ...(deleted for simplicity)
Change it to:
rem # JVM memory allocation pool parameters
set "JAVA_OPTS=-Xms680m -Xmx680m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled"
Complete!
You now need only to restart your server to see the effects.
bash-3.2$ Calling C:\c\server\jbossas-vms\jboss-6.0.0.Final\bin\run.conf.bat
===============================================================================
JBoss Bootstrap Environment
JBOSS_HOME: C:\c\server\jbossas-vms\jboss-6.0.0.Final
JAVA: C:\Program Files\Java\jdk1.6.0_22\bin\java
JAVA_OPTS: -Dprogram.name=run.bat -Xms680m -Xmx680m -XX:PermSize=245m -XX:MaxPermSize=1024m -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.jboss.resolver.warning=true -server
CLASSPATH: C:\Program Files\Java\jdk1.6.0_22\lib\tools.jar;C:\c\server\jbossas-vms\jboss-6.0.0.Final\bin\run.jar
===============================================================================
Notice that JBoss AS echoes my new settings on start up.
Side Note
My PM (@Work) notes and shares that, in Microsoft Windows 32 bit environment, you would not be able to set a value higher than 1024 for your JVM in most cases. Look at this forum thread for some discussion on it http://www.minecraftforum.net/viewtopic.php?f=10&t=167193. Can someone elaborate some on this please? =p
Reference
Managing deployment to JBoss Application Server using Maven through Cargo plugin
Mar 19th
Application Server: JBoss Application Server 6.0.0 Final http://sourceforge.net/projects/jboss/files/JBoss/JBoss-6.0.0.Final/
Sometime ago, i attempted to deploy a JSF 2.0 web application to the newly released GlassFish Application Server 3.1 through the Maven-Cargo plugin. http://java.sg/managing-deployments-to-application-servers-using-maven-through-cargo-plugin/
Cargo is a truly portable plugin that allows you to deploy to most application server vendors and version.
This code snippet shows the same with JBoss Application Server 6.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sg.java</groupId>
<artifactId>web.vms</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Virtualization Management Console</name>
<url>java.sg</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${faces.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>${facelets.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primeFaces.version}</version>
</dependency>
<dependency>
<!-- For primefaces theme http://www.primefaces.org/themes.html -->
<groupId>org.primefaces.themes</groupId>
<artifactId>blitzer</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-core-tools-jboss-deployer-5.1-and-onwards</artifactId>
<version>${cargo.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
<version>5.1.0.GA</version>
</dependency>
</dependencies>
<build>
<finalName>vms</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<!-- JBoss 6 AS Community -->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>${cargo.version}</version>
<configuration>
<container>
<containerId>jboss6x</containerId>
<home>${jbossas.home}</home>
</container>
<configuration>
<type>standalone</type>
<home>${jbossas.server}</home>
</configuration>
<deployer>
<type>installed</type>
<deployables>
<deployable>
<groupId>sg.java</groupId>
<artifactId>web.vms</artifactId>
<type>war</type>
<properties>
<context>/vms</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>java.net</id>
<name>java.net</name>
<url>http://download.java.net/maven/2</url>
</repository>
<repository>
<id>prime-repo</id>
<name>Prime Technology Maven Repository</name>
<url>http://repository.prime.com.tr</url>
<layout>default</layout>
</repository>
<!-- http://community.jboss.org/wiki/MavenGettingStarted-Developers -->
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>codehaus-snapshots</id>
<url>http://ci.repository.codehaus.org/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>codehaus snapshot repository</id>
<url>http://snapshots.repository.codehaus.org/</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<properties>
<junit.version>4.8.2</junit.version>
<primeFaces.version>2.2.1</primeFaces.version>
<faces.version>2.0.3</faces.version>
<javaee.version>1.0.0.Final</javaee.version>
<facelets.version>1.1.15.B1</facelets.version>
<cargo.version>1.0.6</cargo.version>
<jbossas.home>C:\c\server\jbossas-vms\jboss-6.0.0.Final</jbossas.home>
<jbossas.server>${jbossas.home}\server\default</jbossas.server>
</properties>
</project>
To deploy, simply issue the following command in the same directory as where your pom.xml descriptor is sitting.
$ mvn cargo:deploy
You should see output similar to this:
bash-3.2$ mvn cargo:redeploy
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Virtualization Management Console 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- cargo-maven2-plugin:1.0.6:redeploy (default-cli) @ web.vms ---
[INFO] [talledLocalContainer] Parsed JBoss version = [6.0.0]
[INFO] [stalledLocalDeployer] Undeploying [C:\c\server\jbossas-vms\jboss-6.0.0.Final\server\default/deploy/vms.war]...
[INFO] [stalledLocalDeployer] Deploying [C:\c\development projects\project ejb3.1\ide_workspace\ejb3.1_eclipse_workspace\web.vms\target\vms.war] to [C:\c\server\jbossas-vms\jboss-6.0.0.Final\server\default/deploy]...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.929s
[INFO] Finished at: Sat Mar 19 15:29:44 SGT 2011
[INFO] Final Memory: 6M/150M
[INFO] ------------------------------------------------------------------------
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
Mar 5th
This is caused when you deploy a JSF 2.0 web application into a container / server that does not come with the required JSF implementation.
Recall that JSF is a specification (api) which requires the “how” (impl).
It is very likely that you have deployed your application that does not pack a JSF implementation in the package lib into an application server or servlet container that too does not come with the required file.
In this case, you have two options for a solution, 1 – putting the required JSF 2.0 implementation jar file (usually jsf-impl-2.0.jar) into the lib of your project package, or 2 – putting the required JSF 2.0 implementation jar file into the application server / servlet container’s lib folder. The former is a better choice.
Depending on whether you are using the Sun’s Reference Implementation – Sun Mojarra or Apache’s implementation – Apache MyFaces, you generally have these two choices to pick from.
Download Links
Apache MyFaces JSF 2.0 Implementation http://myfaces.apache.org/download.html
Sun Mojarra http://javaserverfaces.java.net/download.html
Maven POM Settings (if you use Maven for dependency management)
Sun Mojarra
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.0-b11</version>
</dependency>
Application Startup Failure Stack Trace
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory
at javax.faces.FactoryFinder$FactoryManager.getFactory(FactoryFinder.java:804)
at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:306)
at javax.faces.webapp.FacesServlet.init(FacesServlet.java:166)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1048)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:950)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4122)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4421)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
at $Proxy38.start(Unknown Source)
at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.system.ServiceController.doChange(ServiceController.java:688)
at org.jboss.system.ServiceController.start(ServiceController.java:460)
at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:662)
How To Configure JBoss AS For Production Environment
Oct 8th
JBoss is a free and open source Java based application server widely used. Since it is Java based, it is supported in a wide range of platforms. JBoss can be used in large scale deployment and supports clustering, load balancing, Enterprise Java Beans and almost all latest J2EE specifications. The current production version is 5.1.* and a new version (6+) will turn GA (Generally Available/Baseline) soon.
JBoss works “out of the box” and applications can be deployed just by dropping application WAR/EAR files to the application server’s deploy folder. But in order to use JBoss in a production server, it is necessary to configure/tune a number of application server settings. In this article I will quickly cover all the important production settings for JBoss.
This article assumes that you are hosting JBoss in a Windows 2003 Server. The steps are similar in Unix/Linux systems(Ubuntu, Fedora etc).
Prerequisites
Before we take up any of the following steps, it is necessary to fix the JBoss version to be used, the JVM version, the platform for hosting JBoss and whether clustering is required. These decisions are dependent on application requirements and current enterprise architecture of the customer. In the examples below I use JBoss 4.2.1(4.2.2) version with Java Virtual Machine 1.5 and Windows 2003 server as hosting platform.
Also note the JBoss folder structure given on the right side (see figure). The following sections refer to various folders shown in this.
Configuring JBoss in a Production Server – Step by Step Guide
Step 1 – Configuring Startup Scripts
The first thing I did was to create a set of startup/shutdown scripts for JBoss Server. These were copied to the desktop so that it is easy to start or stop the JBoss instance.
startjboss.cmd
d:
cd D:\server\jboss-4.2.2.GA\bin
run.bat -b 0.0.0.0
stopjboss.cmd
d:
cd D:\server\jboss-4.2.2.GA\bin
shutdown.bat -S
As you can see both these scripts are actually calling default scripts provided in the JBoss’ bin folder.
In the startup script the -b argument (binding ip) indicates the IP to which the server session is to be attached. 0.0.0.0 indicates that the server must be accessible from all ips including localhost (it binds the JBoss server to all ip addresses of server machine). If you don’t specify this, JBoss will be accessible only from 127.0.0.1.
Step 2 – Configuring JVM Memory Settings
The run.bat file in the bin folder contains JVM parameters including memory configuration. In the production server, ensure that these values are correctly set. For example, the following sets the minimum and maximum heap size as 1GB. It is better to keep them identical for performance reasons. The actual heap size setting will depend on your application requirements and also on the RAM size of the server machine.
set JAVA_OPTS=%JAVA_OPTS% -Xms1024m -Xmx1024m
Also ensure that adequate permgen space is set. Permgen space is the fixed memory required such as the code footprint. For large applications the default value of 64m may not be sufficient. Following sets the permgen space to 512MB.
set JAVA_OPTS=%JAVA_OPTS% -XX:PermSize=512m -XX:MaxPermSize=512m
Step 3 – Changing Default HTTP Port to 80
The HTTP port for default JBoss installation is 8080. In production server, you will require this to be on port 80 (default HTTP port). If you are using HTTPS, you will need to change SSL port from 8443 to 443. Following files must be edited for this change. Look for the “Connector” tag with “port” attribute.
(a) default/deploy/jboss-web.deployer/server.xml
(b) default/deploy/http-invoker.sar/META-INF/jboss-service.xml
(c) default/deployers/jbossweb.deployer/server.xml
(d) default/deploy/jbossws.sar/jbossws.beans/META-INF/jboss-beans.xml
Step 4 – Configuring Datasource Settings
The datasource settings are stored in xml files under deploy folder of the server. For example, oracle-ds.xml is the configuration file I used in my application. This maps a connection setting to a JNDI name. The important parameters to configure are,
min-pool-size – This is the initial number of connections kept open to database.
max-pool-size – This is the maximum number of concurrent connections possible to the database. This value should be based on your application needs and also on the database configuration.
Step 5 – Configuring HTTP Connector Settings
The underlying HTTP connector of JBoss needs to be fine tuned for production settings. The important parameters are,
maxThreads – This indicates the maximum number of threads to be allocated for handling client HTTP requests. This figure corresponds to the concurrent users that are going to access the application. Depending on the machine configuration, there is a physical limit beyond which you will have to do clustering.
acceptCount – This is the number of request threads that are put in request queue when all available threads are used. When this exceeds, client machines get a request timeout response.
compression – If you set this attribute to “force”, the content will be compressed by JBoss and will be send to browser. Browser will extract it and display the page on screen. Enabling compression can substantially reduce bandwidth requirements of your application.
Step 6 – Configuring JSP Compilation Settings
JBoss application server regularly checks whether a JSP requires compilation to a servlet before executing a JSP. In a production server, JSP files won’t change and hence you can configure the settings for increased performance.
Open the web.xml in deploy/jboss-web.deployer/conf folder. Look for the jsp servlet in the file and modify the following XML fragment as given below,
<init-param>
<param-name>development</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>checkInterval</param-name>
<param-value>300</param-value>
</init-param>
Step 7 – Removing unwanted applications and services
JBoss comes with a lot of services and your enterprise applications may not need all of them. Removing these unwanted services can boost application server performance. Following are some of the JBoss services you can remove if your application is not using them. Delete the files/folders given in brackets to remove these services completely.
(a) Home page server- (deploy/ROOT.war)
(b) JMX Console server – (deploy/jmx-console.war)
(c) Web Console server – (deploy/management)
(d) Unique ID key generator – (deploy/uuid-key-generator.sar, lib/autonumber-plugin.jar)
(e) HTTP Invoker service – (deploy/http-invoker.sar)
(f) Quartz scheduler service – (deploy/quartz-ra.rar)
(g) Mail service – (deploy/mail-service.xml, lib/mail*.jar)
(h) Monitoring service – (deploy/monitoring-service.xml,lib/jboss-monitoring.jar)
(i) Scheduler service – (deploy/scheduler-service.xml, deploy/schedule-manager-service.xml,lib/scheduler-plugin*.jar)
(j) Messaging (JMS) service – (deploy/messaging, deploy/jms-ds.xml, deploy/jms-ra.rar, lib/jboss-messaging*.jar)
Step 8 – Protecting Administration Console Applications
Some of the default Web applications in JBoss are very useful in monitoring server status. For example the Web Console can give valuable information such as server memory status and active HTTP active connections. Please see the Web Console screenshot below (http://localhost/web-console/),
So you may decide to leave them enabled on the JBoss production server. But the problem is that these can be accessed by anyone through Internet and is unprotected.
You can protect these applications using JAAS or by limiting access to these applications only from the local machine (server machine). Of course the easiest way to secure them is to remove them as I have shown in the previous section. In order to enable access only from local machine,
Add the following in server.xml (jboss-web.deployer) just before “Engine” closing tag.
<Host name=”loopback” autoDeploy=”false” deployOnStartup=”false” deployXML=”false”>
</Host>
Then add the following in jboss-web.xml in WEB-INF of the following admin applications.
loopback
For JMX Console use deploy/jmx-console.war and for Web Console use deploy/management folder. Now these monitoring apps can be accessed only from http://loopback address.
Step 9 – Configuring Log4J Logging for Production
The default logging configuration in JBoss is not suitable for production deployment. In production, you only want the errors to be logged. Open jboss-log4j.xml file in deploy/conf folder.
First change the root category in the end to contain only FILE appender. This ensures that there is logging to the screen and all errors are only logged to a file.
<root>
<appender-ref ref=”FILE”/>
</root>
Then add the following limiting categories.
<category name=”org”>
<priority value=”ERROR”/>
</category>
<category name=”com”>
<priority value=”ERROR”/>
</category>
<category name=”net”>
<priority value=”ERROR”/>
</category>
Remove the following entries,
<category name=”org.apache”>
<priority value=”INFO”/>
</category>
<category name=”org.quartz”>
<priority value=”INFO”/>
</category>
<category name=”org.jboss.management”>
<priority value=”INFO”/>
</category>
<category name=”org.jboss.serial”>
<priority value=”INFO”/>
</category>
Configure JBoss AS Context Root In Your Struts2 Application
Oct 8th
You might have possibly configured all requests to go to struts.xml from your web.xml.
However when doing a http://localhost/ , you hit the error:
There is no Action mapped for namespace / and action name
This is because Struts 2 is unable to find the action name, which is none, under the namespace / .
If you are using Struts2 over JBoss AS, you need to do three things.
First
Descend to your server deploy root in search of the file “ROOT.WAR”, ROOT.WAR is what you see when you hit http://localhost:8080/ or http://localhost/ or http://myDomainName depending on how you have configured your listening port.
Search and delete the file “ROOT.WAR”.
You may find ROOT.WAR in three or four folders under /server, the server profile that you are usually using should be “default”, so descend into default, delete the file ROOT.WAR.
ROOT.WAR is usually found in
/opt/jbossas/server/default/deploy
In Linux, you may issue the following command to find ROOT.WAR
$ find / -name “ROOT.WAR” -print
Second
Preferred method (Because it is not always the case you are deploying your .WAR as a standalone, it may be part of a .EAR enterprise archive)
In web application that you are trying to fix as the root application, under/WEB-INF folder, create the file “jboss-web.xml” if you do not already have one.
Enter this into jboss-web.xml:
The file should be placed under /WEB-INF/jboss-web.xml . It would be of interest to anyone that contents placed under /WEB-INF is protected from public direct access.
Non preferred method (Quick and easy)
Rename the web application that you are trying to fix as the root application to “ROOT.WAR” from whatever name it was given or using.
Third
In struts.xml, insert the code snippet. you should change out your redirect action and namespace accordingly. For this, i have requested redirection to the initLogin action of the secure namespace. Theoretically, the same action may be accessed by http://localhost/mywebapp/secure/initLogin.
Lastly
Redeploy to take effect. If you have turned off hot deploy, you may need to restart the server to take effect!






