Pages

Monday, July 2, 2012

JBoss 6.0.0 java.lang.ClassCastException: javax.naming.Reference cannot be cast to

Error: JBoss 6.0.0 java.lang.ClassCastException: javax.naming.Reference cannot be cast to com.xxx.xx.xxx.java

I am using maven3 to remotely run the JUnit based regression test on JBoss 6.0.0. While running a regression test for a Stateless Entity Persistence Bean on JBoss 6.0.0, I encountered the following error:
--
java.lang.ClassCastException: javax.naming.Reference cannot be cast to com.pfmclient.glt.GLT
    at com.pfmclient.helper.EJBSupport.getGLT(EJBSupport.java:327)
--

Initially I thought that it means I don't have the ObjectFactory class on my client ClassPath. Thus throwing this error. However, I did have the Object Factory on my client classpath. I had spent hours then I found a solution that fixed the problem.

Fix:
Basically, I needed to include jbossall-client jar in the pom.xml as maven dependency for my project. However, the easiest and correct way to do this in JBoss 6.0.0 is to add the correct maven co-ordidnates for jboss-as-client pom. Add the following dependency to your pom.xml

<dependency>
        <groupId>org.jboss.jbossas</groupId>
        <artifactId>jboss-as-client</artifactId>
        <version>6.0.0.Final</version>
        <type>pom</type>
</dependency>

Please remember this is a fix for you if you use Maven 3 and JBoss 6.0.0

The above Maven artifact dependency will include all the necessary JBoss specific classes and even Java EE API classes required for JBoss 6.0.0.

Reference: 

 

Wednesday, February 1, 2012

JBoss 4.2.2 NoSuchMethodError CommonMessageContext cleanupAttachments

Getting error in your JBoss 4.2.2 for Web service: NoSuchMethodError

JBoss 4.2.2 NoSuchMethodError CommonMessageContext cleanupAttachments

I was getting a NoSuchMethodError in my JBoss 4.2.2 while trying to invoke my web service. I did not find any relevant information for this on google search. So decided to add this post once I find the solution. 

There was nothing wrong with my code. It was happening due to mismatch between jbossws jars while we had upgraded our JBoss ESB to 4.7 version.

The complete stack trace is as given below:
------------------------------------------------------------------------------------------------
java.lang.NoSuchMethodError: org.jboss.ws.core.CommonMessageContext.cleanupAttachments(Lorg/jboss/ws/core/CommonMessageContext;)V
   at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:341)
    at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)
    at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)
    at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    at java.lang.Thread.run(Thread.java:662)
-------------------------------------------------------------------------------------------------------

FIX
To fix this, you will need to get the latest for JBoss 4.2.x (or whatever version you have) of these jars jbossws-client.jar and jbossws-core.jar from the JBoss Website
  • I had to download the complete jboss-4.2.3.GA.zip  from this download link
  • Unpack the jboss-4.2.3.GA.zip to a temp location
  • You will find the jbossws-client.jar in jboss-4.2.3.GA\client\ folder
  • You will find other jbossws specific jars in this above folder too that you could think of using/upgrading to.
  • You will find the jbossws-core.jar in jboss-4.2.3.GA\server\default\deploy\jbossws.sar\ folder
  • copy the "jbossws-client.jar" to this location: {JBOSS_HOME}\client\ folder
  • copy the "jbossws-core.jar" to this location of your esb server: {JBOSS_HOME}\server\{your_server}\deploy\jbossws.sar\ folder 
  • Then restart your JBoss server 
This should fix your issue. Hope it helps someone..
 

Thursday, January 26, 2012

Google Charts not displayed in IE9

Google Charts not displayed in IE9 / Google Charts not rendered in IE9 / IE9 is not showing the Google Charts

Google charts are displayed correctly in Firefox and Chrome. But when I open the same page in Internet Explorer 9 (IE9), it shows blank area instead. IE9 does not throw any error either.

Bug:
We usually load the packages in the page before drawing the cart. So check out the package that you are using. If you are using "areachart" or "piechart" then this is the issue. These packages have known IE9 compatibility issues.

Your existing code may look something like this:

google.load("visualization", "1", {packages:["piechart"]});
google.setOnLoadCallback(drawChart);
....
.....
chart.draw(data, {width: 400, height: 240, is3D: true, legend: 'right', legendFontSize: 10, colourArray});

Fix:
change your package to "corechart" and your chart.draw parameters will also change as follows;

google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
....
.....
chart.draw(data, {chartArea:{left:20},width: 400, height:240, is3D: true, legend: 'right',title:'Portfolio %', pieSliceText: 'none', legendFontSize: 10, colourArray});


The new charts available in this "corechart" package are compatible with IE9, even in standard
mode of IE9. The older charts ( available in "areachart" and "piechart" are using VML in IE9) - it seems that - are not supported anymore. 

Changing the package this way should fix your issue. It will now correctly show your Google Chart in IE9.

Reference:

Thursday, September 22, 2011

How to turn on the SSL Debugging in JBoss


How to turn on the SSL Debugging in JBoss

You need to add this to your JAVA_OPTIONS in your run.bat. Or if you have a batch file that does environment before running the run.bat batch file then you can add this config setting to your jboss startup batch file:

REM to turn ON the SSL debugging in JBoss
set JAVA_OPTS=%JAVA_OPTS% -Djavax.net.debug=ssl:handshake:verbose:keymanager:trustmanager -Djava.security.debug=access:stack

this will turn on the ssl debugging on ssl handshake process and will be verbose in telling which keymanager and trustmanager will be used.

if you want all debugging information on start up then you can use following config setting:
 

set JAVA_OPTS=%JAVA_OPTS% -Djavax.net.debug=all -Djava.security.debug=access:stack

The above commands will give you more information to be able to diagnose the error.


How to explicitly specify keystore and truststore in JAVA_OPTIONS in JBoss


You can explicitly specify the keystore and truststore with -D option in JBoss. Please see the configuration settings below:


REM to explicitly set the keystore and truststore
set JAVA_OPTS=%JAVA_OPTS% -Djavax.net.ssl.trustStore=C:/Java/jboss-4.2.2.GA/server/{your_server_instance}/conf/server.truststore -Djavax.net.ssl.trustStorePassword=[your_password] -Djavax.net.ssl.keyStore=C:/Java/jboss-4.2.2.GA/server/{your_server_instance}/conf/server.keystore -Djavax.net.ssl.keyStorePassword=[your_password]