Thursday, May 2, 2013

Mac OSX - install mod_jk

 Steps to install mod_jk on OSX


  • Download source from apache site
    • http://apache.mirrors.hoobly.com//tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.41-src.tar.gz
  • Extract file and start building

           cd native
make clean
./configure CFLAGS='-arch x86_64' APXSLDFLAGS='-arch x86_64' --with-apxs=/usr/sbin/apxs
make
sudo make install

If you are seeing a compiler issues , follow below steps


The C compiler ("cc") is located inside of that xctoolchain directory.
I created a symlink for OSX10.8.xctoolchain to point to XcodeDefault.xctoolchain
and that fixed the issue of compiler issue.

cd /Applications/Xcode.app/Contents/Developer/Toolchains
sudo ln -s XcodeDefault.xctoolchain OSX10.11.xctoolchain


If internal directory doesn't exist. There was no MacOSX10.11.Internal.sdk intead the directory was MacOSX10.11.sdk. So to create a symlink:

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.Internal.sdk


Disable System Integrity by restarting the machine and holding [ Command + R ] until apple logo comes up.
then open the terminal from utilities and enter below command

csrutil disable   --> this is done because when installing apache mod_jk.so file is not getting installed in /usr/libexec/apache2 folder, throwing error permission denied.

again to enable enter below command


csrutil enable.



Configure Apache  mod_jk.conf ( /etc/apache2/other/mod_jk.conf )


ps=/
LoadModule    jk_module  /usr/libexec/apache2/mod_jk.so
JkShmFile    /var/log/apache2/mod_jk.shm
JkWorkersFile /etc/apache2/workers.properties
JkLogFile     /var/log/apache2/mod_jk.log
JkLogLevel    info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkRequestLogFormat "%w %V %T"
<Location /status>
    JkMount status
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1 192.168.2.%
</Location>
# app2 Worker
JkMount /*.jsp worker1
JkMount /* worker1
## lb test - Worker
JkMount /lb lbloadbalancer
JkMount /lb/* lbloadbalancer



workers.properties (cd /etc/apache2/)

ps=/
worker.list=worker1, lbloadbalancer
worker.default.port=8009
worker.default.host=localhost
worker.default.type=ajp13
worker.default.lbfactor=1
# worker1
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
  
worker.worker1.socket_connect_timeout=10000
worker.worker1.socket_keepalive=True
worker.worker1.ping_mode=A
worker.worker1.ping_timeout=10000
worker.worker1.connection_pool_minsize=0
worker.worker1.connection_pool_timeout=600
worker.worker1.retries=1
worker.worker1.recovery_options=7
worker.worker1.reply_timeout=10000



# LB - Loadbalancer
worker.lbloadbalancer.type=lb
worker.lbloadbalancer.balance_workers=worker1
worker.lbloadbalancer.sticky_session=True

 •Change Tomcat-server config
Edit file:
$TOMCAT_INSTALL/conf/server.xml
Change

Engine name="Catalina" defaultHost="localhost"
Into:
Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1"


That's it.


starting apache
cd /etc/apache2/
sudo apachectl start/stop

logs for mod_jk
cd /var/log/apache2
tail -f mod_jk.log


To enable server status for apache on Mac OSX.
This is the solution if you are running Mac OS X 10.11 El Capitan. Note: You need administrator privileges. (sudo)
 In your /etc/apache2/httpd.conf uncomment these lines
 LoadModule status_module libexec/apache2/mod_status.so
Include /private/etc/apache2/extra/httpd-info.conf

Now open /etc/apache2/extra/httpd-info.conf and make changes as below.
<Location /server-status>
  SetHandler server-status
  Require host localhost
  </Location>

Now you can open the URL http://localhost/server-status with your web browser and see the apache status.


Include below to see " It Works" when you enter localhost in your browser, however localhost/status page throws error now.


# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>


Sunday, April 24, 2011

Setting up Coherence in Tomcat Clustered Environment

Update catalina.sh




XXX_OPTS="-Dtangosol.coherence.distributed.localstorage=false -Dtangosol.coherence.cacheconfig=$PROP_PATH/coherence_cache.xml -Dtangosol.coherence.override=$PROP_PATH/coherence_cache_override.xml"

export CATALINA_OPTS="-server -d64 -Xloggc:xxxx/gc.log -XX:+PrintGCDetails -Xms2048m -Xmx2048m -Dfile.encoding=UTF-8 -DKMSERVICES_HOME=$PROP_PATH $XXX_OPTS"
echo "Catalina OPTS "  $CATALINA_OPTS

below is the coherence_cache_override.xml



below is the coherence_cache.xml



Saturday, April 16, 2011

How to install/Test Coherence*WEB for Weblogic

Coherence Based Session Management

Assumptions: you have downloaded latest web logic server 10.3.3 and Coherence Web 3.6
                       from Oracle

Instructions

First we will create weblogic domains : something like DOMAIN_A and DOMAIN_B.
To configure those domains with coherence based session management, then the
changing of session variable value in one domain will propagate to another domain.

Main Steps

Application Server (WebLogic)

1) Create DOMAIN_A and DOMAIN_B
2) Copy coherence.jar to DOMAIN_A\lib and DOMAIN_B\lib
3) Start both the Domains
4) Deploy coherence-web-spi.war as a shared library

Coherence

1) duplicate cache-server.cmd at the same folder in the coherence and rename
    it to web-cache-server.cmd
2) modify web-cache-server.cmd as shown below
3) set java_opts="-Xms%memory% -Xmx%memory%"

"%java_exec%" -server -showversion "%java_opts%" -cp
c:\coherence\lib\coherence.jar;c:\coherence\lib\coherence-web-spi.war -
Dtangosol.coherence.management.remote=true -Dtangosol.coherence.cacheconfig=WEB-
INF/classes/session-cache-config.xml -Dtangosol.coherence.session.localstorage=true
com.tangosol.net.DefaultCacheServer %1

4) startup web-cache-server.cmd
5) Modify weblogic.xml to add a reference to coherence-web-spi as shown below
     in you application


 wls:library-ref
      wls:library-name   coherence-web-spi  wls:library-name
      wls:specification-version   1.0.0.0  wls:specification-version
      wls:exact true  wls:exact
wls:library-ref


deploy the webapp to DOMAIN_A and DOMAIN_B

Now test Session variable value at DOMAIN_A and check wether it is changed at DOMAIN_B, As show in the below figure

Coherence In Action

Tuesday, April 12, 2011

Setting Up Tomcat Multiple Instances

Setting up tomcat multiple instances

1) First Original Instance, download apache-tomcat-5.5.33 ( any version) this will be the original
Instance and change nothing here.

2) For the instance 2 ... to N do the following as mentioned below

a) Create a new Folder (TomcatInstance1….N) as many as you instances as you want
b) Copy following folders over to TomcatInstance1… to N
conf
logs
temp
webapps
work
c) Write a script to startup/shutdown the second instance(name it as startup.sh
and shutdown.sh) and place under TomcatInstance1..N folders
d) Add following to the newly created startup.sh


CATALINA_HOME=~/Documents/apache-tomcat-5.5.33
CATALINA_BASE=~/Documents/TomcatInstance1
export CATALINA_HOME CATALINA_BASE


$CATALINA_HOME/bin/catalina.sh start

e) Add the following to the newly created shutdown.sh


CATALINA_HOME=~/Documents/apache-tomcat-5.5.33
CATALINA_BASE=~/Documents/TomcatInstance1
export CATALINA_HOME CATALINA_BASE


$CATALINA_HOME/bin/catalina.sh stop

f) Modify the server.xml file in TomcatInstance1/conf/server.xml and change the port
number to 8180

AND change port number to 8109 for the Connector Port of "AJP/1.3"

That's it now start the server with following command " sh startup.sh" and login to
http://localhost:8180 and you should see the tomcat page, do the same for as many instances as you want

How to install/Test Coherence*WEB for Tomcat

Steps to Create

First Install Coherence*Web in your local directory

1) Complete the application inspection step by running the following command.
Specify the full path to your application and the name of your server
(replacing the and with them in the command line below):

java -jar webInstaller.jar
-inspect -server:

e;g java -jar WebInstaller.jar c:\MyCoherenceWeb -inspect -server:Tomcat/5.5


The system will create the coherence-web.xml

2) Complete the Coherence Web application installation step by running the following command,
replacing with the full path to your application:

java -jar webInstaller.jar
-install
e;g java -jar webInstaller.jar c:\MyCoherenceWeb -install


The installer requires a valid coherence-web.xml configuration file to reside
in the same directory as the application

checking if this process is correctly installed or not by verifying the application.war file.

1) Make sure you have a coherence-web.xml in you META-INF file.
2) Installer will Add the following directive to each JSP Page that you have in application

3) Installer will modify and add Coherence Web configuration context parameters in web.xml
descriptor and also add's a listener classes at the end of the web.xml file
4) Make sure you classes folder will have "session-cache-config.xml" file generated.
5) Make sure you lib folder contain coherence.jar and coherence-web.jar

Friday, July 24, 2009

Portlet IPC using JBOSS Portal


Portlet 2.0 is the recently finalized latest version of the Java portlet
specification. One of the shortcomings of the previous version of the spec
(JSR168)was lack of support for inter-portlet communication.As a result,
developers had to resort to all kinds of fancy workarounds using Dojo Toolkit

I am not going to explain what is JSR286 , but try to
achieve IPC for JBOSS Portal

Defining events

To define an event, you would have to declare it in
portlet.xml, as shown below

<event-definition>
<qname
xmlns:mycomp='http://www.something.com/jsr286'>
something:AppEvent</qname>
<value-type>com.ceon.ocp.portlet.WrapperEvent</value-type>
</event-definition>

Publishing an Event

<portlet>
....
<portlet-name>pubEventPortlet</portlet-name>
<supported-publishing-event>
<qname
xmlns:something='http://www.something.com/jsr286'>
something:AppEvent</qname>
</supported-publishing-event>
....
</portlet>

Processing an Event

<portlet>
....
<portlet-name>subEventPortlet</portlet-name>
<supported-processing-event>
<qname xmlns:something='http://www.something.com/jsr286'>
something:AppEvent</qname>
</supported-processing-event>
....
</portlet>

Each portlet definition can have both publishing and processing tags
and you could define multiple events within each portlet definition

Coding events

An Example event class

@XmlRootElement
public class WrapperEvent implements Serializable {
...
public static final QName QNAME = new QName(
"http://www.something.com/jsr286", "AppEvent");
private String name;
private String zipcode;
...
}

An event class must implement the Serializable interface and be annotated with
@XmlRootElement, I am using Java 5,so I used jaxb-api-2.1.jar from the JBoss portlet
container 2.0 lib directory

subscriber ( receiving portlet )

@Override
protected void doView(RenderRequest request, RenderResponse renderResponse)
throws PortletException, IOException {
renderResponse.setContentType(request.getResponseContentType());
// setting the attributes for JSP
request.setAttribute(QUOTE_ATTR, quoteId);
getPortletContext().getRequestDispatcher(VIEW_JSP).include(request,renderResponse);
}
@Override
public void processEvent(EventRequest eventRequest, EventResponse response)
throws PortletException, IOException {
Event event = eventRequest.getEvent();
if(event.getQName().equals(WrapperEvent.QNAME))
{
com.ceon.ocp.portlet.WrapperEvent
wrapEvent=(com.ceon.ocp.portlet.WrapperEvent)event.getValue();
quoteId = wrapEvent.getQuoteID();

}
}

Publisher( trigger event portlet)

@Override
protected void doView(RenderRequest request, RenderResponse renderResponse)
throws PortletException, IOException {
renderResponse.setContentType(request.getResponseContentType());
getPortletContext().getRequestDispatcher(VIEW_JSP)
.include(request,renderResponse);
}

@Override
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
String quoteParam = request.getParameter("QuoteID");
if ( quoteParam == null || quoteParam.trim().equals("")) {
quoteParam = "No Quote ID Specified";
}
com.ceon.ocp.portlet.WrapperEvent event
= new com.ceon.ocp.portlet.WrapperEvent();
event.setQuoteID(quoteParam);
response.setEvent(com.ceon.ocp.portlet.WrapperEvent.QNAME, event);
}

And simple JSPs for both subscriber and publisher.

reciever.jsp

<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<portlet:defineObjects />
Here are the details of Quote State:
QuoteState: <%= renderRequest.getAttribute("QuoteID")%>

publisher.jsp

<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<portlet:defineObjects />
Please enter Quote ID and click submit,you should
see the Quote State in OCP Portlet

<form method='post' action="<portlet:actionURL />" >
QuoteID: <input type=text name=QuoteID>
<input type=submit>
</form>

One final step is go to

After you have installed and configured the container,look at its core Web
application, called simple-portal.This Web application holds the framework that
displays the portlets. You could either add your own page by modifying
layouts/nav/main.jsp, or modify one of the existing pages. I modified one of the
existing pages, demo/demo.jsp, by removing its portlets and adding my own custom
portlets. The JBoss portlet container uses a very simple tag library to include
portlets, which requires the portlet name as defined in portlet.xml and the
context name of the portlet Web application

<xportal:portlet name="pubEventPortlet" applicationName="JbossSample"/>
<xportal:portlet name="subEventPortlet" applicationName="JbossSample"/>

As you can see, it's quite easy for a portlet to receive events from another portlet,
whether the two portlets reside in the same or separate Web applications.
You just have to make sure to include the common event classes in all portlet Web
applications.If you would like to deploy this application to an other Portlet 2.0
container, make sure to check that container's requirements for web.xml,as some
containers expect specific elements in the web.xml files of Portlet 2.0 applications

How to configure a Jboss Datasource?

Configuring a Datasource in Jboss very easy
Step 1: copy the original oracle-ds.xml from $jboss-home\docs\examples\jca\oracle-ds.xml to
$jboss-home\server\default\deploy\
Step 2: modify the XML file as follows
<datasources>
<local-tx-datasource>
<jndi-name>OracleDS</jndi-name>
<connection-url>jdbc:oracle:thin:@IP:PORT:SID</connection-url>
<use-java-context>false</use-java-context>
<!-- this is required if u want to connect to DB remotely from Main method-- >
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<user-name>user</user-name>
<password>password</password>
<min-pool-size>5</min-pool-size>
<max-pool-size>100</max-pool-size>
<query-timeout>60</query-timeout>

<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>

Step 3. Drop the JDBC driver jar into Jboss classpath (easiest approach - drop the jar file in to /server/default/lib)

Create ElasticSearch cluster on single machine

I wanted to figure out how to create a multi-node ElasticSearch cluster on single machine. So i followed these instructions First i did...