d8888 888 888      88888888888 888      d8b                                 888       888          888       .d8888b.           888                               
      d88888 888 888          888     888      Y8P                                 888   o   888          888      d88P  Y88b          888                               
     d88P888 888 888          888     888                                          888  d8b  888          888      Y88b.               888                               
    d88P 888 888 888          888     88888b.  888 88888b.   .d88b.  .d8888b       888 d888b 888  .d88b.  88888b.   "Y888b.   88888b.  88888b.   .d88b.  888d888 .d88b.  
   d88P  888 888 888          888     888 "88b 888 888 "88b d88P"88b 88K           888d88888b888 d8P  Y8b 888 "88b     "Y88b. 888 "88b 888 "88b d8P  Y8b 888P"  d8P  Y8b 
  d88P   888 888 888          888     888  888 888 888  888 888  888 "Y8888b.      88888P Y88888 88888888 888  888       "888 888  888 888  888 88888888 888    88888888 
 d8888888888 888 888          888     888  888 888 888  888 Y88b 888      X88      8888P   Y8888 Y8b.     888 d88P Y88b  d88P 888 d88P 888  888 Y8b.     888    Y8b.     
d88P     888 888 888          888     888  888 888 888  888  "Y88888  88888P'      888P     Y888  "Y8888  88888P"   "Y8888P"  88888P"  888  888  "Y8888  888     "Y8888  
                                                                 888                                                          888                                        
                                                            Y8b d88P                                                          888                                        
                                                             "Y88P"                                                           888   

All Things WebSphere

Concerns and issues relating to all versions of WebSphere Application Server

Tuesday, November 29, 2011

 

Hottest items in the WebSphere Application Server Dynacache Servlet cache



Provided is a DynaCache program that leverages PMI and JMX to output the top 100 templates in the servlet cache in terms of in-memory cache hits. 
You can use this client program to determine which items in the cache are the most popular.

When there are a lot of cache-entries  and consequently templates in the cachespec.xml this tool will give you a good idea of what is hot or not. The utility of this tool decreases when the cache-entry names are not granular. For instance some cachespec.xml's use the single front controller, with a lot of the cache-ids hanging off a usually a single cache-entry. For now the program/tool only looks at the in-memory cache hits and not disk hits. Java src is included in the jar if you want to modify it :-)

Attached jar contains the src and the class files:
http://dl.dropbox.com/u/12872475/Dynacache-WXS/dc-pmi.jar

This program requires the template servlet cache PMI group to be enabled.






























Usage:
C:\WebSphere7\AppServer\java\bin\java -Djava.ext.dirs=C:\WebSphere7\AppServer\runtimes;c:\WebSphere7\AppServer\lib;C:\WebSphere7\AppServer\java\jre\lib;C:\WebSphere7\AppServer\java\jre\lib\ext;C:\WebSphere7\AppServer\lib com.ibm.ws.sample.DynaCachePMIClient localhost 8881-standalone smitaNode01 server1 baseCache
  • Replace C:\WebSphere7\AppServer with your $WAS_HOME &rerun.
  • Program arguments are in orange. 
  • There is also a test.properties that can be modified inside the jar for more granular control, if you do not want to provide arguments.
Output:
host=localhost , port=8881 , connector=SOAP , distributed=false
main: create the adminclient
getAdminClient: hostStr=localhost , portStr=8881
getAdminClient: WasClientPath=C:/WebSphere7/AppServer/profiles/base
*****************************************
DynaCache Automated Tests
Host     : smita.raleigh.ibm.com
Port     : 9081
PMI Port : 8881 connector: SOAP
Cell     : smitaNode01Cell
Node     : smitaNode01
Server   : server1
BaseCacheSize: 2000
Offload to Disk: false
IhsEnabled: true
globalSecurityEnabled: false
IHS Host    : localhost
IHS Port    : 80
Distributed Caching: false
zOSMode: false
*****************************************
Usage: DynaCachePMIClient [ <-distributed|-standalone> ]
Arguments passed in to com.ibm.ws.sample.DynaCachePMIClient
args[0] localhost
args[1] 8881
args[2] -standalone
args[3] smitaNode01
args[4] server1
args[5] baseCache

Found 1
...node:smitaNode01 match: true
...process:server1 match: true
my perf MBean: WebSphere:name=PerfMBean,process=server1,platform=dynamicproxy,node=smitaNode01,version=7.0.0.19,type=Perf,mbeanIdentifier=PerfMBean,cell=smitaNode01Cell,spec=1.0

Get statistics from all cacheModules

stats name=cacheModule.template
    HitsInMemoryCount[21]=23
    HitsOnDiskCount[22]=0
    ExplicitInvalidationCount[23]=0
    LruInvalidationCount[24]=0
    TimeoutInvalidationCount[25]=0
    InMemoryAndDiskCacheEntryCount[26]=4
    RemoteHitCount[27]=0
    MissCount[28]=4
    ClientRequestCount[29]=27
    DistributedRequestCount[30]=0
    ExplicitMemoryInvalidationCount[31]=0
    ExplicitDiskInvalidationCount[32]=0
    LocalExplicitInvalidationCount[34]=0
    RemoteExplicitInvalidationCount[35]=0
    RemoteCreationCount[36]=0

    stats name=/dynacachetests/TimeStamp
        HitsInMemoryCount[21]=11
        HitsOnDiskCount[22]=0
        ExplicitInvalidationCount[23]=0
        LruInvalidationCount[24]=0
        TimeoutInvalidationCount[25]=0
        InMemoryAndDiskCacheEntryCount[26]=2
        RemoteHitCount[27]=0
        MissCount[28]=2
        ClientRequestCount[29]=13
        DistributedRequestCount[30]=0
        ExplicitMemoryInvalidationCount[31]=0
        ExplicitDiskInvalidationCount[32]=0
        LocalExplicitInvalidationCount[34]=0
        RemoteExplicitInvalidationCount[35]=0
        RemoteCreationCount[36]=0

    stats name=/dynacachetests/TimeStamp1
        HitsInMemoryCount[21]=12
        HitsOnDiskCount[22]=0
        ExplicitInvalidationCount[23]=0
        LruInvalidationCount[24]=0
        TimeoutInvalidationCount[25]=0
        InMemoryAndDiskCacheEntryCount[26]=2
        RemoteHitCount[27]=0
        MissCount[28]=2
        ClientRequestCount[29]=14
        DistributedRequestCount[30]=0
        ExplicitMemoryInvalidationCount[31]=0
        ExplicitDiskInvalidationCount[32]=0
        LocalExplicitInvalidationCount[34]=0
        RemoteExplicitInvalidationCount[35]=0
        RemoteCreationCount[36]=0

TOP 100 TEMPLATES IN THE CACHE baseCache
/dynacachetests/TimeStamp1=12
/dynacachetests/TimeStamp=11

Dynacache PMI structure:








Labels:


Wednesday, November 9, 2011

 

How to tell if a response from WebSphere Application Server has been cached


An application that uses Dynacache servlet caching in the past had no indication in the servlet response if data came from the cache or not.

Starting with WAS version 7.0.0.11 in APAR PM01156,  Dynacache adds a header to the response that can be used to determine if the servlet response has been returned from Dynacache. The name of this header is "CACHED_RESPONSE"

An application may need to take different actions depending on  if the data has been cached.
The header CACHED_RESPONSE has been added to the header of the servlet response and set to true when the servlet output is obtained from the cache.

Labels:


 

ApacheCon 2011 Web Technologies in Java EE6 : Servlet 3.0 and JSF 2.0 Whats New ?


Here are the slides from my ApacheCon 2011 talk on web EE technologies JSF 2.0 and Servlet 3.0

http://dl.dropbox.com/u/12872475/Servlet_JSF_apachecon_2011.pdf

Servlet 3.0 is a new specification that is part of the Java EE 6 technologies. This session will introduce you to the new features of Servlet 3.0 and explain how you can leverage them in your applications. The session will focus on two major themes: ease of development, and improving application scalability. This session is intended for Java EE developers, administrators, and architects.

JSF 2.0 is a new specification that is part of the Java EE 6 technologies. This session will introduce you to the new features of JSF 2.0 and explain how you can leverage JSF in your Java EE and Portlet applications. The session will focus on three major themes: ease of development, performance improvements, and open source technology adoption. You will learn how the tools for the Application Developer make developing UI easier, as well as the JSF-Dojo component library. This session is intended for Java EE developers, administrators, and architects.

Labels:


Sunday, November 6, 2011

 

Dynacache Servlet caching cachespec.xml example


Often customers ask me for complicated and non trivial examples of a servlet cache specification using Dyncache servlet caching. I have uploaded one on  github that we use for our testing.

You can copy paste this cachespec.xml in your application's WEB-INF directory to enable servlet caching of your responses in WebSphere Application Server.

Labels:


Thursday, November 3, 2011

 

How to get Contexts & Dependency Injection (JSR 299) running on WebSphere Application Server 7.0.0.x

Please understand that even with these changes you are losing a lot of WAS value-add and integration of Dependency Integration with Java EE resources in WAS i.e. pojo injection in a servlet/EJB or vice versa. IBM cannot help with support calls on WAS 7 when open web beans or JSF 2 is bundled as part of the application.  For dependency injection in WAS we recommend upgrading to WAS 8 which has CDI and JSF2 support baked in.

1. OpenWebBeans (OWB) Download
Register for JIRA and watch OpenWebBeans project here https://issues.apache.org/jira/browse/OWB
Versions https://issues.apache.org/jira/browse/OWB#selectedTab=com.atlassian.jira.plugin.system.project%3Aversions-panel
Latest version     1.1.2    Release Date: 21/Oct/11    OpenWebBeans-1.1.2
Distribution: https://repository.apache.org/content/repositories/releases/org/apache/openwebbeans/openwebbeans-distribution/1.1.2/
Download and unzip https://repository.apache.org/content/repositories/releases/org/apache/openwebbeans/openwebbeans-distribution/1.1.2/openwebbeans-distribution-1.1.2-binary.tar.gz
to C:\WebSphere7\AppServer\temp where C:\WebSphere7\AppServer is my WAS_INSTALL_ROOT
C:\WebSphere7\AppServer\temp was chosen as an arbitrary location for download. You can do this in any directory.
After unzip you should see C:\WebSphere7\AppServer\temp\openwebbeans-distribution-1.1.2

2.  Build a sample that comes with the OWB Distribution
In this scenario I will be building the jsf2sample application.
This examples shows the usage of MyFaces JSF2 + OpenWebBeans .
Before building the application add org.apache.myfaces.webapp.StartupServletContextListener
to the web.xml of your application if you intend to use JSF2.0. This is how the listener stanza should look like

    <listener>
        <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    </listener>

For this to work you will need to add
<profiles>
    <profile>
      <id>apache</id>
      <pluginRepositories>
        <pluginRepository>
          <id>apache.snapshots</id>
          <name>Maven Plugin Snapshots</name>
          <url>http://repository.apache.org/snapshots/</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>apache</activeProfile>
  </activeProfiles>

to your global settings in M2_INSTALL_HOME\conf\settings.xml or  user settings from M2_USER_HOME\.m2\settings.xml . To determine these settings locations type "mvn -X"

You may need to change the pom.xml of the sample application
Replace ../pom.xml in with
https://repository.apache.org/content/repositories/releases/org/apache/openwebbeans/openwebbeans/1.1.2/openwebbeans-1.1.2.pom/pom.xml
You may also need to delete myfaces.version xml element from   org.apache.myfaces.core ...
After building the jsf2sample  CDI you should see C:\WebSphere7\AppServer\temp\openwebbeans-distribution-1.1.2\samples\jsf2sample\target\jsf2sample.war

3.  Configure WAS 7 to use JSF 2.0

Because WAS 7 comes with its own implementation of JSF we have to follow the steps below for the jsf2sample to leverage JSF 2.0 myfaces correctly.

3.1 Extract
commons-beanutils-1.8.3.jar,
commons-codec-1.3.jar,
commons-collections-3.2.jar,
commons-digester-1.8.jar,
commons-logging-1.1.1.jar,
myfaces-api-2.0.3.jar,
myfaces-impl-2.0.3.jar from the WEB-INF/lib dir of the application to a common place on your server where you want to store them.
    Say  ${WAS_INSTALL_ROOT}\optionalLibraries\Apache\MyFaces..

3.2 Delete the 7 jar files listed above from the WEB-INF/lib dir of the app
3.3 Open up the myfaces-impl-2.0.x.jar file and remove the files in the META-INF\services\ directory.
3.4 Install js2sample.war  application on WAS 7

3.5 Configuring WAS v7 shared libraries
Next, we configure the JAR files as Isolated Shared libraries.

Add the following to Environment > Shared Libraries > New

Name
OWB

Classpath
${WAS_INSTALL_ROOT}/optionalLibraries/IBM/JSFProviders/WebSphere-MyFaces20-annotation-provider.jar  (this is needed and only available on & after 7.0.0.19)
${WAS_INSTALL_ROOT}/optionalLibraries/Apache/owb/commons-beanutils-1.8.3.jar
${WAS_INSTALL_ROOT}/optionalLibraries/Apache/owb/commons-codec-1.3.jar
${WAS_INSTALL_ROOT}/optionalLibraries/Apache/owb/commons-collections-3.2.jar
${WAS_INSTALL_ROOT}/optionalLibraries/Apache/owb/commons-digester-1.8.jar
${WAS_INSTALL_ROOT}/optionalLibraries/Apache/owb/commons-logging-1.1.1.jar
${WAS_INSTALL_ROOT}/optionalLibraries/Apache/owb/myfaces-api-2.0.3.jar
${WAS_INSTALL_ROOT}/optionalLibraries/Apache/owb/myfaces-impl-2.0.3.jar

Click on the check box for ‘Use an isolated class loader for this shared library’. Click Apply and Save.

3.6 Associate the shared library with your
Go to Enterprise Applications > jsf2sample_war > Shared library references and add the OWB shared library reference
to both web module

3.7 If you want at this point you can enable trace for *=info:org.apache.webbeans*=all to get more information about the OWB
and WAS interaction

3.8 Restart the application server

4. Confirmation
After the server has started look for these messages to validate that your CDI application has started
[11/2/11 15:53:57:141 EDT] 00000008 WebContainerL 2 org.apache.webbeans.web.lifecycle.WebContainerLifecycle debug Deploying scanned beans.
[11/2/11 15:53:57:250 EDT] 00000008 BeansDeployer 2 org.apache.webbeans.config.BeansDeployer debug Found Managed Bean with class name : [org.apache.webbeans.jsf2.HelloJsfBean]
[11/2/11 15:53:57:391 EDT] 00000008 WebContainerL I org.apache.webbeans.web.lifecycle.WebContainerLifecycle info OpenWebBeans Container has started, it took [313] ms.
[11/2/11 15:53:59:860 EDT] 00000008 servlet       I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [jsf2sample_war] [/jsf2sample] [Faces Servlet]: Initialization successful.

5. Final Validation

Hit
   - http://localhost:9081/jsf2sample/counter.xhtml
     Shows the AJAX functionality of JSF2 specification.

   - http://localhost:9081/jsf2sample/conversation.xhtml
     Show the usage of JSF conversations.

where 9081 is the WC_defaulthost port.

Labels:


Archives

December 2006   September 2008   January 2009   February 2009   March 2009   September 2009   October 2009   November 2009   December 2009   January 2010   February 2010   March 2010   April 2010   October 2010   January 2011   February 2011   April 2011   May 2011   June 2011   July 2011   August 2011   September 2011   October 2011   November 2011   December 2011   January 2012   February 2012   March 2012   April 2012   May 2012   June 2012   July 2012   August 2012   September 2012   October 2012   November 2012   January 2013   May 2013   June 2013   July 2013   September 2013   October 2013   June 2014   August 2014  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]