How to detect deadlocks, session and other jmx-console goodies

Link to Console

http://haldevweb01.hq.halw.com/jmx-console/
haldevjbsXX.hq.halw.com/jmx-console/
admin/admin

List of sessions:

jboss.web
host=localhost,path=/,type=Manager
listSessionIds

Looking for a thread deadlock, how to

jboss.system
type=ServerInfo

listThreadCpuUtilization

Look for a thread taking a huge amount of CPU

Such as ajp-haldevjbs04%2F10.194.50.211-8009-3
and go back to type=ServerInfo

listThreadDump
and then search for thread found previously

Thread deadlock, caused 100% CPU

Refer: http://halpjira01:8080/browse/WITG-100 Guillaume fixed the issue
1550     2d 09h     guillaume     /trunk/     Reintegrate WITG-100_100percentCPUHashmap. Should fix 100% cpu issue on prod. Fix WITG-100.

Don saw this problem happen eventually across all of our servers.

Changed this:
this.alaskaCruiseTourMap = new HashMap<String, AlaskaCruiseTour>();

To this:
this.alaskaCruiseTourMap = new ConcurrentHashMap<String, AlaskaCruiseTour>();

Example to run a jUnit test with Maven

How to run a specific test:

cd ~/workspace/safenet-credit-card-encryption2/hal-parent/hal-ejb
mvn -Dtest=WebCryptographyITCase test

How to run all tests:

cd ~/workspace/safenet-credit-card-encryption2/hal-parent/hal-ejb
mvn test

Create a SpringApplicationContext service for legacy code

Guillaume applied changes to "Delete WebCryptography. Have all code use the EncryptionService instead. Also create a SpringApplicationContext service so that legacy code (where instances are not created by spring) can access the spring application context and lookup beans."

hal-ejb/src/main/java/com/hal/sf/service/SpringApplicationContext.java

SpringApplicationContext.java

Code using the above legacy class, need the following:

Declarations

import com.hal.sf.service.SpringApplicationContext;
import com.hollandamerica.common.encryption.EncryptionService;
private EncryptionService encryptionService;

Inside Construction

encryptionService =(EncryptionService) SpringApplicationContext.getBean("encryptionService");

Sample Code Usage

String newCCN = encryptionService.decrypt(encrypted);
String previousCCN = encryptionService.decrypt(previous);

How to make your VM think it is www.hollandamerica.com

From: Mario Hartman [mailto:mhartman@hexacta.com]
Sent: Tuesday, May 29, 2012 10:44 AM
To: Ruckman, Maurice (HAL); Augustine, Anila (HAL); Mirza, Masood (HAL Contractor); Fillman, Eric (HAL)
Cc: Sankar, Kousalya (HAL); Brace, Jannette (HAL Contractor); Florencia Castro; Thompson, Sonya (HAL); Daniela Greca
Subject: RE: Sample JSP with IFrame to Bazaar Voice on the network server

Hi,
These are the changes I made to trick my server into thinking that we are under the domain www.hollandamerica.com

1 - Go to /etc/httpd/conf/httpd.conf file and change your virtual host in this way

### Section 3: Virtual Hosts
NameVirtualHost www.hollandamerica.com:80
<VirtualHost www.hollandamerica.com:80>
DocumentRoot "/home/jboss1/HAL/halwebsite"
ServerName www.hollandamerica.com:80
ErrorLog logs/error.log
JkMountFile conf/uriworkermap.properties
SSLEngine off
</VirtualHost>

NameVirtualHost www.hollandamerica.com:443
<VirtualHost www.hollandamerica.com:443>
DocumentRoot "/home/jboss1/HAL/halwebsite"
ServerName www.hollandamerica.com:443
ErrorLog logs/ssl_error.log
JkMountFile conf/uriworkermap.properties
#CustomLog logs/ssl_access.logcombined
SSLEngine on
SSLCertificateFile "/etc/httpd/conf/ssl/hq.halw.com.crt"
SSLCertificateKeyFile "/etc/httpd/conf/ssl/hollandamerica.com.key"
</VirtualHost>

Also in this file change your server name to: ServerName www.hollandamerica.com.com:80

2 - Change the following line in your hosts file (/etc/hosts) to looks like the following line
127.0.0.1             www.hollandamerica.com localhost

3 - Change your /etc/sysconfig/network file  and set the hostname as:
HOSTNAME=www.hollandamerica.com

After that, restart your network service, restart your apache instance and your jboss server.

If everything  went well, you will be able to access your local server using www.hollandamerica.com in your webbrowser.
If anyone think that we can reach the same goal with less changes or with a better configuration please let me know.

Thanks

Mario

Mario Andres Hartman
Phone 54+343+423 6141
San Martín 902, E3100AAT, Paraná, Argentina
Think Green - Please do not print this email unless you really need to

Fixing serialization Errors – Example

Refer: com/hollandamerica/checkin/action/EdocsHelper.java

Please see the following code stubs for example coding changes required:

import com.halw.util.SerializableByteArrayOutputStream;

* <li>mlr 03-12.2012
* <ul>
* <li>Marking several class variables transient in attempt to fix serialization
* error when converting to JBoss with session persistance.</li>
* </ul>
* </li>

private transient boolean checkinComplete = false;

from:
private transient ByteArrayOutputStream baosFinal = new ByteArrayOutputStream();

to:
private transient SerializableByteArrayOutputStream baosFinal = new SerializableByteArrayOutputStream();

New pattern to toggle features in JSP

From: Thompson, Sonya (HAL)
Sent: Thursday, May 24, 2012 9:19 AM
To: Ruckman, Maurice (HAL); Fillman, Eric (HAL); Phatak, Sheetal (HAL); Klein, Brian (HAL); Bojja, Sridhar (HAL Contractor)
Cc: Augustine, Anila (HAL)
Subject: RE: New feature to toggle features in JSP

I've also created a FeatureToggleHelper.java with getFeatureToggle() and getFeatureToggleAsString() methods.
This helper knows where the featureToggles.xml file is located & appends the "toggles.{environment}." To the front of whatever key is passed in.
However, this will not be avail until I merge it into 12.23

From: Ruckman, Maurice (HAL)
Sent: Thursday, May 24, 2012 7:31 AM
To: Fillman, Eric (HAL); Thompson, Sonya (HAL); Phatak, Sheetal (HAL); Klein, Brian (HAL); Bojja, Sridhar (HAL Contractor)
Cc: Augustine, Anila (HAL)
Subject: RE: New feature to toggle features in JSP

To supplement this effort, here is an example of how to access our XML in the back-end Java code to drive logic:
Refer: hal-ejb/src/main/java/com/hal/sf/olci/page/AcceptPrintTermsPage.java

if ( StaticXmlDataList.getInstance().getStaticXmlFileMap().get(
"web.copy.olci.acceptTerms_logic.xml" ).get(
"page.EUTerms." + guestCountry ) != null )
{
setEuropeanUnion( true );
}
else
{
setEuropeanUnion( false );
}
From: Fillman, Eric (HAL)
Sent: Friday, May 18, 2012 4:09 PM
To: Thompson, Sonya (HAL); Phatak, Sheetal (HAL); Ruckman, Maurice (HAL); Klein, Brian (HAL); Bojja, Sridhar (HAL Contractor)
Cc: Augustine, Anila (HAL)
Subject: New feature to toggle features in JSP

Hi.

Sonya and I put together a little process that will allow you to control when a new feature or new code will be used.
It starts with a  file in Teamsite called featureToggles.xml, and it's in the web/copy/features directory.

Here's a very condensed sample of what the file looks like:

<toggles>

<!-- Use the following section to control how features will be enabled in the non-production environments -->

<nonProd>
<displayGroupExcursions><![CDATA[true]]></displayGroupExcursions>
</nonProd>

<!-- Use the following section to control how features will be enabled in the PRODUCTION environment -->

<prod>
<displayGroupExcursions><![CDATA[false]]></displayGroupExcursions>
</prod>

</toggles>

Essentially there are two sections - <nonProd> and <prod>.  <prod> would be used for production, <nonProd> will be used for everything else.  Within each you define an element and indicate whether that feature will be used/displayed/etc. within the JSP.  In the example above, <displayGroupExcursions> can be used to control the group excursion functionality.  It's currently set to true for nonProd so group excursion features will display there, but false for prod.

This way we can push code to dev, test, and prod, and have the features available in dev and test, but not prod.  Once the OK is given for prod, we just need to change the XML and push that through Teamsite.  If we need to shut a feature off for some reason in prod, we can do that too.

To use the featureToggles.xml, you just need to include a reference to it in the JSP like we do for all the static content XML files:

<s:set var="featureMap" value="#application.staticXmlDataList.staticXmlFileMap['web.copy.features.featureToggles.xml']"/>

Then in the JSP code, add an if statement to check the value of your feature name:

<s:if test="#featureMap['toggles.' + featureEnv + '.displayGroupExcursions'] == 'true'">
<!-- These are Group Excursions!-->
<s:if test="%{!getShxGroupTourBizList().isEmpty()}">

// Do something here

</s:if>
</s:if>

Notice the featureEnv variable in the highlighted line above.  We added a method to the BaseAction class called getFeatureEnv() that will return a string value of either nonProd or prod depending on the environment variable set in the System Properties.  If environment is prd, it returns prod, otherwise it returns nonProd.  As long as your JSP is called from an Action that extends BaseAction (which I think everything is the new flows do), your JSP should have access to featureEnv.

You should also be capable of accessing the XML file directly from an action if you want to control which methods are being called from a service or something, but we didn't get that far with it.

The code is in 12.21-RC, so it should go to prod next week.

Let me or Sonya know if you have any questions.

Thanks.

Eric

JCE cannot authenticate the provider IngrianProvider

Could not get Safenet working and kept getting the following error, one solution found was to explode the EAR file.

JCE cannot authenticate the provider IngrianProvider

Caused by: java.util.jar.JarException:
Cannot parse jar:file:/home/jboss1/programs/jboss-eap-5.1/jboss-as/server/haldev-vm-template-safenet/deploy/hal-ear-1.0-SNAPSHOT.ear!/hal-web-1.0-SNAPSHOT.war

Refer: https://access.redhat.com/knowledge/solutions/34813