I've done more testing and it seems that using resources.xml is not working
how i thought it would.  If i configure a pool in resources.xml as
follows...

<resources>
        <Resource id="testPool"
class-name="com.cyberavenue.jcatest.JCATestManagedConnectionFactory">
                poolMinSize = 7
                poolMaxSize = 10
        </Resource>
</resources>

When I start tomee, the following is printed out...

TomcatWebAppBuilder.init /jcawebapp
10/01/2013 8:41:13 PM org.apache.openejb.config.ConfigurationFactory
configureApplication
INFO: Configuring enterprise application:
D:\Users\Anthony\Documents\DEV\JCATest\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\jcawebapp
10/01/2013 8:41:14 PM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=testPool, type=Resource, provider-id=testPool)
10/01/2013 8:41:14 PM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=testPool)
10/01/2013 8:41:14 PM org.apache.openejb.assembler.classic.Assembler
createResource
INFO: Creating ConnectionManager for Resource(id=testPool)
10/01/2013 8:41:14 PM
org.apache.geronimo.connector.outbound.GenericConnectionManager$InterceptorsImpl
<init>
INFO: No runtime TransactionSupport
10/01/2013 8:41:14 PM org.apache.openejb.config.OutputGeneratedDescriptors
writeRaXml
INFO: Dumping Generated ra.xml to:
D:\Users\Anthony\AppData\Local\Temp\ra-5615975532766635748jcawebappRA.xml
10/01/2013 8:41:14 PM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=jcawebappRARA, type=Resource,
provider-id=jcawebappRARA)
10/01/2013 8:41:14 PM org.apache.openejb.config.ConfigurationFactory
configureService
INFO: Configuring Service(id=jcatestPoolA, type=Resource,
provider-id=jcatestPoolA)
10/01/2013 8:41:14 PM org.apache.openejb.config.AppInfoBuilder build
INFO: Enterprise application
"D:\Users\Anthony\Documents\DEV\JCATest\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\jcawebapp"
loaded.
10/01/2013 8:41:14 PM org.apache.openejb.assembler.classic.Assembler
createApplication
INFO: Assembling app:
D:\Users\Anthony\Documents\DEV\JCATest\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\jcawebapp
10/01/2013 8:41:14 PM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=jcawebappRARA)
JCATestResourceAdapter.start()...
10/01/2013 8:41:14 PM org.apache.openejb.assembler.classic.Assembler
createRecipe
INFO: Creating Resource(id=jcatestPoolA)
10/01/2013 8:41:14 PM org.apache.openejb.assembler.classic.Assembler
createResource
INFO: Creating ConnectionManager for Resource(id=jcatestPoolA)
10/01/2013 8:41:14 PM
org.apache.geronimo.connector.outbound.GenericConnectionManager$InterceptorsImpl
<init>
INFO: No runtime TransactionSupport
...


I have a servlet where I inject the testPool...

@WebServlet("/jcatest")
public class JCATestServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
        
        @Resource(name="testPool")
        JCATestConnectionFactory testPool;
       
        protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
                PrintWriter out = response.getWriter();
                out.println("<html><body>");
                out.println("
Welcome to the JCATest servlet!
");
                out.println("</body></html>");
                
                JCATestConnection conn = null;
                try {
                         conn = testPool.getConnection();
                } catch (ResourceException e) {
                        throw new ServletException(e);
                } finally {
                        if (conn != null) {
                                conn.close();
                        }
                }
        }
} 

When I run that servlet i get the following error...

10/01/2013 8:43:14 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [JCATestServlet] in context with path
[/jcawebapp] threw exception [javax.resource.NotSupportedException:
LocalTransactions are not supported] with root cause
javax.resource.NotSupportedException: LocalTransactions are not supported
        at
com.cyberavenue.jcatest.JCATestManagedConnection.getLocalTransaction(JCATestManagedConnection.java:62)
        at
org.apache.geronimo.connector.outbound.LocalXAResourceInsertionInterceptor.getConnection(LocalXAResourceInsertionInterceptor.java:43)
        at
org.apache.geronimo.connector.outbound.SinglePoolConnectionInterceptor.internalGetConnection(SinglePoolConnectionInterceptor.java:70)
        at
org.apache.geronimo.connector.outbound.AbstractSinglePoolConnectionInterceptor.getConnection(AbstractSinglePoolConnectionInterceptor.java:80)
        at
org.apache.geronimo.connector.outbound.TransactionEnlistingInterceptor.getConnection(TransactionEnlistingInterceptor.java:49)
        at
org.apache.geronimo.connector.outbound.TransactionCachingInterceptor.getConnection(TransactionCachingInterceptor.java:109)
        at
org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.getConnection(ConnectionHandleInterceptor.java:43)
        at
org.apache.geronimo.connector.outbound.TCCLInterceptor.getConnection(TCCLInterceptor.java:39)
        at
org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.getConnection(ConnectionTrackingInterceptor.java:66)
        at
org.apache.geronimo.connector.outbound.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:81)
        at
com.cyberavenue.jcatest.JCATestConnectionFactoryImpl.getConnection(JCATestConnectionFactoryImpl.java:33)
        at com.cyberavenue.jcatest.JCATestServlet.doGet(JCATestServlet.java:46)


I found that by getting rid of resources.xml and specifying the pooling
parameters in ra.xml, it worked.  My ra.xml now looks like this...

<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>JCATest Resource Adapter</display-name>
        <vendor-name>CyberAvenue</vendor-name>
        <eis-type>JCATest</eis-type>
        <resourceadapter-version>1.0</resourceadapter-version>
        <resourceadapter>
        
<resourceadapter-class>com.cyberavenue.jcatest.JCATestResourceAdapter</resourceadapter-class>
                <outbound-resourceadapter>
                        <connection-definition id="jcatestPoolA">
                        
<managedconnectionfactory-class>com.cyberavenue.jcatest.JCATestManagedConnectionFactory</managedconnectionfactory-class>
                                <config-property>
                          
<config-property-name>poolMinSize</config-property-name>
                          
<config-property-type>java.lang.Integer</config-property-type>
                          <config-property-value>7</config-property-value>
                        </config-property>
                        <config-property>
                          
<config-property-name>poolMaxSize</config-property-name>
                          
<config-property-type>java.lang.Integer</config-property-type>
                          <config-property-value>10</config-property-value>
                        </config-property>
                        
<connectionfactory-interface>com.cyberavenue.jcatest.JCATestConnectionFactory</connectionfactory-interface>
                        
<connectionfactory-impl-class>com.cyberavenue.jcatest.JCATestConnectionFactoryImpl</connectionfactory-impl-class>
                        
<connection-interface>com.cyberavenue.jcatest.JCATestConnection</connection-interface>
                        
<connection-impl-class>com.cyberavenue.jcatest.JCATestConnectionImpl</connection-impl-class>
                        </connection-definition>
                        <transaction-support>NoTransaction</transaction-support>
                        
<reauthentication-support>false</reauthentication-support>
                </outbound-resourceadapter>
        </resourceadapter>
</connector>

I then modified the servlet above to use the "jcatestPoolA" instead of
"testPool" and it works.


There is some strange behavious with the pool though. I find that its only
when i call the servlet the second time does tomee instantiate the minimum
number of connections specified in the pool.  Ideally the pool should be
specified with the minimum number of connections when tomee starts up and
initializes the connection pool.



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Does-tomee-plus-support-ValidatingManagedConnectionFactory-tp4660187p4660224.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to