"com.sun.xml.ws.message.saaj.SAAJHeader cannot be cast to class com.sun.xml.ws.security.opt.impl.outgoing.SecurityHeader" when calling protected SOAP service

280 views
Skip to first unread message

J2eeInside J2eeInside

unread,
Apr 21, 2021, 3:03:25 AM4/21/21
to Payara Forum

HI all,

I just generated (via wsimport tool) a Java client code, in order to call protected SOAP Web service. However, I am stuck with this error for a days, I have no idea what to do.
Can anyone help ?

Payara community, 5.2020.5
Here is stack trace,

javax.xml.ws.WebServiceException: java.lang.ClassCastException: class com.sun.xml.ws.message.saaj.SAAJHeader cannot be cast to class com.sun.xml.ws.security.opt.impl.outgoing.SecurityHeader (com.sun.xml.ws.message.saaj.SAAJHeader and com.sun.xml.ws.security.opt.impl.outgoing.SecurityHeader are in unnamed module of loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader @360e0886) at com.sun.xml.wss.jaxws.impl.SecurityClientTube.processRequest(SecurityClientTube.java:222) at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1106) at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1020) at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:989) at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:847) at com.sun.xml.ws.client.Stub.process(Stub.java:433) at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:161) at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78) at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:62) at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:131) at com.sun.proxy.$Proxy424.preuzmiPromenePodatakaOPrivrednimSubjektima(Unknown Source) at apr_ws_update_timer.PreuzmiPPOPrivSubjektima.preuzmiPromene(PreuzmiPPOPrivSubjektima.java:76) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:588) at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:408) at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4817) at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:665) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:834) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:615) at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163) at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundTimeout(SystemInterceptorProxy.java:145) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:888) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:833) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:615) at org.jboss.weld.module.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:81) at org.jboss.weld.module.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:888) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:833) at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:375) at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4789) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4777) at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:4027) at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1208) at com.sun.ejb.containers.EJBTimerService.access$000(EJBTimerService.java:96) at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:1927) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)

steve.millidge

unread,
Apr 21, 2021, 5:47:38 AM4/21/21
to Payara Forum
There's not much to go on here and you would need to create an executable test case for anybody to provide much insight.

However, these sort of errors are typically because the same class is being loaded by two different classloaders. I would check that your deployment does not also include metro or other classes which should be loaded from the server.

Steve


J2eeInside J2eeInside

unread,
Apr 21, 2021, 6:10:15 AM4/21/21
to Payara Forum
Hi @steve, and thank for reply,


" I would check that your deployment does not also include metro or other classes which should be loaded from the server. "
Can you tell me how to check it?
What is exactly metro or other classes to which I should pay attention ?

In fact, I just packaged wsimport's generated classes in the EJB .JAR file, and deployed that .jar to the Payara.

The only specific stuff I added to the generated source, is two custom classes, one of those
implements javax.xml.ws.handler.soap.SOAPHandler<SOAPMessageContext>
     and another one 
implements javax.xml.ws.handler.HandlerResolver

That is all.
Any suggestion?

J2eeInside J2eeInside

unread,
Apr 21, 2021, 6:25:11 AM4/21/21
to Payara Forum
And just to add, I am calling web service from @Singleton annotated class, in  this way:

@javax.ejb.Singleton
public class MyBean {
   @javax.ejb.Schedule(minute = "*/10", hour = "*")
   public void wsCall() {
       // web service call goes here
  }

--
You received this message because you are subscribed to a topic in the Google Groups "Payara Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/payara-forum/rK5TAVrkBNE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to payara-forum...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/payara-forum/7fbec834-8321-48c8-8ffa-675181e7d710n%40googlegroups.com.

Ondro Mihályi

unread,
Apr 25, 2021, 6:16:27 AM4/25/21
to J2eeInside J2eeInside, Payara Forum
Hi,

It's best if you can share your project, it's really hard to say what's going on just from the stacktrace you posted.

Ondro

Dňa st 21. 4. 2021, 12:25 J2eeInside J2eeInside <j2eei...@gmail.com> napísal(a):
You received this message because you are subscribed to the Google Groups "Payara Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to payara-forum...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/payara-forum/CAK-aFFaBDAfE4VuRCvEX65jkQaXmZQs-VhutKXj8q5n3UH6bjA%40mail.gmail.com.

J2eeInside J2eeInside

unread,
Apr 25, 2021, 7:02:14 AM4/25/21
to Ondro Mihályi, Payara Forum
Hi @Ondro,
Of course I have reproducible test application, but in order to run app (which is actually one EJB Timer), the Web service provider gave me two .cert files (which should be imported in the JDK and Payara cacerts).
The problem is -  I would not like for those sertificates to be publicly available.

it would be best to have some protected service that is publicly available, but I can't find any.
Do you know such one service?
Reply all
Reply to author
Forward
0 new messages