Hi,
we're facing nearly the same problem I think...
Here is my stack trace:

org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'org.apache.activemq.xbean.XBeanBrokerService' defined in class
path resource [activemq.xml]: Invocation of init method failed; nested
exception is java.io.IOException: Cannot create PoolableConnectionFactory
(I/O Exception: Got minus one from a read call)
Caused by: java.io.IOException: Cannot create PoolableConnectionFactory (I/O
Exception: Got minus one from a read call)
        at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:45)
        at
org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:61)
        at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.createAdapter(JDBCPersistenceAdapter.java:294)
        at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.getAdapter(JDBCPersistenceAdapter.java:249)
        at
org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.start(JDBCPersistenceAdapter.java:155)
        at
org.apache.activemq.store.journal.JournalPersistenceAdapter.start(JournalPersistenceAdapter.java:225)
        at
org.apache.activemq.broker.BrokerService.createRegionBroker(BrokerService.java:1448)
        at
org.apache.activemq.broker.BrokerService.createBroker(BrokerService.java:1400)
        at
org.apache.activemq.broker.BrokerService.getBroker(BrokerService.java:513)
        at 
org.apache.activemq.broker.BrokerService.start(BrokerService.java:422)
        at
org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:46)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
        at
org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:64)
        at
org.apache.xbean.spring.context.ResourceXmlApplicationContext.<init>(ResourceXmlApplicationContext.java:52)
        at
org.apache.activemq.xbean.XBeanBrokerFactory.createApplicationContext(XBeanBrokerFactory.java:91)
        at
org.apache.activemq.xbean.XBeanBrokerFactory.createBroker(XBeanBrokerFactory.java:51)
        at
org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:71)
        at
org.apache.activemq.broker.BrokerFactory.createBroker(BrokerFactory.java:54)
        at activemqtest.ActivemqJunit.testFoobar(ActivemqJunit.java:90)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (I/O Exception: Got minus one from a read call)
        at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:859)
        at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:544)
        at
org.apache.activemq.store.jdbc.TransactionContext.getConnection(TransactionContext.java:54)
        ... 44 more
Caused by: java.sql.SQLException: I/O Exception: Got minus one from a read
call
        at
oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:74)
        at 
oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:110)
        at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:171)
        at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
        at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:494)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:411)
        at
oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:490)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:202)
stop
        at
oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:474)
        at
org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)
        at
org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
        at
org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:881)
        at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:855)
        ... 46 more
java.lang.NullPointerException
        at activemqtest.ActivemqJunit.testFoobar(ActivemqJunit.java:102)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at junit.framework.TestCase.runTest(TestCase.java:154)
        at junit.framework.TestCase.runBare(TestCase.java:127)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
        at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
start
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


We faced this problem in our unit tests, so I broke down our action to the
following code snippet:

        for(int x=0;x<numberOfRuns;x++){
                
                try {                           
                URI activemqConfigurationUri = new URI("xbean:activemq.xml");   
     
                
                brokerService =                                  
                        BrokerFactory.createBroker(activemqConfigurationUri);   
                
                System.out.println("Starting broker"); 
                brokerService.start();
                
                } catch (Exception e) {
                        e.printStackTrace();                            
                } 
                
                
                
                
                 try {
                
                 System.out.println("stopping broker");               
                 brokerService.stop();
                 brokerService.waitUntilStopped();
                 brokerService=null; 
             }
             catch (JMSException e) {
                e.printStackTrace();
             } catch (Exception e) {                            
                                e.printStackTrace();
                        }
        }


So we are simply starting and stopping the broker.  In our Oracle DB the
number of INACTIVE connections rises until it explodes.  But ONLY when we
call this snippet as part of a unit test. When we run this as a simple java
app, there is no problem, inactive connections are cleaned up properly.

We also wrote a simple app that gets connections from dbcp and closes them
again. There we have NO problem in a utest environment/simple java app.

I looked into the activemq TransactionContext class and I saw nothing wrong.
When debugging, connection.close and connection=null is executed. During a
debug session, we also don't get the exception (due to pauses??). When I
remove the breakpoints, inactive sessions explode again...



activemqnewbie wrote:
> 
> When I am executing a bulk load of data to Oracle, I intermittently
> receive the following. Activemq publlishes 300 messages before
> failing. If I run it again it may fail after publishing200 messages . Has
> anyone seen this before?  It appears that it is failing to create a
> connection pool.
> Seems prvious connections are not being closed.Is this a bug in activemq
> or is it that am missing to specify some parametrs in my activemq.xml.
> Below is my activemq.xml snippet.
> Appreciate  help on my query.
> App uses: ActiveMq5,Oracle 10g
> 
> <beans
>   xmlns="http://www.springframework.org/schema/beans";
>   xmlns:amq="http://activemq.org/config/1.0";
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>   xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
>   http://activemq.org/config/1.0
> http://activemq.apache.org/schema/activemq-core.xsd
>   http://activemq.apache.org/camel/schema/spring
> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd";>
> 
>   <!-- Allows us to use system properties as variables in this
> configuration file -->
>   <bean
> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
>   
>   <broker xmlns="http://activemq.org/config/1.0"; brokerName="localhost"
> dataDirectory="${activemq.base}/data">
>   
>     <!-- Destination specific policies using destination names or
> wildcards -->
>     <destinationPolicy>
>       <policyMap>
>         <policyEntries>
> 
>           <policyEntry topic="SINFO.>" producerFlowControl="false"
> memoryLimit="1mb">
>             <dispatchPolicy>
>               <strictOrderDispatchPolicy/>
>             </dispatchPolicy>
>             <subscriptionRecoveryPolicy>
>               <lastImageSubscriptionRecoveryPolicy/>
>             </subscriptionRecoveryPolicy>
>           </policyEntry>
> 
>         </policyEntries>
>       </policyMap>
>     </destinationPolicy>
> 
> 
>     <!-- The transport connectors ActiveMQ will listen to -->
>     <transportConnectors>
>        <transportConnector name="openwire" uri="tcp://localhost:61616"
> discoveryUri="multicast://default"/>
>        <transportConnector name="ssl"     uri="ssl://localhost:61617"/>
>        <transportConnector name="stomp"   uri="stomp://localhost:61613"/>
>        <transportConnector name="xmpp"    uri="xmpp://localhost:61222"/>
>     </transportConnectors>
> 
>     <!-- The store and forward broker networks ActiveMQ will listen to -->
>     <networkConnectors>
>       <!-- by default just auto discover the other brokers -->
>       <networkConnector name="default-nc" uri="multicast://default"/>
>     </networkConnectors>
>     <persistenceAdapter>
>         <jdbcPersistenceAdapter dataSource="#oracle-ds"/>
>     </persistenceAdapter>   
>    
>   
>   </broker>
> 
>   <!--
>     ** Lets deploy some Enterprise Integration Patterns inside the
> ActiveMQ Message Broker
>     ** For more details see
>     **
>     ** http://activemq.apache.org/enterprise-integration-patterns.html
>     -->
>   <camelContext id="camel"
> xmlns="http://activemq.apache.org/camel/schema/spring";>
> 
>     <!-- You can use a <package> element for each root package to search
> for Java routes -->
>     <package>org.foo.bar</package>
> 
>     <!-- You can use Spring XML syntax to define the routes here using the
> <route> element -->
>     <route>
>       <from uri="activemq:example.A"/>
>       <to uri="activemq:example.B"/>
>     </route>
>   </camelContext>
> 
> 
> 
>   <!-- lets create a command agent to respond to message based admin
> commands on the ActiveMQ.Agent topic -->
>   <commandAgent xmlns="http://activemq.org/config/1.0"/>
> 
> 
>   <!-- An embedded servlet engine for serving up the Admin console -->
>   <jetty xmlns="http://mortbay.com/schemas/jetty/1.0";>
>     <connectors>
>       <nioConnector port="8161" />
>     </connectors>
> 
>     <handlers>
>       <webAppContext contextPath="/admin"
> resourceBase="${activemq.base}/webapps/admin" logUrlOnStart="true" />
>       <webAppContext contextPath="/demo"
> resourceBase="${activemq.base}/webapps/demo" logUrlOnStart="true" />
>     </handlers>
>   </jetty>
> 
> 
> 
>   
>  
>     <!-- Oracle DataSource Sample Setup -->
>   <bean id="oracle-ds" class="org.apache.commons.dbcp.BasicDataSource"
> destroy-method="close">
>     <property name="driverClassName"
> value="oracle.jdbc.driver.OracleDriver"/>
>     <property name="url" value="jdbc:oracle:thin:@xx.xx.xx.xx"/>
>     <property name="username" value="xxx"/>
>     <property name="password" value="xxx"/>
>     <property name="poolPreparedStatements" value="true"/>
>   </bean>
> Thanks
> 

-- 
View this message in context: 
http://www.nabble.com/Got-minus-one-from-a-read-call-tp14734900s2354p14948097.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to