Tuesday, June 15, 2010

JBoss 5.X.X Custom Profile

Creating a Custom profile in JBoss 5.X.X

Below are the steps to create a Custom Profile which Doesn't use Default DS. This profile supports -- web apps & ejb apps as well

Below Services are trimmed down in this profile

1. EJBTimerService - using persistencePolicy=noop
2. JUDDI
3. Key Generator
4. JBoss Messaging
5. JBoss Mail
6. Scheduling
7. Hypersonic DB
8. Turn off hot deployment

Steps to Do

1. In server/node/deploy/ejb2-timer-service.xml
Comment the mbean name="jboss.ejb:service=EJBTimerService (comment the complete mbean )
Comment the depends optional-attribute-name="PersistencePolicy">jboss.ejb:service=EJBTimerService,persistencePolicy=databasedepends
Uncomment the mbean code="org.jboss.ejb.txtimer.NoopPersistencePolicy" name="jboss.ejb:service=EJBTimerService,persistencePolicy=noop"

2 Remove JUDDI

Remove , In server/node/deploy
  • juddi-service.sar
3. Remove Key Generator

In server//deploy/ remove:

  • uuid-key-generator.sar
4. Remove JBoss Messaging

In server//deploy/ remove:

  • messaging
  • jms-ra.rar

In server//deployers/ remove:

  • messaging-definitions-jboss-beans.xml

5. Remove JBoss Mail

In server//deploy/ remove:

  • mail-service.xml
  • mail-ra.rar
6. Scheduling

In server/node/deploy

  • scheduler-manager-service.xml
  • scheduler-service.xml
  • quartz-ra.rar
7. Remove Hypersonic DB

Performed these steps
  • Remove the libraries hsqldb.jar and hsqldb-plugin.jar from jboss/common/lib/.
  • Remove the descriptor for the HSQLDB datasource DefaultDS by deleting deploy/hsqldb-ds.xml;
  • In conf/login-config.xml, comment out the declaration with the name "HsqlDbRealm";

8. Turn off hot deployment

In server//deploy/ remove:

  • hdscanner-jboss-beans.xml

Tuesday, May 18, 2010

Solaris coreadm utility

This includes the ability to control where core files are written, the name of core files, which portions of the processes address space will be written to the core file, and my favorite option, whether or not to generate a syslog entry indicating that a core file was generated.

To begin using coreadm, you will first need to run it wit the “-g” option to specify where core files should be stored, and the pattern that should be used when creating the core file:

$ coreadm -g /var/core/core.%f.%p

Once a directory and file pattern are specified, you can optionally adjust which portions of the processes address space (e.g., text segment, heap, ISM, etc.) will be written to the core file. To ease debugging, I like to configure coreadm to dump everything with the”-G all” option:

$ coreadm -G all

Since core files are typically created at odd working hours, I also like to configure coreadm to log messages to syslog indicating that a core file was created. This can be done by using the coreadm “-e log” option:

$ coreadm -e log

After these settings are adjusted, the coreadm “-e global” option can be used to enable global core file generation, and the coreadm utility can be run without any arguments to view the settings (which are stored in /etc/coreadm.conf):

$ coreadm -e global

$ coreadm

     global core file pattern: /var/core/core.%f.%p
global core file content: all
init core file pattern: core
init core file content: default
global core dumps: enabled
per-process core dumps: enabled
global setid core dumps: disabled
per-process setid core dumps: disabled
global core dump logging: enabled

Once global core file support is enabled, each time a process receives a deadly signal (e.g., SIGSEGV, SIGBUS, etc.):

$ kill -SIGSEGV 4652

A core file will be written to /var/core:

$ ls -al /var/core/*4652

-rw-------   1 root     root     4163953 Mar  9 11:51 /var/core/core.inetd.4652

Friday, May 7, 2010

Managing JBoss 5.0.0 Instance

Managing JBoss Instance

  • Admin Console
  • JMX Console
  • JBoss Web Console
Admin Console & JMX Console

http://ip:port/admin-console
http://ip:port/jmx-console/

username/passwd == admin/admin

  • vi jboss-eap-5.0/jboss-as/server/node/conf/props/jmx-console-users.properties & uncomment admin=admin

Imp files
jmx-console-roles.properties
jmx-console-users.properties

Being Reffered in login-config.xml

server/node/conf/props/jmx-console-users.properties
server/node/conf/props/jmx-console-roles.properties


JBoss Web Console

http://ip:port/web-console

username/passwd == admin/admin

  • Copy files in jboss-eap-5.0/jboss-as/server/node/deploy/management/console-mgr.sar/web-console.war/WEB-INF/classes/
web-console-users.properties
web-console-roles.properties

to jboss-eap-5.0/jboss-as/server/node/conf/props/

  • vi the file web-console-users.properties and uncomment admin=admin
  • vi login-config.xml and update web-console element to right location
props/web-console-users.properties
props/web-console-roles.properties


Services in JBoss 5.X.X

Following are the list of Services I cross in Jboss version : jboss-eap-5.0 (enterprise-installer-5.0.0.GA.jar)

EJB3 services

In server/node/deploy/
  • ejb3-connections-jboss-beans.xml
  • ejb3-container-jboss-beans.xml
  • ejb3-interceptors-aop.xml
  • ejb3-timerservice-jboss-beans.xml
  • profile-service-secured.jar

In server//deployers

  • jboss-ejb3-endpoint-deployer.jar

EJB2 services

In server/node/deploy
  • ejb2-container-jboss-beans.xml
  • ejb2-timer-service.xml (Note that EJB3 deployments may fail without this service. See this forum post)

JUDDI

In server/node/deploy
  • juddi-service.sar

Key Generator

In server/node/deploy

  • uuid-key-generator.sar

JBoss Messaging

In server/node/deploy

  • messaging
  • jms-ra.rar

In server/node/deployers

  • messaging-definitions-jboss-beans.xml

JBoss Mail

In server/node/deploy

  • mail-service.xml
  • mail-ra.rar

Scheduling

In server/node/deploy

  • scheduler-manager-service.xml
  • scheduler-service.xml
  • quartz-ra.rar

Hypersonic DB

hsqldb-ds.xml
jboss/common/lib/hsqldb.jar and lib/hsqldb-plugin.jar

JBossWS

In server/node/deploy

  • jbossws.sar

In server/node/deployers

  • jbossws.deployer

Seam

In server/node/deployers/

  • seam.deployer
  • webbeans.deployer

In server/node/deploy

  • admin-console.war - takes too much resources in JBoss 5.x, remove it even if you use Seam

other services

In server/node/deployers

  • xnio-provider.jar - not used in JBoss 5.x default configuration for JBooss remoting anyway

In server/node/deploy

  • jboss-xa-jdbc.rar - if you do not use XA datasources
  • jmx-remoting.sar - remote (RMI) acces to JMX, you can still access JMX by jmx-console
  • profileservice-secured.jar - secured remote access to profileservice
  • sqlexception-service.xml - pretty useless in JBoss 5.x
  • xnio-provider.jar - not used in JBoss 5.x default configuration for JBooss remoting

In server/node/deployers

  • hibernate-deployer-jboss-beans.xml - deployment of HAr archives only, you can still use Hibernate in EJBs after you remove this

Also, feel free to remove the corresponding .jars for the services slimmed above from jboss/common/lib.

RemoveHSQLDB in Jboss 5.X.X

Version : jboss-eap-5.0 (enterprise-installer-5.0.0.GA.jar)

Performed these steps on default profile
  • Remove the libraries hsqldb.jar and hsqldb-plugin.jar from jboss/common/lib/.
  • Remove the descriptor for the HSQLDB datasource DefaultDS by deleting deploy/hsqldb-ds.xml;
  • In conf/login-config.xml, comment out the declaration with the name "HsqlDbRealm";


Several services rely on the datasource defaultDS which point to HsqlDbRealm
  • JBoss Messaging
  • EJB Services (EJB Timer Service)
  • Key Generator Services

We should remove above services, otherwise you will end up in dependency errors. Below are the steps to remove them


Remove JBoss Messaging

In server//deploy/ remove:

  • messaging
  • jms-ra.rar

In server//deployers/ remove:

  • messaging-definitions-jboss-beans.xml

Remove EJB3 services

In server//deploy/ remove:

  • ejb3-connections-jboss-beans.xml
  • ejb3-container-jboss-beans.xml
  • ejb3-interceptors-aop.xml
  • ejb3-timerservice-jboss-beans.xml
  • profile-service-secured.jar

In server//deployers/ remove

  • jboss-ejb3-endpoint-deployer.jar

Remove EJB2 services

In server//deploy/ remove:

  • ejb2-container-jboss-beans.xml
  • ejb2-timer-service.xml (Note that EJB3 deployments may fail without this service. See this forum post)

Remove Key Generator

In server//deploy/ remove:

  • uuid-key-generator.sar

Remove JBoss Mail

In server//deploy/ remove:

  • mail-service.xml
  • mail-ra.rar

Tuesday, February 2, 2010

Java.lang.OutOfMemory Error

JVM error (Java.lang.OutOfMemory) that indicates a condition where not enough free memory is available to allocate a object

It Can be caused by
  • Undersized Heap
  • Memory fragmentation
  • Memory leak in java code
  • Not enough memory in native code
Different types

Exception in thread "main": java.lang.OutOfMemoryError: Java heap space

Exception in thread "main": java.lang.OutOfMemoryError: PermGen space

Exception in thread "main": java.lang.OutOfMemoryError: Requested array size exceeds VM limit

Exception in thread "main": java.lang.OutOfMemoryError: request bytes for . Out of swap space?

Exception in thread "main": java.lang.OutOfMemoryError: (Native method)

Friday, January 8, 2010

How Java Objects use Heap Memory

In this blog, lets look at how objects are stored in memory in Java so that you can understand at a lower level what happens when you create and manipulate the objects that make up your programs

A typical Java program contains many Java language attributes like Classes, Methods, Variable, Objects etcThrough these object interactions, a program can carry out various tasks, such as implementing a GUI,running an animation, or sending and receiving information over a network

There are two kinds of memory used in Java.
Stack memory
Heap memory.

Stack memory stores primitive data types.

Heap memory stores the java objects (When a new object is invoked in java program). See below for how object is created in java program

When you are done with an object, the memory is reclaimed for you automatically via Garbage collection runs as a thread in the background, looking for objects that no longer have a usable reference. When it finds them, it destroys them and reclaims the memory.

An object reference on the stack is only an address that refers to the place in heap memory where that object is kept.

As Java programmer, you do not have to directly address memory allocation
and recovery of memory space.

Below is snapshot of code which creates three objects:
One Point object and two Rectangle objects.

Point originOne = new Point(23, 94);
Rectangle rectOne = new Rectangle(originOne, 100, 200);
Rectangle rectTwo = new Rectangle(50, 100);

Primitive data types have just one value to store. For instance:
int i = 1;

The appropriate amount of space is allocated given the data type, and the variable is stored in memory just as it is.