users@glassfish.java.net

spring 2.5.6 / glassfish v3 / WorkManagerFactory

From: Mark Stephens <markrstephens_at_gmail.com>
Date: Thu, 25 Feb 2010 20:39:28 -0500

I'm trying to bind to a thread pool via spring 2.5.6 using glassfish v3 and
a bean definition like this:

<bean id="threadPool"
class="org.springframework.jca.work.glassfish.GlassFishWorkManagerTaskExecutor">
    <property name="threadPoolName" value="mediaSourceTasks" />
</bean>

I get this exception when deploying:

Caused by: java.lang.IllegalStateException: Could not initialize
GlassFishWorkManagerTaskExecutor because GlassFish API is not available:
java.lang.NoSuchMethodException: com.sun.
enterprise.connectors.work.WorkManagerFactory.getWorkManager(java.lang.String)
        at
org.springframework.jca.work.glassfish.GlassFishWorkManagerTaskExecutor.<init>(GlassFishWorkManagerTaskExecutor.java:52)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at
org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
        ... 79 more

appserv-rt-2.1.jar for glassfish v2 has the method:

javap -classpath appserv-rt-2.1.jar
com/sun/enterprise/connectors/work/WorkManagerFactory
Compiled from "WorkManagerFactory.java"
public final class com.sun.enterprise.connectors.work.WorkManagerFactory
extends java.lang.Object{
    public com.sun.enterprise.connectors.work.WorkManagerFactory();
   * public static javax.resource.spi.work.WorkManager
getWorkManager(java.lang.String) throws
com.sun.enterprise.connectors.ConnectorRuntimeException;*
    static {};
}

However for glassfish v3, the only place I see this class defined is in the
modules/work-management.jar file. It's missing the
getWorkManager(java.lang.String) method:

javap -classpath modules/work-management.jar
com/sun/enterprise/connectors/work/WorkManagerFactory
Compiled from "WorkManagerFactory.java"
public final class com.sun.enterprise.connectors.work.WorkManagerFactory
extends java.lang.Object implements
com.sun.appserv.connectors.internal.api.WorkManagerFactory{
    protected static final java.util.Map workManagers;
    public com.sun.enterprise.connectors.work.WorkManagerFactory();
    public javax.resource.spi.work.WorkManager
createWorkManager(java.lang.String, java.lang.String);
    static void addWorkManager(java.lang.String,
javax.resource.spi.work.WorkManager);
    static javax.resource.spi.work.WorkManager
retrieveWorkManager(java.lang.String);
    public boolean removeWorkManager(java.lang.String);
    public javax.resource.spi.work.WorkManager
getWorkManagerProxy(java.lang.String, java.lang.String) throws
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException;
    static {};
}

Then I got even more confused when I checked out the glassfish v3 source
from cvs and WorkManagerFactory.java ( cvs version 1.6 ) has this:

 public static WorkManager getWorkManager(String poolName)
                              throws ConnectorRuntimeException {