Search in sources :

Example 6 with UnmarshalException

use of java.rmi.UnmarshalException in project Payara by payara.

the class EjbContainerPostHandler method handleRequest.

@Override
public boolean handleRequest(MessageContext context) {
    EJBInvocation inv = null;
    try {
        WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
        InvocationManager invManager = wscImpl.getInvocationManager();
        inv = EJBInvocation.class.cast(invManager.getCurrentInvocation());
        Method webServiceMethodInPreHandler = inv.getWebServiceMethod();
        if (webServiceMethodInPreHandler != null) {
            // Now that application handlers have run, do another method
            // lookup and compare the results with the original one.  This
            // ensures that the application handlers have not changed
            // the message context in any way that would impact which
            // method is invoked.
            Method postHandlerMethod = wsUtil.getInvMethod((com.sun.xml.rpc.spi.runtime.Tie) inv.getWebServiceTie(), context);
            if (!webServiceMethodInPreHandler.equals(postHandlerMethod)) {
                throw new UnmarshalException("Original method " + webServiceMethodInPreHandler + " does not match post-handler method ");
            }
        }
    } catch (Exception e) {
        wsUtil.throwSOAPFaultException(e.getMessage(), context);
    }
    return true;
}
Also used : UnmarshalException(java.rmi.UnmarshalException) InvocationManager(org.glassfish.api.invocation.InvocationManager) EJBInvocation(org.glassfish.ejb.api.EJBInvocation) Method(java.lang.reflect.Method) UnmarshalException(java.rmi.UnmarshalException)

Example 7 with UnmarshalException

use of java.rmi.UnmarshalException in project cuba by cuba-platform.

the class JmxControlBean method getManagedBeans.

@Override
public List<ManagedBeanInfo> getManagedBeans(JmxInstance instance) {
    checkNotNullArgument(instance);
    // noinspection UnnecessaryLocalVariable
    List<ManagedBeanInfo> infos = withConnection(instance, (jmx, connection) -> {
        Set<ObjectName> names = connection.queryNames(null, null);
        List<ManagedBeanInfo> infoList = new ArrayList<>(names.size());
        for (ObjectName name : names) {
            MBeanInfo info;
            try {
                info = connection.getMBeanInfo(name);
            } catch (UnmarshalException | InstanceNotFoundException e) {
                // unable to use this bean, may be ClassNotFoundException
                continue;
            }
            ManagedBeanInfo mbi = createManagedBeanInfo(jmx, name, info);
            loadOperations(mbi, info);
            infoList.add(mbi);
        }
        infoList.sort(new MBeanComparator());
        return infoList;
    });
    return infos;
}
Also used : UnmarshalException(java.rmi.UnmarshalException) JmxConnectionHelper.getObjectName(com.haulmont.cuba.web.jmx.JmxConnectionHelper.getObjectName)

Example 8 with UnmarshalException

use of java.rmi.UnmarshalException in project jmxtrans by jmxtrans.

the class Query method fetchResults.

public Iterable<Result> fetchResults(MBeanServerConnection mbeanServer, ObjectName queryName) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
    ObjectInstance oi = mbeanServer.getObjectInstance(queryName);
    List<String> attributes;
    if (attr.isEmpty()) {
        attributes = new ArrayList<>();
        MBeanInfo info = mbeanServer.getMBeanInfo(queryName);
        for (MBeanAttributeInfo attrInfo : info.getAttributes()) {
            attributes.add(attrInfo.getName());
        }
    } else {
        attributes = attr;
    }
    try {
        if (!attributes.isEmpty()) {
            logger.debug("Executing queryName [{}] from query [{}]", queryName.getCanonicalName(), this);
            AttributeList al = mbeanServer.getAttributes(queryName, attributes.toArray(new String[attributes.size()]));
            return new JmxResultProcessor(this, oi, al.asList(), oi.getClassName(), queryName.getDomain()).getResults();
        }
    } catch (UnmarshalException ue) {
        if ((ue.getCause() != null) && (ue.getCause() instanceof ClassNotFoundException)) {
            logger.debug("Bad unmarshall, continuing. This is probably ok and due to something like this: " + "http://ehcache.org/xref/net/sf/ehcache/distribution/RMICacheManagerPeerListener.html#52", ue.getMessage());
        } else {
            throw ue;
        }
    }
    return ImmutableList.of();
}
Also used : MBeanInfo(javax.management.MBeanInfo) AttributeList(javax.management.AttributeList) UnmarshalException(java.rmi.UnmarshalException) ObjectInstance(javax.management.ObjectInstance) ToString(lombok.ToString) MBeanAttributeInfo(javax.management.MBeanAttributeInfo)

Example 9 with UnmarshalException

use of java.rmi.UnmarshalException in project Payara by payara.

the class WebServiceInvocationHandler method invoke.

private Object invoke(Method method, Object[] args, EjbInvocation inv) throws Exception {
    try {
        inv.ejbObject = this;
        // find the right method object on the SIB.
        if (endpoint_.getServiceEndpointInterface().equals(ejbClass_.getName())) {
            // we need to substiture the method object
            method = ejbClass_.getMethod(method.getName(), method.getParameterTypes());
        }
        inv.method = method;
        inv.clientInterface = serviceEndpointIntfClass_;
        inv.invocationInfo = (InvocationInfo) invocationInfoMap_.get(inv.method);
        if (inv.invocationInfo == null) {
            throw new EJBException("Web service Invocation Info lookup failed for method " + inv.method);
        }
        inv.transactionAttribute = inv.invocationInfo.txAttr;
        // special handling of jaxrpc endpoints (identfied by mapping file)
        if (endpoint_.getWebService().hasMappingFile()) {
            if (hasHandlers_) {
            // Handler performed method authorization already
            } else {
                final boolean authorized = container.authorize(inv);
                if (!authorized) {
                    throw new AccessLocalException("Client not authorized to access " + inv.method);
                }
            }
        } else if (hasHandlers_) {
            // jaxws enpoint
            // authorization was done in security pipe
            // Now that application handlers have run, do
            // another method lookup and compare the results
            // with the original one. This ensures that the
            // application handlers have not changed
            // which method is invoked.
            final Method methodBefore = inv.getWebServiceMethod();
            if (methodBefore != null && !methodBefore.equals(inv.method)) {
                inv.exception = new UnmarshalException(localStrings.getLocalString("enterprise.webservice.postHandlerMethodMismatch", "Original Method {0} does not match post-handler method {1}", new Object[] { methodBefore, inv.method }));
                throw inv.exception;
            }
        }
        final ComponentContext ctx = container.getContext(inv);
        inv.context = ctx;
        inv.ejb = ctx.getEJB();
        inv.instance = inv.ejb;
        container.preInvokeTx(inv);
        // Enterprise Bean class doesn't necessarily implement
        // web service endpoint interface, so we can't directly
        // dispatch through the given method object.
        final Method beanClassMethod = ejbClass_.getMethod(method.getName(), method.getParameterTypes());
        inv.beanMethod = beanClassMethod;
        inv.methodParams = args;
        return container.intercept(inv);
    } catch (NoSuchMethodException nsme) {
        inv.exception = nsme;
        return null;
    } catch (InvocationTargetException ite) {
        inv.exception = ite.getCause();
        return null;
    } catch (Throwable c) {
        inv.exception = c;
        return null;
    } finally {
        if (inv.ejb != null) {
            // Do post invoke tx processing so that a commit failure
            // will be visible to web service client.
            container.postInvokeTx(inv);
        }
    }
}
Also used : ComponentContext(com.sun.ejb.ComponentContext) UnmarshalException(java.rmi.UnmarshalException) AccessLocalException(javax.ejb.AccessLocalException) Method(java.lang.reflect.Method) EJBException(javax.ejb.EJBException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

UnmarshalException (java.rmi.UnmarshalException)9 IOException (java.io.IOException)4 Method (java.lang.reflect.Method)4 MarshalException (java.rmi.MarshalException)4 RemoteException (java.rmi.RemoteException)4 ObjectInput (java.io.ObjectInput)3 ObjectOutput (java.io.ObjectOutput)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 ServerError (java.rmi.ServerError)2 ServerException (java.rmi.ServerException)2 ExportException (java.rmi.server.ExportException)2 ServerNotActiveException (java.rmi.server.ServerNotActiveException)2 SkeletonNotFoundException (java.rmi.server.SkeletonNotFoundException)2 InvocationManager (org.glassfish.api.invocation.InvocationManager)2 JmxConnectionHelper.getObjectName (com.haulmont.cuba.web.jmx.JmxConnectionHelper.getObjectName)1 ComponentContext (com.sun.ejb.ComponentContext)1 WebComponentInvocation (com.sun.enterprise.web.WebComponentInvocation)1 DataInputStream (java.io.DataInputStream)1 StreamCorruptedException (java.io.StreamCorruptedException)1 RemoteCall (java.rmi.server.RemoteCall)1