Total Visitors

Saturday, December 7, 2013

Clustering and Load Balancing in JBoss 7.1 using Apache mod_jk

Comming Soon ....

Auto Connection after Network Failure in JBoss 7.1

Put the following inside <datasource> .... </datasource> :- 
  <validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
<stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker"/>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter"/>
  </validation>
<timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>1</idle-timeout-minutes>
</timeout>

----- OR -----

<validation>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>

----- OR -----
<validation>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
<validate-on-match>true</validate-on-match>
<background-validation>false</background-validation>
</validation>


----------EXPLAINATIONS-------------

--> <valid-connection-checker-class-name> :- a class that can check whether a connection is valid using a vendor specific mechanism

--> <check-valid-connection-sql> :- an sql statement that is executed before it is checked out from the pool (see <validate-on-match>) to make sure
it is still valid.If the sql fails, the connection is closed and new ones created. Also it will be used by <background-validation>

--> <validate-on-match> :- whether to validate the connection when the JCA layer matches a managed connection (i.e. when the connection is checked out
of the pool). With the addition of <background-validation> this is not necessarily required.
Note: Specifying "true" for <validate-on-match> is typically not done in conjunction with specifying "true" for <background-validation> as
this would be overkill in most scenarios.  Default is true.

--> <background-validation> :- In JBoss 4.0.5 background connection validation was added to help reduce the overall load on the RDBMS system  when validating a connection. When using this feature, JBoss will attempt to validate the current connections in the pool is a separate thread (ConnectionValidator). This must be set to true for <background-validation-minutes> to take effect.  Default is false.

--> <stale-connection-checker-class-name> :- An implementation of org.jboss.resource.adapter.jdbc.StateConnectionChecker that will decide whether
SQLExceptions that notify of bad connections throw org.jboss.resource.adapter.jdbc.StateConnectionException (from JBoss5)

--> <exception-sorter-class-name> :- a class that looks at vendor specific messages to determine whether sql errors are fatal and thus the connection  should be destroyed.  If none specified, no errors will be treated as fatal.

--> <blocking-timeout-millis> :- the length of time to wait for a connection to become available when all the connections are checked out. Default is 30000 (30 seconds).

--> <idle-timeout-minutes> :- indicates the maximum time a connection may be idle before being closed. Setting to 0 disables it.  Default is 15 minutes.


Sunday, November 24, 2013

What is AJP? A short introduction



  • AJP is used to communicate between the web server and the servlet container
  • The Apache JServ Protocol (AJP) is a binary protocol that can proxy inbound requests from a web server through to an application server that sits behind the web server. The web server is a “reverse proxy,” meaning, its purpose is to handle incoming traffic from the Internet on behalf of the application server.
  • Gal Shachor was the original designer of this protocol. There is, apparently, no current documentation of how the protocol works.
  • Apache JServ is a 100% pure Java servlet engine fully compliant with the JavaSoft Java Servlet APIs 2.0 specification
  • Web implementers typically use AJP in a load-balanced deployment where one or more front-end web servers feed requests into one or more application servers.
  • AJP runs in Apache HTTP Server using the mod_jk plugin.
  • When it was developed the goals of this protocol was
    • Increasing performance (speed, specifically).
    • Adding support for SSL, so that isSecure() and getScheme() will function correctly within the servlet container.
  • A binary format was presumably chosen over the more readable plain text for reasons of performance.

Monday, November 18, 2013

Enabling Debug Facility in JBoss7 AS.

Go to bin/standalone.conf.bat of JBoss 7 AS:-

Inside this file just remove the rem from the below given line:

rem # Sample JPDA settings for remote socket debugging
set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

Then if you are using eclipse as an IDE do the following steps:-
1) Go to Debug configuration
2) Go to Remote Java Application
3) Assign Port: 8787
4) Give your desire Project name and Enjoy!

Wednesday, November 13, 2013

Migration From JBoss6 to JBoss7 AS Servers

1) Make a lib dir inside the EAR and copy paste only the required.(Removed)
Place all your depended lib inside the EarContent/lib folder.
2) Go to Eclipse and make add the lib classpath from this EarContent/lib folder.
3) Here in SRS it will give jxl error, so give classpath of this specific jxl jar file which is situated inside common.


1) ERROR: Caused by: org.jboss.msc.service.ServiceNotFoundException: Service service jboss.ejb.default-resource-adapter-name-service not found
solution: inside standalone.xml add the following lines under "<subsystem xmlns="urn:jboss:domain:ejb3:1.2">"
in standalone.xml:-
<mdb>
  <resource-adapter-ref resource-adapter-name="hornetq-ra"/>
  <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
</mdb>
Note:
If you are configuring it inside standalone.xml but inside standalone-full.xml it is not required and no error will be displayed.

2) Create Connection Pooling.
Go to Datasource and make a connection pooling for your database.
In JBoss 7 configuration the JNDI path is different:
private final String GLOBAL = "java:global";
private final String EJB ="SRSEJB";
Its: GLOBAL + EksConstants.FILE_SEPARATOR+ EAR_NAME + EksConstants.FILE_SEPARATOR +EJB+ EksConstants.FILE_SEPARATOR + jndiName;
--Goto persistance.xml and do the following:
<jta-data-source>java:jboss/SRSOracleDS</jta-data-source>

3) Caused by: java.lang.NoClassDefFoundError: jxl/format/CellFormat
-- https://community.jboss.org/thread/195522
That location isn't meant for placing the application jars. You'll have to package the jxl.jar within
the EarContent/lib folder
That's what the EE spec says about application libraries.

4) Switch to standalone-full.xml, here you don't have to explicitly write step:1

5) Go to standalone.conf.bat and standalone.conf file and change standalone.xml to respective .xmls.

6) In JB7 the @WebContext has changed the jar path. Earlier it was import org.jboss.wsf.spi.annotation.WebContext;
Now it has changed to import org.jboss.ws.api.annotation.WebContext;

7) As in JBoss6 go to your hornetq-jms.xml and pick up:
<jms-queue name="SRSScheduleQueue">
<entry name="/queue/SRSScheduleQueue"/>
</jms-queue>
and paste it inside the standalone-full.xml of JB7 under  "<jms-destinations>"

8)
Go to JBoss Admin Console and add your property configuration in System Properties.
Or add properties at run time manually by CLI(Command Line Argument) as shown below:-
 As in JBoss6 go to your properties-service.xml and pick up:
JBOSS_CONF_FOLDER=C:/jboss-6.1.0.Final/server/conf
SRS_PROP=SRS.properties
RESOURCE_PROP=resources.properties
paste it in a notepad and save it as a .properties file in a drive (say D:/).
-- Prepare a bat file as shown below:
c:
cd C:\jboss-as-7.1.1.Final\bin
standalone.bat --properties d:\srsConfig.properties
Run it...
Observation:-
After load the properties, u can see it at
localhost:8080 > Configuration > Environment Properties
Note:-
Run it......

9) Set your mail configuration inside standalone-full.

Hot Deployment in JB7

#Steps:- https://community.jboss.org/message/723945

1. Please make sure to add
<configuration>
<jsp-configuration development="true"/>
</configuration>
in standalone.xml under <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">        

2. Go to jboss-as-7.1.1.Final/modules/org/jboss/as/web/main
  Place the jboss-as-web-7.1.1.Final-RECOMPILE.jar in there. You can download from http://www.datafilehost.com/download-2cb9ff04.html

3. Open module.xml (jboss-as-7.1.1.Final/modules/org/jboss/as/web/main) and add the following line
<!--resource-root path="jboss-as-web-7.1.1.Final.jar"/-->
<resource-root path="jboss-as-web-7.1.1.Final-RECOMPILE.jar"/>

-----------------------------------OR ANOTHER WAY!-----------------------------

<servlet>
            <servlet-name>jsp</servlet-name>
            <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
            <init-param>
                <param-name>development</param-name>
                <param-value>true</param-value>
            </init-param>
            <load-on-startup>3</load-on-startup>
        </servlet>

How to configure Domain and Host in JBoss 7 AS Server

1) Domain Side (Master)
eg :-(say)
Domain(Master):-10.112.98.200
Host(Slave):-10.112.98.154

Remember:- If we want to create a host then we should first create Users for the host by clicking on add-user.bat cmd.
Then its username and password is used inside the HOST side in host.xml file.
Here say username:- slave and password:- admin

On DOMAIN Side:-
Create User by running add_user.bat. eg:- username: slave password:admin
Create bat with this command:-
domain.bat -b 10.112.98.154 -Djboss.bind.address.management=10.112.98.154
Now run it...

2) Host Side (Slave)
Create a bat file:-
c:
cd C:\jboss-as-7.1.1.Final_Cluster\bin
domain.bat -b 10.112.98.200 -Djboss.domain.master.address=10.112.98.154 -Djboss.bind.address.management=10.112.98.200

3)
Open host.xml : add server identities inside managementRealm attribute and Secret value in base64 format:

Convert Host Created password into base64 decoding using online decoder and place it inside the <secret value>.

<host name="slave" xmlns="urn:jboss:domain:1.2">     <--- username (which was created on Master)

<security-realm name="ManagementRealm">
<server-identities>
<!-- Replace this with either a base64 password of your own, or use a vault with a vault expression -->
      <secret value="YWRtaW4="/>                 <--- password (which was created on Master)
</server-identities>
<authentication>
<properties path="mgmt-users.properties" relative-to="jboss.domain.config.dir"/>
</authentication>
</security-realm>

### Edit the <domain-controller> at host section to read:
 <domain-controller>
       <!--<local/>-->
       <!-- Alternative remote domain controller configuration with a host and port -->
       <remote host="${jboss.domain.master.address}" port="${jboss.domain.master.port:9999}" security-realm="ManagementRealm"/>
    </domain-controller>

Don't forget to add the the security-realm attribute otherwise you will get messages like:


[Host Controller] 16:26:06,454 ERROR [org.jboss.remoting.remote.connection] (Rem
oting "host1:MANAGEMENT" read-1) JBREM000200: Remote connection failed: javax.se
curity.sasl.SaslException: Authentication failed: all available authentication m
echanisms failed
[Host Controller] 16:26:06,469 ERROR [org.jboss.as.host.controller] (Controller
Boot Thread) JBAS010901: Could not connect to master. Aborting. Error was: java.
lang.IllegalStateException: JBAS010942: Unable to connect due to authentication
failure.

Now run your Host side...You can access the link either from Master's or Host's IP Address.