[jboss-user] [EJB 3.0] - Re: Bug: inject WebServiceContext at AroundInvoke

MrTed do-not-reply at jboss.com
Wed Jul 15 04:14:12 EDT 2009


Hi, I had the same problem using JBoss 4.2.3 and JBossWS 3.1.1
I have resolved it via such work around placed in my Interceptor:

  |         /**
  | 	 * Returns true if current context has a webservice context available. This
  | 	 * method is a workaround for not working injection of the WebServiceContext
  | 	 * via Resource annotation.
  | 	 *
  | 	 * @param ctx InvocationContext
  | 	 * @return true if WebServiceContext is available, false otherwise.
  | 	 */
  | 	private boolean isWebServiceContext(InvocationContext ctx) {
  | 		try {
  | 			WebServiceContext wsc = null;
  | 			Field wrapped = ctx.getClass().getDeclaredField("wrapped");
  | 			if (wrapped != null) {
  | 				wrapped.setAccessible(true);
  | 				Object sbctx = wrapped.get(ctx);
  | 				if (sbctx != null) {
  | 					Field ctxField = sbctx.getClass().getDeclaredField("ctx");
  | 					if (ctxField != null) {
  | 						ctxField.setAccessible(true);
  | 						Object context = ctxField.get(sbctx);
  | 						if (context != null) {
  | 							Field webServiceCtx = context.getClass().getDeclaredField("webServiceContext");
  | 							if (webServiceCtx != null) {
  | 								webServiceCtx.setAccessible(true);
  | 								wsc = (WebServiceContext) webServiceCtx.get(context);
  | 								return wsc != null;
  | 							}
  | 						}
  | 					}
  | 				}
  | 			}
  | 		} catch (NoSuchFieldException e) {
  | 			// silent
  | 		} catch (IllegalArgumentException e) {
  | 			// silent
  | 		} catch (IllegalAccessException e) {
  | 			// silent
  | 		}
  | 		return false;
  | 	}
  | 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4243663#4243663

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4243663



More information about the jboss-user mailing list