Search in sources :

Example 1 with ResourceAdapterInternalException

use of org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException in project cxf by apache.

the class InvocationHandlerFactory method createHandlers.

public CXFInvocationHandler createHandlers(Object target, Subject subject) throws ResourceAdapterInternalException {
    CXFInvocationHandler first = null;
    CXFInvocationHandler last = null;
    // Create data member
    CXFInvocationHandlerData data = new CXFInvocationHandlerDataImpl();
    data.setBus(bus);
    data.setManagedConnection(managedConnection);
    data.setSubject(subject);
    data.setTarget(target);
    for (int i = 0; i < handlerChainTypes.length; i++) {
        CXFInvocationHandler newHandler;
        try {
            Constructor<?> newHandlerConstructor = handlerChainTypes[i].getDeclaredConstructor(new Class[] { CXFInvocationHandlerData.class });
            newHandler = (CXFInvocationHandler) newHandlerConstructor.newInstance(new Object[] { data });
        } catch (Exception ex) {
            ResourceAdapterInternalException raie = new ResourceAdapterInternalException("error creating InvocationHandler: " + handlerChainTypes[i], ex);
            LOG.warning(raie.getMessage());
            throw raie;
        }
        if (last != null) {
            last.setNext(newHandler);
            last = newHandler;
        } else {
            first = newHandler;
            last = newHandler;
        }
    }
    return first;
}
Also used : CXFInvocationHandler(org.apache.cxf.jca.cxf.CXFInvocationHandler) CXFInvocationHandlerData(org.apache.cxf.jca.cxf.CXFInvocationHandlerData) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) IOException(java.io.IOException)

Example 2 with ResourceAdapterInternalException

use of org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException in project cxf by apache.

the class JCABusFactory method isMonitorEJBServicePropertiesEnabled.

private boolean isMonitorEJBServicePropertiesEnabled() throws ResourceException {
    boolean retVal = false;
    if (mcf.getMonitorEJBServiceProperties().booleanValue()) {
        URL url = mcf.getEJBServicePropertiesURLInstance();
        if (url == null) {
            throw new ResourceAdapterInternalException(new Message("EJB_SERVANT_PROPERTIES_IS_NULL", BUNDLE).toString());
        }
        retVal = isFileURL(url);
    }
    return retVal;
}
Also used : Message(org.apache.cxf.common.i18n.Message) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) URL(java.net.URL)

Example 3 with ResourceAdapterInternalException

use of org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException in project cxf by apache.

the class ManagedConnectionImpl method associateConnection.

public void associateConnection(Object connection) throws ResourceException {
    try {
        CXFInvocationHandler handler = (CXFInvocationHandler) Proxy.getInvocationHandler(connection);
        Object managedConnection = handler.getData().getManagedConnection();
        if (managedConnection != this) {
            handler.getData().setManagedConnection(this);
            ((ManagedConnectionImpl) managedConnection).disassociateConnectionHandle(connection);
            if (getCXFService() == null) {
                // Very unlikely as THIS
                // managed connection is
                // already involved in a transaction.
                cxfService = connection;
                connectionHandleActive = true;
            }
        }
    } catch (Exception ex) {
        throw new ResourceAdapterInternalException(new Message("ASSOCIATED_ERROR", BUNDLE).toString(), ex);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) ResourceException(javax.resource.ResourceException) NotSupportedException(javax.resource.NotSupportedException) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) WebServiceException(javax.xml.ws.WebServiceException) AbstractManagedConnectionImpl(org.apache.cxf.jca.core.resourceadapter.AbstractManagedConnectionImpl)

Example 4 with ResourceAdapterInternalException

use of org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException in project cxf by apache.

the class ManagedConnectionImpl method getCXFConnection.

public synchronized Object getCXFConnection(Subject subject, ConnectionRequestInfo crInfo) throws ResourceException {
    CXFConnectionRequestInfo requestInfo = (CXFConnectionRequestInfo) crInfo;
    Class<?> serviceInterface = requestInfo.getInterface();
    ClassLoader orig = Thread.currentThread().getContextClassLoader();
    try {
        final ClientProxyFactoryBean factoryBean;
        if (isJaxWsServiceInterface(serviceInterface)) {
            factoryBean = new JaxWsProxyFactoryBean();
        } else {
            factoryBean = new ClientProxyFactoryBean();
        }
        factoryBean.setServiceClass(serviceInterface);
        if (requestInfo.getServiceName() != null) {
            factoryBean.getServiceFactory().setServiceName(requestInfo.getServiceName());
        }
        if (requestInfo.getPortName() != null) {
            factoryBean.getServiceFactory().setEndpointName(requestInfo.getPortName());
        }
        if (requestInfo.getWsdlLocation() != null) {
            factoryBean.getServiceFactory().setWsdlURL(requestInfo.getWsdlLocation());
        }
        if (requestInfo.getAddress() != null) {
            factoryBean.setAddress(requestInfo.getAddress());
        }
        Object obj = factoryBean.create();
        setSubject(subject);
        return createConnectionProxy(obj, requestInfo, subject);
    } catch (WebServiceException wse) {
        throw new ResourceAdapterInternalException(new Message("FAILED_TO_GET_CXF_CONNECTION", BUNDLE, requestInfo).toString(), wse);
    } finally {
        Thread.currentThread().setContextClassLoader(orig);
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Message(org.apache.cxf.common.i18n.Message) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException)

Example 5 with ResourceAdapterInternalException

use of org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException in project cxf by apache.

the class DummyClassLoader method testInvalidMonitorConfigNoPropsURL.

@Test
public void testInvalidMonitorConfigNoPropsURL() throws Exception {
    ManagedConnectionFactoryImpl mcf = new ManagedConnectionFactoryImpl();
    mcf.setMonitorEJBServiceProperties(Boolean.TRUE);
    JCABusFactory jcaBusFactory = new JCABusFactory(mcf);
    try {
        Bus mockBus = EasyMock.createMock(Bus.class);
        jcaBusFactory.setBus(mockBus);
        jcaBusFactory.initializeServants();
        fail("exception expected");
    } catch (ResourceAdapterInternalException re) {
        assertTrue("EJBServiceProperties is not set.", re.getMessage().indexOf("EJBServicePropertiesURL is not set") != -1);
    }
}
Also used : Bus(org.apache.cxf.Bus) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) Test(org.junit.Test) AbstractCXFTest(org.apache.cxf.test.AbstractCXFTest)

Aggregations

ResourceAdapterInternalException (org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException)7 Message (org.apache.cxf.common.i18n.Message)5 IOException (java.io.IOException)3 ResourceException (javax.resource.ResourceException)2 WebServiceException (javax.xml.ws.WebServiceException)2 InputStream (java.io.InputStream)1 URL (java.net.URL)1 Properties (java.util.Properties)1 NotSupportedException (javax.resource.NotSupportedException)1 Bus (org.apache.cxf.Bus)1 BusFactory (org.apache.cxf.BusFactory)1 ClientProxyFactoryBean (org.apache.cxf.frontend.ClientProxyFactoryBean)1 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)1 AbstractManagedConnectionImpl (org.apache.cxf.jca.core.resourceadapter.AbstractManagedConnectionImpl)1 UriHandlerInit (org.apache.cxf.jca.core.resourceadapter.UriHandlerInit)1 CXFInvocationHandler (org.apache.cxf.jca.cxf.CXFInvocationHandler)1 CXFInvocationHandlerData (org.apache.cxf.jca.cxf.CXFInvocationHandlerData)1 AbstractCXFTest (org.apache.cxf.test.AbstractCXFTest)1 Test (org.junit.Test)1