Skip to main content

mustang build 96 causes ClassCastException for soap message!

31 replies [Last post]
navinkjha
Offline
Joined: 2004-12-28
Points: 0

I have Java client that connects to .Net web services. I was working fine until mustang build 95. Something in build 96 broke it. Here is the error I get:

java.lang.ClassCastException: com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl cannot be cast to com.sun.xml.messaging.saaj.soap.MessageImpl

Any ideas?
-Navin

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
praveen16
Offline
Joined: 2006-11-27
Points: 0

I am also facing the same problem of class cast exception:
com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl cannot be cast to com.sun.xml.messaging.
saaj.soap.MessageImpl
at com.sun.xml.rpc.client.dii.CallInvokerImpl._postSendingHook(CallInvok
erImpl.java:305)

I've tried saaj jars downloaded from the URL mentioned in previous replies. But still the problem is there.
My configuration is:
(1) jwsdp-2.0
(2) jboss 4.0.5.GA
(3) Java 1.6

Please help!
Thanx

navinkjha
Offline
Joined: 2004-12-28
Points: 0

Just get the latest saaj jars from saaj.dev.java.net. That should do it.
-Navin

rituraj_tiwari
Offline
Joined: 2005-07-06
Points: 0

I have tried everything from getting the latest SAAJ jars to updating my JAX-RPC 1.6 libs on Netbeans. This thing does not seem to go away.

When I revert my JRE to JRE 5, I have a different problem: It is unable to find SAAJMetaFactoryImpl class.

I am surprised that something so broken is publicly released.

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Well, but as you can see in other people's posting, this was fixed in time.

I suspect you have a slightly different problem...

rituraj_tiwari
Offline
Joined: 2005-07-06
Points: 0

Kosuke,
You are probably right. I tried running my WS client code from Junit (as a Java application) and it works fine. It only seems to break with the class cast exception when running within an applet.

This is driving me nuts. I have tried everything I can to make sure I am using the correct SAAJ jars from my applet including putting the SAAJ jars in jre/ext/lib. Nothing seems to work.

One piece of detail: The applet needs to connect outside the sandbox, so I am signing all jars: my own code and all JAX-RPC jars.

Any help will be greatly appreciated.

I have attached screenshots of classloaders and the stack trace to the SAAJ issue I have opened for this: https://saaj.dev.java.net/issues/show_bug.cgi?id=19

Message was edited by: rituraj_tiwari

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Try using a tool like http://which4j.dev.java.net/ to find out where you are actually loading SAAJ from.

Beyond that, I think you probably need to attach a debugger and take it from there.

rituraj_tiwari
Offline
Joined: 2005-07-06
Points: 0

Kohsuke,
An update on this issue:
This is being tracked as a SAAJ issue at this time: https://saaj.dev.java.net/issues/show_bug.cgi?id=19

My fear is that there may be a fundamental issue around using SAAJ in applets. When using JRE 6, SAAJ's overrides don't have effect and I end up with the class cast exception.

When reverting to JRE 5 and repackaging all SAAJ jar contents in my applet's jar file, SAAJ code still cannot use the SPI to discover the meta factory implementation.

Are there any limitations on trusted applets' use of META-INF/services?

kohsuke
Offline
Joined: 2003-06-09
Points: 0

We'll see what the SAAJ folks need to say.

AFAIK, SAAJ in Mustang is properly package renamed, so it shouldn't collide with your copy of SAAJ in the applet. But I'd really wait for SAAJ guys to chime in.

rituraj_tiwari
Offline
Joined: 2005-07-06
Points: 0

Kohsuke,
I am beginning to think that there is some fundamental issue with applets being able to get at definitions in a jar's meta inf. (I am using signed applets).

While SAAJ folks were trying to figure out issue#19, I went ahead and replaced my web service with a vanilla servlet that uses JavaMail MimeMultipart to receive POST messages with multipart payload. In my applet I am constructing these messages using the same class: MimeMultipart. All attempts to create a message in my applet fails. It says is cannot find the data content handler for text/plain. Now this DCH is defined in a mailcap file in mail.jar. This file is located in the meta-inf of the mail.jar file.

Attempts to set this in code also fail.
// add handlers for main MIME types
MailcapCommandMap mc = (MailcapCommandMap)CommandMap.getDefaultCommandMap();
mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
CommandMap.setDefaultCommandMap(mc);

Placing all these jars in JRE/lib/ext does not help either.

Have you heard of or encountered something like this?

Thanks.
-Raj

kohsuke
Offline
Joined: 2003-06-09
Points: 0

I'm sorry, but I never really wrote any applet. You might want to spend some time looking for how classloading and resource loading works in applet.

rituraj_tiwari
Offline
Joined: 2005-07-06
Points: 0

Kohsuke,
Thanks for your time on this issue. I resorted to hand-coding multipart message creation, essentially aborting use of SAAJ or any other library that relies on META-INF contents for configuration. That finally got things working.

I have posted this dilemma in the java plugin forum: http://forums.java.net/jive/thread.jspa?threadID=24195. Will look for answers there.

-Raj

rbervini
Offline
Joined: 2005-04-21
Points: 0

I have a very similar problem. I have developed the client as a standalone class and works properly but if I put the same code in a jsp (running with Tomcat) I get:

com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl cannot be cast to com.sun.xml.messaging.saaj.soap.MessageImpl

can anybody help me?
Thank you
-Rasael

Message was edited by: rbervini

kohsuke
Offline
Joined: 2003-06-09
Points: 0

You need the newer SAAJ jar, as this thread discusses.

pekarna
Offline
Joined: 2008-02-28
Points: 0

For the case anyone had the same problem with NetBeans 6.0.1:

Web service *client* generated by WSimport and built in NetBeans can throw the ClassCastException. That is also caused by obsolete SAAJ library. See
http://www.netbeans.org/issues/show_bug.cgi?id=128736 .

To get the client working, put snapshot version of SAAJ to ".netbeans\6.0\modules\ext\jaxrpc16\saaj-impl.jar" and rebuild it.

For SAAJ library developers: IMHO this bug deserves increase of minor version number. NetBeans would bundle new version of SAAJ library and that would spare me two days of bug-hunting. Thanks.

danielmk
Offline
Joined: 2006-08-31
Points: 0

Using web service on Sun App server 8.2
server: jdk 1.5.0_06
client:Mustang, build 97

Here is stack trace:

Exception in thread "main" java.lang.ClassCastException: com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl cannot be cast to com.sun.xml.messaging.saaj.soap.MessageImpl
at com.sun.xml.rpc.client.StubBase._postSendingHook(StubBase.java:231)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:324)
at cz.nempodlesi.ikis.opm.ws.WSProcedureManagerSEI_Stub.getTimeZone(WSProcedureManagerSEI_Stub.java:120)
at cz.nempodlesi.ikis.opm.WebServicesApiProcedureManager.getTimeZone(WebServicesApiProcedureManager.java:119)
at cz.nempodlesi.ikis.app.CIkisApplication.initializeEnvironment(CIkisApplication.java:152)
at cz.nempodlesi.ikis.app.CIkisApplication.main(CIkisApplication.java:205)

navinkjha
Offline
Joined: 2004-12-28
Points: 0

Guys,

Any idea on the timetable for a fix of this bug ? I am getting a little anxious :-)

-Navin

kohsuke
Offline
Joined: 2003-06-09
Points: 0

I thought this was already fixed. If not, it's a big deal.

navinkjha
Offline
Joined: 2004-12-28
Points: 0

As of mustang build 102, it is not fixed. I am very worried.

kohsuke
Offline
Joined: 2003-06-09
Points: 0

I asked around, and it looks like the plan is to release another version of SAAJ that you can drop in.

navinkjha
Offline
Joined: 2004-12-28
Points: 0

So If I understand this correctly, I should wait for JWSDP release and then use the SAAJ library from there ?

kohsuke
Offline
Joined: 2003-06-09
Points: 0

I believe the SAAJ release will be available standalone.
JWSDP is EOLed. See http://java.sun.com/webservices/jwsdp/index.jsp

navinkjha
Offline
Joined: 2004-12-28
Points: 0

I did download glassfish and couldn't find the libraries saaj-api.jar and saaj-impl.jar. Have these been renamed in glassfish ?

All of this works fine in JSE 5.0 and was broken in mustang build 96. To me this indicates libraries in mustang build 96 overrides the SAAJ libraries I provide with the client.

kohsuke
Offline
Joined: 2003-06-09
Points: 0

No, I'm saying you should look for a new release of the standalone SAAJ RI at http://saaj.dev.java.net/

If you can ping the owners, that would be great.

navinkjha
Offline
Joined: 2004-12-28
Points: 0

I'll definitely ping them.

Again may be this is a dumb question but why does the SAAJ library work with JSE 5.0 but not with Mustang ?That points to Mustang build rather than SAAJ.

Message was edited by: navinkjha

navinkjha
Offline
Joined: 2004-12-28
Points: 0

kohsuke,

Good news! I took the latest nighly build from the saaj dev site and dropped that in and it works! It looked like you checked in the version, thanks a lot!

Now I just need to find out the latest stable build that works.

Thank again!
-Navin

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Right. I believe they haven't released such a version yet. That's why I'm suggesting to contact the project owner.

navinkjha
Offline
Joined: 2004-12-28
Points: 0

Ok, so I'll ping the owner. Is there is a bug number I could refer to, when I get in touch with the person ?

One more thing, it is not clear who the owner is. I see you listed in the owner(s) list on:
https://java-ws-xml.dev.java.net

-Navin

Message was edited by: navinkjha

kohsuke
Offline
Joined: 2003-06-09
Points: 0

You can refer to this thread and also mention my name.

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Can you post the stack trace? This is likely a very high-priority bug and needs urgent attention. We need more details so that we can fix this in time before Mustang ships.

Please send us details.

navinkjha
Offline
Joined: 2004-12-28
Points: 0

here you go, let me know if you need more information:
java.lang.ClassCastException: com.sun.xml.internal.messaging.saaj.soap.ver1_1.Me
ssage1_1Impl cannot be cast to com.sun.xml.messaging.saaj.soap.MessageImpl
at com.sun.xml.rpc.client.StubBase._postSendingHook(StubBase.java:231)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:324
)
at org.ap.dimms.ws.security.SecurityManagerWebServiceSoap_Stub.logon(Sec
urityManagerWebServiceSoap_Stub.java:70)
at org.ap.pes.util.AuthenticateListener.actionPerformed(AuthenticateList
ener.java:75)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicRootPaneUI$Actions.actionPerformed(Unknow
n Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.KeyboardManager.fireBinding(Unknown Source)
at javax.swing.KeyboardManager.fireKeyboardAction(Unknown Source)
at javax.swing.JComponent.processKeyBindingsForAllComponents(Unknown Sou
rce)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)

at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Sour
ce)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Sour
ce)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.Dialog$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Message was edited by: navinkjha

jitu
Offline
Joined: 2003-06-14
Points: 0

What's your classpath ? Do you have SAAJ jars in the classpath and where are you picking them ?