Showing posts with label JBoss. Show all posts
Showing posts with label JBoss. Show all posts

Sunday, October 30, 2011

Issues with Connection Pooling in Tomcat/JBoss


Problem Statement:
One of the application is showing the below error message while accessing the application.  The application is raising this bug for every three or four months.

Ok, what is the bug here?
Cannot get a connection, pool exhausted error.

How the problem was identified?
First of all, I came to know that the problem is related to connection pooling, by observing the above specified error message details in log file.  I wanted to replicate the problem to identify the origin of the bug.  Then, I have gone through the project to verify the settings related to connection pooling.  I have identified an entry maxActive related to Connection Pooling as part of DB configuration settings.  The entry specifies the maximum number of connections that are available in connection pool.  To identify the bug, I have minimized its value from 200 to 5.  Then, I have tested the each and every operation at least 6 times.  Out of all operations, I found the above error at one operation.  The operation is throwing error as the operation is not getting an open connection.  So, I felt that the operation might be missed the close_connection statement. 
Then, I have gone through the code in that specific flow.  I found the closeConnection statement, but, it is referring the class/global variable.  In fact, the usage of class/global variable is very less in that java program.  Then, I removed the class/global variable and created the local variables when ever required.

Solution provided:

Quick solution provided:
*) Restart the web/application server. [and/or]
*) Enable removeAbandoned flag which is related to Connection Pooling as part of DB configuration settings.

<!-- To configure a DBCP DataSource so that abandoned dB connections are removed and recycled add the following paramater to the ResourceParams configuration for your DBCP DataSource Resource: -->

<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>

<!--Use the removeAbandonedTimeout parameter to set the number of seconds a dB connection has been idle before it is considered abandoned.   -->

<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value> 
</parameter>                                


Suggested solution:
Removed the class/global variable and created the local variable.

Thursday, October 27, 2011

Tomcat and JBoss co-existence


Introduction

The purpose of this note is to make Tomcat and JBoss co-existence in one system.  If Tomcat has been installed in your system and you wanted to install JBoss in the same system, you may face some problems due to conflict of resources such as ports.  This note should help you solve them.

Scenario: -

Let’s say, you have installed JDK 1.4/1.5 and Tomcat 5.0/5.5 (on Port No. 8085) to deploy some applications.  Now, you want to install JBoss 3.2.6 (on Port No. 8080) to deploy some other EJB application.  You follow the normal procedure to install JBoss.  After installing, during, you may face the following error:

11:59:03,017 ERROR [Http11Protocol] Error initializing endpoint
java.net.BindException: Address already in use: JVM_Bind:8080
at org.apache.tomcat.util.net.PoolTcpEndpoint.initEndpoint(PoolTcpEndpoint.java:264)
at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:137)
.
.
at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:407)
at org.jboss.system.server.ServerImpl.start(ServerImpl.java:311)
at org.jboss.Main.boot(Main.java:145)
at org.jboss.Main$1.run(Main.java:399)
at java.lang.Thread.run(Thread.java:534)

Solution: -

The search suggested me to change the webserver Port Number from 8080 to Something-Else (for example, 8090).  8080 is a favorite port number for a lot of different applications these days.  Please search the below mentioned files and replace 8080 to another port, say, 8090 -
'...deploy/http-invoker.sar/META-INF/jboss-service.xml' and
'...deploy/jbossweb-tomcat50.sar/server.xml'

After doing these settings restart the web server. You may still face the following console message on JBoss startup: -

11:20:00,168 INFO  [ChannelSocket] Port busy 8009 java.net.BindException:
Address already in use: JVM_Bind

This appears to be a known issue with JBoss. You can read more about this in bugs.sun.com  and bug_id=5098261

As per this information, it is not a bug.

Try the below links to ensure everything is fine:
http://localhost:8090
http://localhost:8090/jmx-console

Conclusion: - 

Tomcat and JBoss can co-exist by a simple configuration of port settings at appropriate places.


Thursday, April 21, 2011

Alfresco 3 Setup with JBoss 4.2.3

Alfresco 3 download (wiki.alfresco.com/)

*) JDK 6 was installed in C:\java.

*) Unzip jboss-4.2.3.GA.zip file in C:\Java.

*) Install MySQL 5.0.18
Copy mysql-connector-java-5.1.13-bin.jar file in C:\Alfresco\jboss-4.2.3.GA\server\default\lib
Execute the DB Script (alfresco-labs-war-3Stable\extras\databases\mysql\db_setup.sql).

*) Create one folder(alfresco.war) in C:\Alfresco\jboss-4.2.3.GA\server\default\deploy\ 
Unzip alfresco.war in C:\Alfresco\jboss-4.2.3.GA\server\default\deploy\alfresco.war.

*) Create one folder(share.war) in C:\Alfresco\jboss-4.2.3.GA\server\default\deploy\ 
Unzip share.war in C:\Alfresco\jboss-4.2.3.GA\server\default\deploy\share.war.

*) Copy alfresco-labs-war-3Stable\commands\bin and alfresco-labs-war-3Stable\commands\ImageMagick folders to C:\Alfresco\jboss-4.2.3.GA\bin folder.

*) Create a conf directory for alfresco and move the distribution extension folder.
   i.e., Copy *.* files from alfresco-labs-war-3Stable\extensions\extension folder to C:\Alfresco\jboss-5.1.0.GA\server\default\conf\alfresco.

*) Edit run.bat file in C:\Alfresco\jboss-4.2.3.GA\bin 
set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=128m
set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote -Dalfresco.home=.
*) Edit C:\Alfresco\jboss-4.2.3.GA\server\default\deploy\jboss-web.deployer\server.xml and C:\Java\jboss-4.2.3.GA\server\all\deploy\jboss-web.deployer\server.xml and add URIEncoding="UTF-8" to the section
<Connector port="8080" address="${jboss.bind.address}"
maxThreads="250" maxHttpHeaderSize="8192"
For example:
<Connector port="8080" URIEncoding="UTF-8" address="${jboss.bind.address}"
maxThreads="250" maxHttpHeaderSize="8192"

*) Edit \jboss\server\default\deploy\ejb3.deployer\META-INF\persistence.properties and change the line:
hibernate.bytecode.provider=javassist
to
hibernate.bytecode.provider=cglib

*) Run the application by using run.bat in C:\Java\jboss-4.2.3.GA \bin 
*) Test application by using URL:http://localhost:8080/alfresco 
*) The default UserID:admin and Password:admin

WCM Integration:
==============
*) Get alfresco-labs-wcm-3Stable.zip and unzip it.
*) copy the file wcm-bootstrap-context.xml to the Alfresco<extension> directory (C:\Java\jboss-4.2.3.GA\server\default\deploy\alfresco.war\WEB-INF\classes\alfresco\extension).
*) Restart JBoss

Verifying the WCM installation
=======================
*) In alfresco.log, search for the following text:
The Web Forms folder was successfully created: and The Web Projects folder was successfully created:
*) Check that the following additional spaces are in your Alfresco repository:
• Web Projects in Company Home
• Web Forms in Data Dictionary