You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by toby cabot <to...@caboteria.org> on 2004/07/10 17:26:31 UTC
ResourceAdapter.start() not getting called?
Hi folks,
I'm trying to get a skeleton JCA 1.5 resource adapter up and running,
and am most of the way there but for one problem: my
javax.resource.spi.ResourceAdapter.start() doesn't get called.
It looks as if my deployment is OK, at least my configuration
parameter setter gets called but then start() doesn't.
Based on my reading of the JCA spec I believe that start() should be
called, by my JCA-fu is weak so I could be wrong.
I fixed a NPE caused by not having any outbound connection factories
or admin objects (see
http://nagoya.apache.org/jira/browse/GERONIMO-262 if you're curious)
and since both are minOccurs=0 in the schema I think they're optional.
So now I'm stuck. If anyone's got any ideas or pointers of where to
look in the code, I'd appreciate it and will investigate further. If
anyone wants to whack me with the JCA clue-by-four I can accept that,
too.
Regards,
Toby
My resource adapter rar is trivial, just ra.xml, geronimo-ra.xml and
an implementation of javax.resource.spi.ResourceAdapter.
ra.xml:
<?xml version="1.0" ?>
<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">
<description>experimental jca 1.5 resource adapter</description>
<display-name>testRA</display-name>
<vendor-name>FIXME</vendor-name>
<eis-type>test</eis-type>
<resourceadapter-version>0.0</resourceadapter-version>
<resourceadapter>
<resourceadapter-class>skeleton.ra.spread.AdapterImpl</resourceadapter-class>
<config-property>
<config-property-name>ConfigParameter</config-property-name>
<config-property-type>java.lang.String</config-property-type>
<config-property-value>OldStringValue</config-property-value>
</config-property>
</resourceadapter>
</connector>
geronimo-ra.xml:
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee" version="1.5"
configId="testRA"
parentId="org/apache/geronimo/Server">
<resourceadapter>
<resourceadapter-instance>
<resourceadapter-name>testRA</resourceadapter-name>
<config-property-setting name="ConfigParameter">NewStringValue</config-property-setting>
<bootstrapcontext-name>geronimo.connector:role=BootstrapContext</bootstrapcontext-name>
</resourceadapter-instance>
</resourceadapter>
</connector>
code:
package skeleton.ra.spread;
import javax.resource.spi.BootstrapContext;
import javax.resource.spi.ResourceAdapterInternalException;
import javax.resource.spi.endpoint.MessageEndpointFactory;
import javax.resource.ResourceException;
import javax.transaction.xa.XAResource;
import javax.resource.spi.ActivationSpec;
/**
* A null resource adapter.
*/
public class AdapterImpl implements javax.resource.spi.ResourceAdapter {
/**
* Describe <code>start</code> method here.
*
* @param bootstrapContext a <code>BootstrapContext</code> value
* @exception ResourceAdapterInternalException if an error occurs
*/
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
System.out.println("ra test starting");
}
/**
* Describe <code>stop</code> method here.
*
*/
public void stop() {
System.out.println("ra test stopping");
}
/**
* Describe <code>endpointActivation</code> method here.
*
* @param messageEndpointFactory a <code>MessageEndpointFactory</code> value
* @param activationSpec an <code>ActivationSpec</code> value
* @exception ResourceException if an error occurs
*/
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException {
System.out.println("ra test endpoint activation");
}
/**
* Describe <code>endpointDeactivation</code> method here.
*
* @param messageEndpointFactory a <code>MessageEndpointFactory</code> value
* @param activationSpec an <code>ActivationSpec</code> value
*/
public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
System.out.println("ra test endpoint deactivation");
}
/**
* Describe <code>getXAResources</code> method here.
*
* @param activationSpecArray an <code>ActivationSpec[]</code> value
* @return a <code>XAResource[]</code> value
* @exception ResourceException if an error occurs
*/
public XAResource[] getXAResources(ActivationSpec[] activationSpecArray) throws ResourceException {
System.out.println("ra test get xa resources");
return null;
}
String configParameter;
/**
* Get the ConfigParameter value.
* @return the ConfigParameter value.
*/
public String getConfigParameter() {
return configParameter;
}
/**
* Set the ConfigParameter value.
* @param newConfigParameter The new ConfigParameter value.
*/
public void setConfigParameter(String newConfigParameter) {
System.out.println("ra test setting configParameter to " + newConfigParameter);
new Throwable().printStackTrace();
this.configParameter = newConfigParameter;
}
}
ResourceAdapter.start() now getting called
Posted by toby cabot <to...@caboteria.org>.
David,
Thanks!
On Sat, Jul 10, 2004 at 12:24:02PM -0700, David Jencks wrote:
> On Saturday, July 10, 2004, at 11:50 AM, toby cabot wrote:
>
> >
> <snip>
> >Does this imply that my geronimo-ra.xml
> >
> ><bootstrapcontext-name>geronimo.connector:role=BootstrapContext</
> >bootstrapcontext-name>
> >
> >element is wrong? It wouldn't surprise me since I'm not clear on what
> >that element's supposed to do anyway.
>
> yes. I tried to make the names somewhat more uniform and it is now
>
> geronimo.server:type=BootstrapContext
That's the solution. With this change to geronimo-ra.xml my start()
method is now being called.
> Since it is unlikely that anyone will be running more than one
> TransactionManager/XATerminator in a geronimo server, perhaps this
> should be made a little clearer by specifying the WorkManager directly
> in the ResourceAdapter config and constructing a BootstrapContext per
> ResourceAdapter instance. Opinions?
I'm afraid I've got to learn a lot more about how bootstrap contexts
work before I can offer an informed opinion. I kinda see now how the
<bootstrapcontext-name> is supposed to refer to another <gbean> that
<references> the WorkManager and XATerminator but don't really
understand how it works. When/if I get a clue I'll weigh in.
In the mean time thanks again,
Toby
Re: ResourceAdapter.start() not getting called?
Posted by David Jencks <da...@coredevelopers.net>.
On Saturday, July 10, 2004, at 06:57 PM, Gianny Damour wrote:
> On 11/07/2004 5:24 AM, David Jencks wrote:
>
>>
>> Since it is unlikely that anyone will be running more than one
>> TransactionManager/XATerminator in a geronimo server, perhaps this
>> should be made a little clearer by specifying the WorkManager
>> directly in the ResourceAdapter config and constructing a
>> BootstrapContext per ResourceAdapter instance. Opinions?
>
> I agree. Perhaps that there is also something not so obvious - at
> least for me: a BootstrapContext must reference the same XATerminator
> used under the cover by the XAWork referenced by the WorkManager of
> this context.
>
> The current dependencies are something like that:
>
> TransactionManager <---- XAWork<---- WorkManager <----
> BootstrapContext;
> ^
> |
> |
> -------------------------------------------------------------------
>
> So, is it possible to make it "clearer" by providing to the
> (Geronimo)WorkManager a TransactionManager(Proxy)? This latter still
> provides an XAWork view in order to recreate resource adpater
> transactions; one adds to the (Geronimo)WorkManager a getter for this
> XATerminator reference/attribute; and BootstrapContext only needs by
> now a simple reference to (Geronimo)WorkManager.
>
> This way, the dependencies could be more abvious - one more time, at
> least for me:
> TransactionManager <---- WorkManager <---- BootstrapContext.
I think this is an excellent idea. My idea for the
TransactionManagerProxy was that you could get the TransactionManager,
XATerminator, and XAWork from it, so supplying it to the WorkManager
will eliminate this possible inconsistency. I've implemented this.
>
> By the way, as I am talking about XAWork, I think that there are some
> concurrency issues: the begin and end methods should be synchronized
> otherwise, it is possible to run two Work concurrently having the same
> ExecutionContext.
Very true! that's not the only problem, resume and suspend also weren't
getting called on the delegate tm.
>
>>
>> Also, perhaps we should adopt a naming convention for all these
>> gbeans such as
>>
>> geronimo.server:type=BootstrapContext,name=MyBootstrapContext
>
> Is it possible to have a distinct domain for the JCA services? I mean
> something like:
> geronimo.jca:type=BootstrapContext,name=MyBootstrapContext
>
> Moreover, one could perhaps use the naming conventions proposed by
> JSR-77. For instance, a WorkManager could be name:
> geronimo.jca:type=WorkManager,BootstrapContext=MyBootstrapContext
First of all, I meant
geronimo.server:type=WorkManager,name=MyWorkManager
I'd like to use JSR-77 compliant names, but I'm not entirely sure what
they would be. Maybe Dain can suggest something? Meanwhile I'm just
using this pattern, and the geronimo-ra.xml just requires
"MyWorkManager"
many thanks,
david jencks
>
> Many thanks,
> Gianny
>
Re: ResourceAdapter.start() not getting called?
Posted by Gianny Damour <gi...@optusnet.com.au>.
On 11/07/2004 5:24 AM, David Jencks wrote:
>
> Since it is unlikely that anyone will be running more than one
> TransactionManager/XATerminator in a geronimo server, perhaps this
> should be made a little clearer by specifying the WorkManager
> directly in the ResourceAdapter config and constructing a
> BootstrapContext per ResourceAdapter instance. Opinions?
I agree. Perhaps that there is also something not so obvious - at least
for me: a BootstrapContext must reference the same XATerminator used
under the cover by the XAWork referenced by the WorkManager of this context.
The current dependencies are something like that:
TransactionManager <---- XAWork<---- WorkManager <---- BootstrapContext;
^
|
|
-------------------------------------------------------------------
So, is it possible to make it "clearer" by providing to the
(Geronimo)WorkManager a TransactionManager(Proxy)? This latter still
provides an XAWork view in order to recreate resource adpater
transactions; one adds to the (Geronimo)WorkManager a getter for this
XATerminator reference/attribute; and BootstrapContext only needs by now
a simple reference to (Geronimo)WorkManager.
This way, the dependencies could be more abvious - one more time, at
least for me:
TransactionManager <---- WorkManager <---- BootstrapContext.
By the way, as I am talking about XAWork, I think that there are some
concurrency issues: the begin and end methods should be synchronized
otherwise, it is possible to run two Work concurrently having the same
ExecutionContext.
>
> Also, perhaps we should adopt a naming convention for all these
> gbeans such as
>
> geronimo.server:type=BootstrapContext,name=MyBootstrapContext
Is it possible to have a distinct domain for the JCA services? I mean
something like:
geronimo.jca:type=BootstrapContext,name=MyBootstrapContext
Moreover, one could perhaps use the naming conventions proposed by
JSR-77. For instance, a WorkManager could be name:
geronimo.jca:type=WorkManager,BootstrapContext=MyBootstrapContext
Many thanks,
Gianny
Re: ResourceAdapter.start() not getting called?
Posted by David Jencks <da...@coredevelopers.net>.
On Saturday, July 10, 2004, at 11:50 AM, toby cabot wrote:
>
<snip>
> Does this imply that my geronimo-ra.xml
>
> <bootstrapcontext-name>geronimo.connector:role=BootstrapContext</
> bootstrapcontext-name>
>
> element is wrong? It wouldn't surprise me since I'm not clear on what
> that element's supposed to do anyway.
yes. I tried to make the names somewhat more uniform and it is now
geronimo.server:type=BootstrapContext
As I recall I discovered while working with ActiveMQ this was one of
the many configuration errors in the default configuration and tests.
This reference tells the deployer which pre-configured BootstrapContext
to use. This primarily is going to give you a choice of
WorkManager/thread pools for your inbound adapters.
Since it is unlikely that anyone will be running more than one
TransactionManager/XATerminator in a geronimo server, perhaps this
should be made a little clearer by specifying the WorkManager directly
in the ResourceAdapter config and constructing a BootstrapContext per
ResourceAdapter instance. Opinions?
Also, perhaps we should adopt a naming convention for all these gbeans
such as
geronimo.server:type=BootstrapContext,name=MyBootstrapContext
so the reference to it only contains "MyBootstrapContext".
thanks
david jencks
>
> Thanks,
> Toby
>
Re: ResourceAdapter.start() not getting called?
Posted by toby cabot <to...@caboteria.org>.
David,
Thank you for the tips (on a weekend no less)! I pulled the source
from CVS this morning so I should be reasonably up to date.
> Can you look in the geronimo log (target/var/log/geronimo.log) and look
> for messages about the ResourceAdapterWrapper gbean? There is probably
> some information about a missing dependency or similar problem. If
> it's not obvious what the problem is please post the log.
Here's the part of the log that seems relevant:
14:17:19,320 DEBUG [GBeanMBean] geronimo.security:type=LoginConfiguration State changed from stopped to starting
14:17:19,330 DEBUG [GBeanMBean] geronimo.security:type=LoginConfiguration State changed from starting to running
14:17:19,330 DEBUG [GBeanMBean] geronimo.config:name="testRA" State changed from stopped to starting
14:17:19,335 DEBUG [Configuration] ClassPath for testRA resolved to [file:/home/tobyc/try/incubator-geronimo/target/config-store/8/connector/skeleton-ra.jar]
14:17:19,669 INFO [Configuration] Started configuration testRA
14:17:19,669 DEBUG [GBeanMBean] geronimo.config:name="testRA" State changed from starting to running
14:17:19,670 DEBUG [GBeanMBean] geronimo.server:J2EEApplication=null,J2EEServer=geronimo,ResourceAdapterModule=testRA,j2eeType=ResourceAdapter,name=testRA State changed from stopped to starting
14:17:19,673 DEBUG [GBeanMBean] Waiting to start: objectName="geronimo.server:J2EEApplication=null,J2EEServer=geronimo,ResourceAdapterModule=testRA,j2eeType=ResourceAdapter,name=testRA" reason="No targets are running for bootstrapContext reference"
14:17:19,673 DEBUG [GBeanMBean] geronimo.server:J2EEApplication=null,J2EEServer=geronimo,j2eeType=ResourceAdapterModule,name=testRA State changed from stopped to starting
14:17:19,687 DEBUG [GBeanMBean] geronimo.server:J2EEApplication=null,J2EEServer=geronimo,j2eeType=ResourceAdapterModule,name=testRA State changed from starting to running
14:17:19,687 DEBUG [GBeanMBean] geronimo.server:role=JMXService,name=localhost State changed from stopped to starting
Does this imply that my geronimo-ra.xml
<bootstrapcontext-name>geronimo.connector:role=BootstrapContext</bootstrapcontext-name>
element is wrong? It wouldn't surprise me since I'm not clear on what
that element's supposed to do anyway.
Thanks,
Toby
Re: ResourceAdapter.start() not getting called?
Posted by David Jencks <da...@coredevelopers.net>.
Thanks for the patch -- I hope to get a minute to apply it soon.
I got ActiveMQ to deploy and work recently, so in some circumstances
resourceAdapter.start is being called (it definitely should be called).
Can you look in the geronimo log (target/var/log/geronimo.log) and look
for messages about the ResourceAdapterWrapper gbean? There is probably
some information about a missing dependency or similar problem. If
it's not obvious what the problem is please post the log.
Also, please be sure you are up to date with cvs (+ your patch) since I
found several configuration errors when working on ActiveMQ.
Thanks,
david jencks
On Saturday, July 10, 2004, at 08:26 AM, toby cabot wrote:
> Hi folks,
>
> I'm trying to get a skeleton JCA 1.5 resource adapter up and running,
> and am most of the way there but for one problem: my
> javax.resource.spi.ResourceAdapter.start() doesn't get called.
> It looks as if my deployment is OK, at least my configuration
> parameter setter gets called but then start() doesn't.
> Based on my reading of the JCA spec I believe that start() should be
> called, by my JCA-fu is weak so I could be wrong.
>
> I fixed a NPE caused by not having any outbound connection factories
> or admin objects (see
> http://nagoya.apache.org/jira/browse/GERONIMO-262 if you're curious)
> and since both are minOccurs=0 in the schema I think they're optional.
>
> So now I'm stuck. If anyone's got any ideas or pointers of where to
> look in the code, I'd appreciate it and will investigate further. If
> anyone wants to whack me with the JCA clue-by-four I can accept that,
> too.
>
> Regards,
> Toby
>
> My resource adapter rar is trivial, just ra.xml, geronimo-ra.xml and
> an implementation of javax.resource.spi.ResourceAdapter.
>
> ra.xml:
>
> <?xml version="1.0" ?>
> <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">
> <description>experimental jca 1.5 resource adapter</description>
> <display-name>testRA</display-name>
> <vendor-name>FIXME</vendor-name>
> <eis-type>test</eis-type>
> <resourceadapter-version>0.0</resourceadapter-version>
> <resourceadapter>
>
> <resourceadapter-class>skeleton.ra.spread.AdapterImpl</
> resourceadapter-class>
> <config-property>
>
> <config-property-name>ConfigParameter</config-property-name>
>
> <config-property-type>java.lang.String</config-property-type>
>
> <config-property-value>OldStringValue</config-property-value>
> </config-property>
> </resourceadapter>
> </connector>
>
> geronimo-ra.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <connector xmlns="http://geronimo.apache.org/xml/ns/j2ee" version="1.5"
> configId="testRA"
> parentId="org/apache/geronimo/Server">
> <resourceadapter>
> <resourceadapter-instance>
> <resourceadapter-name>testRA</resourceadapter-name>
> <config-property-setting
> name="ConfigParameter">NewStringValue</config-property-setting>
>
> <bootstrapcontext-name>geronimo.connector:role=BootstrapContext</
> bootstrapcontext-name>
> </resourceadapter-instance>
> </resourceadapter>
> </connector>
>
> code:
>
> package skeleton.ra.spread;
>
> import javax.resource.spi.BootstrapContext;
> import javax.resource.spi.ResourceAdapterInternalException;
> import javax.resource.spi.endpoint.MessageEndpointFactory;
> import javax.resource.ResourceException;
> import javax.transaction.xa.XAResource;
> import javax.resource.spi.ActivationSpec;
>
>
> /**
> * A null resource adapter.
> */
> public class AdapterImpl implements javax.resource.spi.ResourceAdapter
> {
>
> /**
> * Describe <code>start</code> method here.
> *
> * @param bootstrapContext a <code>BootstrapContext</code> value
> * @exception ResourceAdapterInternalException if an error occurs
> */
> public void start(BootstrapContext bootstrapContext) throws
> ResourceAdapterInternalException {
> System.out.println("ra test starting");
> }
>
> /**
> * Describe <code>stop</code> method here.
> *
> */
> public void stop() {
> System.out.println("ra test stopping");
> }
>
> /**
> * Describe <code>endpointActivation</code> method here.
> *
> * @param messageEndpointFactory a
> <code>MessageEndpointFactory</code> value
> * @param activationSpec an <code>ActivationSpec</code> value
> * @exception ResourceException if an error occurs
> */
> public void endpointActivation(MessageEndpointFactory
> messageEndpointFactory, ActivationSpec activationSpec) throws
> ResourceException {
> System.out.println("ra test endpoint activation");
> }
>
> /**
> * Describe <code>endpointDeactivation</code> method here.
> *
> * @param messageEndpointFactory a
> <code>MessageEndpointFactory</code> value
> * @param activationSpec an <code>ActivationSpec</code> value
> */
> public void endpointDeactivation(MessageEndpointFactory
> messageEndpointFactory, ActivationSpec activationSpec) {
> System.out.println("ra test endpoint deactivation");
> }
>
> /**
> * Describe <code>getXAResources</code> method here.
> *
> * @param activationSpecArray an <code>ActivationSpec[]</code>
> value
> * @return a <code>XAResource[]</code> value
> * @exception ResourceException if an error occurs
> */
> public XAResource[] getXAResources(ActivationSpec[]
> activationSpecArray) throws ResourceException {
> System.out.println("ra test get xa resources");
> return null;
> }
>
>
> String configParameter;
>
> /**
> * Get the ConfigParameter value.
> * @return the ConfigParameter value.
> */
> public String getConfigParameter() {
> return configParameter;
> }
>
> /**
> * Set the ConfigParameter value.
> * @param newConfigParameter The new ConfigParameter value.
> */
> public void setConfigParameter(String newConfigParameter) {
> System.out.println("ra test setting configParameter to " +
> newConfigParameter);
> new Throwable().printStackTrace();
> this.configParameter = newConfigParameter;
> }
>
>
> }
>