Hi Sandeep,
The normal way to get a connection would be :
1. Deploy the Resource Adapter
2. Create a connection factory
3. Do a JNDI lookup.
It appears here that you are trying to do a lookup inside the RA before
deploying it.
thanks,
:aditya
Sandeep Rajpathak wrote:
> In my implementation, in the start method of the adapter, I start a timer
> using the method createTimer of BootStrapContext. In the run method of the
> timer, I create an instance of my work interface implementation and call its
> WorkManager.scheduleWork passing this instance.
>
> The implementation of Work interface does the lookup on ConnectionFactory
> and calls getConnection on it.
> Following is the code
> ----------------------------------------------------------------------------
> -------------------------------
> public void run()
> {
> System.out.println("In the run of OutboundWork");
>
> String JNDIName = "test/OutboundAdapter";
>
> try
> {
> Context ctx = new InitialContext();
> System.out.println("Obtained the initial context.");
>
> Object object = ctx.lookup(JNDIName);
>
> System.out.println("Class name is: " +
> object.getClass().getName());
>
> ConnectionFactory ctxFactory =
> (OutboundConnectionFactory)object;
>
> System.out.println("ConnectionFactory obtained: " + ctxFactory +
> " " + ctxFactory.getClass().getName() );
>
> Connection connection = ctxFactory.getConnection();
> System.out.println("Connection obtained: " + connection + " " +
> connection.getClass().getName() );
> }
> catch(Exception ex)
> {
> System.out.println("Invalid class returned from lookup.");
> ex.printStackTrace();
> }
> }
> ----------------------------------------------------------------------------
> --------------------------------
>
> Is there something incorrect in this implementation.
>
> Sandeep
>
> ----- Original Message -----
> From: "Aditya Gore" <Aditya.Gore@(protected)>
> To: <J2EE-INTEREST@(protected)>
> Sent: Wednesday, July 30, 2003 10:29 AM
> Subject: Re: Problems running Outbound Adapter on SUN J2EE 1.4 RI Beta 1
>
>
>
>>Hi Sandeep,
>>In this particular case, how are you accessing your Adapter? Is it through
>>an EJB or is it through a Servlet/JSP?
>>
>>thanks,
>>:aditya
>>
>>Sandeep Rajpathak wrote:
>>
>>
>>>Hello,
>>>
>>>
>>>
>>>I am trying to build an Outbound Adapter using the JCA 1.5
>>>specifications. I have provided implementations for the following
>>>
> classes:
>
>>>
>>>
>>>
javax.resource.cci.ConnectionFactory>>>
>>>
javax.resource.cci.Connection>>>
>>>
javax.resource.cci.ConnectionMetaData>>>
>>>
javax.resource.cci.Interaction;
>>>
javax.resource.cci.InteractionSpec>>>
javax.resource.cci.RecordFactory>>>
>>>
javax.resource.cci.Record>>>
>>>
javax.resource.cci.ResourceAdapterMetaData>>>
>>>
>>>
>>>
javax.resource.spi.ResourceAdapter>>>
>>>
javax.resource.spi.ManagedConnectionFactory>>>
>>>
javax.resource.spi.ManagedConnection>>>
>>>java.resource.spi.ConnectionManager
>>>
>>>
javax.resource.spi.ConnectionRequestInfo>>>
>>>
javax.resource.spi.ManagedConnectionMetaData>>>
>>>
javax.resource.spi.work.Work>>>
>>>
>>>
>>>The implementation of the ManagedConnectionFactory method
>>>
>>>
>>>
>>>1. matchManagedConnection is returning null always.
>>>
>>>2. createManagedConnection always creates a new ManagedConnection.
>>>
>>>
>>>
>>>I deploy this adapter and trigger a Timer in the start method which will
>>>do the lookup for cci.ConnectionFactory and call getConnection().
>>>
>>>
>>>
>>>The lookup for ConnectionFactory happens correctly but on the call to
>>>getConnection() when the call is delegated to the
>>>ConnectionManager.allocateConnection, the call returns an error "Invalid
>>>class returned from lookup". Following is the error trace -
>>>
>>>
>>>
>>>
>>--------------------------------------------------------------------------
>>
> ----------------------------------------
>
>>>In the run of OutboundWork
>>>Obtained the initial context.
>>>In constructor of OutboundManagedConnectionFactory
>>>setResourceAdapter of OutboundManagedConnectionFactory called
>>>createConnectionFactory of OutboundManagedConnectionFactory called
>>>Constructor of OutboundConnectionFactory called with ConnectionManager
>>>and ManagedConnectionFactory
>>>ConnectionFactory obtained: OutboundConnectionFactory@(protected)
>>><mailto:OutboundConnectionFactory@(protected)
>>>getConnection method of OutboundConnectionFactory called
>>>
>>>Invalid class returned from lookup.
>>>
com.sun.enterprise.InvocationException>>> at
>>>
>>>
>
com.sun.enterprise.util.InvocationManagerImpl.getCurrentInvocation(Invocatio
> nManagerImpl.java:188)
>
>>> at
>>>
>>>
>
com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerImpl.java
> :96)
>
>>> at
>>>
>>>
> com.sun.enterprise.resource.ConnectionManagerImpl.internalGetConnection(Conn
> ectionManagerImpl.java:133)
>
>>> at
>>>
>>>
> com.sun.enterprise.resource.ConnectionManagerImpl.allocateConnection(Connect
> ionManagerImpl.java:58)
>
>>> at
>>>
>>>
> OutboundConnectionFactory.getConnection(OutboundConnectionFactory.java:66)
>
>>> at OutboundWork.run(OutboundWork.java:48)
>>> at
>>>
> com.sun.enterprise.resource.async.WorkerThread.run(WorkerThread.java:84)
>
>>--------------------------------------------------------------------------
>>
> ----------------------------------------
>
>>>
>>>
>>>Following is the ra.xml file I am using
>>>
>>>
>>>
>>>
>>--------------------------------------------------------------------------
>>
> ----------------------------------------
>
>>><?xml version="1.0" encoding="UTF-8"?>
>>>
>>>
>>>
>>><connector xmlns="http://java.sun.com/xml/ns/j2ee"
>>>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
>>>http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd" version="1.5">
>>>
>>>
>>>
>>> <display-name>Outbound Adpater</display-name>
>>> <vendor-name>Test</vendor-name>
>>> <eis-type>Outbound</eis-type>
>>> <resourceadapter-version>1.0</resourceadapter-version>
>>>
>>> <resourceadapter>
>>>
> <resourceadapter-class>OutboundResourceAdapter</resourceadapter-class>
>
>>> <outbound-resourceadapter>
>>> <connection-definition>
>>>
>>>
> <managedconnectionfactory-class>OutboundManagedConnectionFactory</managedcon
> nectionfactory-class>
>
>>>
> <connectionfactory-interface>
javax.resource.cci.ConnectionFactory</connectio
> nfactory-interface>
>
>>>
> <connectionfactory-impl-class>OutboundConnectionFactory</connectionfactory-i
> mpl-class>
>
>>>
> <connection-interface>
javax.resource.cci.Connection</connection-interface>
>
>>><connection-impl-class>OutboundConnectionImpl</connection-impl-class>
>>> </connection-definition>
>>> <transaction-support>NoTransaction</transaction-support>
>>> <reauthentication-support>false</reauthentication-support>
>>> </outbound-resourceadapter>
>>> </resourceadapter>
>>></connector>
>>>
>>--------------------------------------------------------------------------
>>
> ----------------------------------------
>
>>>
>>>
>>>Any idea what could possibly be going wrong with the implementation.
>>>
>>>
>>>
>>>Sandeep
>>>
>>>
>>
> ===========================================================================
>
>>To unsubscribe, send email to listserv@(protected)
>>
> body
>
>>of the message "signoff J2EE-INTEREST". For general help, send email to
>>listserv@(protected)".
>>
>
> ===========================================================================
> To unsubscribe, send email to listserv@(protected)
> of the message "signoff J2EE-INTEREST". For general help, send email to
> listserv@(protected)".
>
===========================================================================
To unsubscribe, send email to listserv@(protected)
of the message "signoff J2EE-INTEREST". For general help, send email to
listserv@(protected)".