You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Andrey Grebnev <fo...@udm.ru> on 2005/10/09 13:04:41 UTC

Problem with application-scoped database pool

Hi

  I am trying to port my application AtLeap
(https://atleap.dev.java.net) from Geronimo 1.0 M4 to M5.
AtLeap uses Spring and Hibernate. AtLeap was working
correclty with M4. But now I have the followin error:

15:44:27,421 ERROR [GBeanInstanceState] Error while
starting; GBean is now in the FAILED state:
objectName="geron
imo.server:J2EEApplication=atleapEAR,J2EEServer=geronimo,j2eeType=WebModule,name=atleap.war"
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined i
n ServletContext resource
[/WEB-INF/applicationContext-hibernate.xml]: Can't resolve
reference to bean 'dataSourc
e' while setting property 'dataSource'; nested exception is
org.springframework.beans.factory.BeanCreationExcepti
on: Error creating bean with name 'dataSource' defined in
ServletContext resource [/WEB-INF/applicationContext-re
sources.xml]: Initialization of bean failed; nested
exception is javax.naming.NamingException: could not look
up
: env/jdbc/atleap_db
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataSource' defined in Se
rvletContext resource
[/WEB-INF/applicationContext-resources.xml]: Initialization
of bean failed; nested exceptio
n is javax.naming.NamingException: could not look up :
env/jdbc/atleap_db
javax.naming.NamingException: could not look up :
env/jdbc/atleap_db [Root exception is
java.lang.IllegalStateExc
eption: Could not get proxy]
    at
org.apache.geronimo.naming.java.ReadOnlyContext.lookup(ReadOnlyContext.java:222)
    at
org.apache.geronimo.naming.java.RootContext.lookup(RootContext.java:51)
    at
javax.naming.InitialContext.lookup(InitialContext.java:347)
    at
org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:123)
    at
org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
    at
org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:121)
    at
org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:74)
    at
org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.java:104)
...
Caused by: java.lang.IllegalStateException: Could not get
proxy
    at
org.apache.geronimo.naming.reference.ResourceReference.getContent(ResourceReference.java:55)
    at
org.apache.geronimo.naming.java.ReadOnlyContext.lookup(ReadOnlyContext.java:220)
    ... 83 more
Caused by: java.lang.IllegalStateException: Operations can
only be invoke while the GBean is running: geronimo.se
rver:J2EEApplication=atleapEAR,J2EEServer=geronimo,JCAResource=tranql-connector-1.0.rar,j2eeType=JCAManagedConnec
tionFactory,name=atleapDataSource
    at
org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:793)
    at
org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:180)
    at
org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java:175)
    at
org.apache.geronimo.naming.reference.ResourceReference.getContent(ResourceReference.java:53)
    ... 84 more

I have the following structure of my EAR:

atleap.ear
  -> META-INF
    - application.xml
    - geronimo-application.xml
  -> atleap.war
    ...
    -> WEB-INF
      - web.xml
      - geronimo-web.xml
  - database-plan.xml
  - tranql-connector-1.0.rar

The below I will show most important parts of config files

<?xml version="1.0" encoding="UTF-8"?>
<application
	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/application_1_4.xsd"
	version="1.4">
	<module>
		<connector>tranql-connector-1.0.rar</connector>
	</module>
	<module>
    	<web>
            <web-uri>atleap.war</web-uri>
            <context-root>/atleap</context-root>
    	</web>
	</module>
</application>


<?xml version="1.0" encoding="UTF-8"?>
<application
	xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.0"
	configId="atleapEAR"
	parentId="org/apache/geronimo/Server">
	<module>
		<connector>tranql-connector-1.0.rar</connector>
   		<alt-dd>database-plan.xml</alt-dd>
	</module>
</application>


<?xml version="1.0" encoding="UTF-8"?>
<connector
    xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.0"
    configId="atleapDB"
    >
  <dependency>
    <uri>mysql/jars/mysql-connector-java-3.1.7-bin.jar</uri>
  </dependency>

  <resourceadapter>
    <outbound-resourceadapter>
      <connection-definition>
        <connectionfactory-interface>
          javax.sql.DataSource
        </connectionfactory-interface>
        <connectiondefinition-instance>
          <name>atleapDataSource</name>
          <config-property-setting name="UserName">
            test
          </config-property-setting>
          <config-property-setting name="Password">
            test
          </config-property-setting>
          <config-property-setting name="Driver">
            com.mysql.jdbc.Driver
          </config-property-setting>
          <config-property-setting name="ConnectionURL">
            jdbc:mysql://localhost:3306/atleap_db?characterEncoding=utf-8&amp;useUnicode=true&amp;autoReconnect=true
          </config-property-setting>
          <config-property-setting
name="CommitBeforeAutocommit">
            true
          </config-property-setting>
          <config-property-setting
name="ExceptionSorterClass">
            org.tranql.connector.NoExceptionsAreFatalSorter
          </config-property-setting>
          <connectionmanager>
            <local-transaction/>
            <single-pool>
              <max-size>20</max-size>
              <min-size>1</min-size>
              <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
              <idle-timeout-minutes>30</idle-timeout-minutes>
              <match-one/>
            </single-pool>
          </connectionmanager>
        </connectiondefinition-instance>
      </connection-definition>
    </outbound-resourceadapter>
  </resourceadapter>
</connector>


<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
         xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.0"
         configId="atleapWAR"
         >

	<context-root>/atleap</context-root>
    <context-priority-classloader>false</context-priority-classloader>
    <naming:resource-ref>
        <naming:ref-name>jdbc/atleap_db</naming:ref-name>
        <naming:resource-link>atleapDataSource</naming:resource-link>
    </naming:resource-ref>
</web-app>


<?xml version="1.0" encoding="UTF-8"?>

<web-app id="web-app_1"
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/web-app_2_4.xsd"
version="2.4">
   <display-name>atleap</display-name>

     <resource-ref id="ResourceRef_1">
        <description>DB Connection</description>
        <res-ref-name>jdbc/atleap_db</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
</web-app>


Any ideas? Maybe after you have removed <global-jndi-name>
I should specify JNDI in some other place? Or maybe I
should specify some explicit dependences for class-loader?

Thanks beforhand.

--
Best regards.
Andrey Grebnev
----------------------------------------------------
Треть суток на треть дешевле!
МАРК-ИТТ ввёл льготные цены на ночной трафик в Народном Интернете
цены на трафик на 30% ниже дневных в период с 1:00 до 9:00.
600-й - 1.75р, Профессиональный - 1.89р, Деловой - 1.96р, 5-ка - 2,03р, Домашний - 2,10р

Re: Problem with application-scoped database pool

Posted by Andrey Grebnev <fo...@udm.ru>.
On Sun, 9 Oct 2005 08:59:06 -0700
 David Jencks <da...@yahoo.com> wrote:
> I can't tell from the stack trace, but my guess is that
> the jndi lookup  is occuring during  the init method of a
> servlet.  Unfortunately as  noted in
> http://issues.apache.org/jira/browse/GERONIMO-513 we
> currently  have no way to force the target of a jndi
> reference to start before the  client.  Very
> unfortunately the only workaround I know of at the moment
>  is to deploy the datasource as a separate module.
> 
> I think we need to fix this for 1.0
> 
> thanks
> david jencks
> 

This code is called from listener's init method.

The issue GERONIMO-513 which you adduced affects version
M3, but this approach correctly worked under versions M3
and M4. It only does not work under Geronimo 1.0 M5. I
suppose that problem is that you have changed something
during removing <global-jndi-name>.

--
Best regards.
Andrey Grebnev
----------------------------------------------------
Треть суток на треть дешевле!
МАРК-ИТТ ввёл льготные цены на ночной трафик в Народном Интернете
цены на трафик на 30% ниже дневных в период с 1:00 до 9:00.
600-й - 1.75р, Профессиональный - 1.89р, Деловой - 1.96р, 5-ка - 2,03р, Домашний - 2,10р

Re: Problem with application-scoped database pool

Posted by David Jencks <da...@yahoo.com>.
I can't tell from the stack trace, but my guess is that the jndi lookup  
is occuring during  the init method of a servlet.  Unfortunately as  
noted in http://issues.apache.org/jira/browse/GERONIMO-513 we currently  
have no way to force the target of a jndi reference to start before the  
client.  Very unfortunately the only workaround I know of at the moment  
is to deploy the datasource as a separate module.

I think we need to fix this for 1.0

thanks
david jencks

On Oct 9, 2005, at 4:04 AM, Andrey Grebnev wrote:

> Hi
>
>   I am trying to port my application AtLeap
> (https://atleap.dev.java.net) from Geronimo 1.0 M4 to M5.
> AtLeap uses Spring and Hibernate. AtLeap was working
> correclty with M4. But now I have the followin error:
>
> 15:44:27,421 ERROR [GBeanInstanceState] Error while
> starting; GBean is now in the FAILED state:
> objectName="geron
> imo.server: 
> J2EEApplication=atleapEAR,J2EEServer=geronimo,j2eeType=WebModule,name=a 
> tleap.war"
> org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'sessionFactory' defined i
> n ServletContext resource
> [/WEB-INF/applicationContext-hibernate.xml]: Can't resolve
> reference to bean 'dataSourc
> e' while setting property 'dataSource'; nested exception is
> org.springframework.beans.factory.BeanCreationExcepti
> on: Error creating bean with name 'dataSource' defined in
> ServletContext resource [/WEB-INF/applicationContext-re
> sources.xml]: Initialization of bean failed; nested
> exception is javax.naming.NamingException: could not look
> up
> : env/jdbc/atleap_db
> org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'dataSource' defined in Se
> rvletContext resource
> [/WEB-INF/applicationContext-resources.xml]: Initialization
> of bean failed; nested exceptio
> n is javax.naming.NamingException: could not look up :
> env/jdbc/atleap_db
> javax.naming.NamingException: could not look up :
> env/jdbc/atleap_db [Root exception is
> java.lang.IllegalStateExc
> eption: Could not get proxy]
>     at
> org.apache.geronimo.naming.java.ReadOnlyContext.lookup(ReadOnlyContext. 
> java:222)
>     at
> org.apache.geronimo.naming.java.RootContext.lookup(RootContext.java:51)
>     at
> javax.naming.InitialContext.lookup(InitialContext.java:347)
>     at
> org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java: 
> 123)
>     at
> org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:85)
>     at
> org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:121)
>     at
> org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.j 
> ava:74)
>     at
> org.springframework.jndi.JndiObjectLocator.lookup(JndiObjectLocator.jav 
> a:104)
> ...
> Caused by: java.lang.IllegalStateException: Could not get
> proxy
>     at
> org.apache.geronimo.naming.reference.ResourceReference.getContent(Resou 
> rceReference.java:55)
>     at
> org.apache.geronimo.naming.java.ReadOnlyContext.lookup(ReadOnlyContext. 
> java:220)
>     ... 83 more
> Caused by: java.lang.IllegalStateException: Operations can
> only be invoke while the GBean is running: geronimo.se
> rver:J2EEApplication=atleapEAR,J2EEServer=geronimo,JCAResource=tranql- 
> connector-1.0.rar,j2eeType=JCAManagedConnec
> tionFactory,name=atleapDataSource
>     at
> org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.ja 
> va:793)
>     at
> org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java: 
> 180)
>     at
> org.apache.geronimo.kernel.basic.BasicKernel.invoke(BasicKernel.java: 
> 175)
>     at
> org.apache.geronimo.naming.reference.ResourceReference.getContent(Resou 
> rceReference.java:53)
>     ... 84 more
>
> I have the following structure of my EAR:
>
> atleap.ear
>   -> META-INF
>     - application.xml
>     - geronimo-application.xml
>   -> atleap.war
>     ...
>     -> WEB-INF
>       - web.xml
>       - geronimo-web.xml
>   - database-plan.xml
>   - tranql-connector-1.0.rar
>
> The below I will show most important parts of config files
>
> <?xml version="1.0" encoding="UTF-8"?>
> <application
> 	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/application_1_4.xsd"
> 	version="1.4">
> 	<module>
> 		<connector>tranql-connector-1.0.rar</connector>
> 	</module>
> 	<module>
>     	<web>
>             <web-uri>atleap.war</web-uri>
>             <context-root>/atleap</context-root>
>     	</web>
> 	</module>
> </application>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <application
> 	xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.0"
> 	configId="atleapEAR"
> 	parentId="org/apache/geronimo/Server">
> 	<module>
> 		<connector>tranql-connector-1.0.rar</connector>
>    		<alt-dd>database-plan.xml</alt-dd>
> 	</module>
> </application>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <connector
>     xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.0"
>     configId="atleapDB"
>>
>   <dependency>
>     <uri>mysql/jars/mysql-connector-java-3.1.7-bin.jar</uri>
>   </dependency>
>
>   <resourceadapter>
>     <outbound-resourceadapter>
>       <connection-definition>
>         <connectionfactory-interface>
>           javax.sql.DataSource
>         </connectionfactory-interface>
>         <connectiondefinition-instance>
>           <name>atleapDataSource</name>
>           <config-property-setting name="UserName">
>             test
>           </config-property-setting>
>           <config-property-setting name="Password">
>             test
>           </config-property-setting>
>           <config-property-setting name="Driver">
>             com.mysql.jdbc.Driver
>           </config-property-setting>
>           <config-property-setting name="ConnectionURL">
>              
> jdbc:mysql://localhost:3306/atleap_db?characterEncoding=utf-8&amp; 
> useUnicode=true&amp;autoReconnect=true
>           </config-property-setting>
>           <config-property-setting
> name="CommitBeforeAutocommit">
>             true
>           </config-property-setting>
>           <config-property-setting
> name="ExceptionSorterClass">
>             org.tranql.connector.NoExceptionsAreFatalSorter
>           </config-property-setting>
>           <connectionmanager>
>             <local-transaction/>
>             <single-pool>
>               <max-size>20</max-size>
>               <min-size>1</min-size>
>                
> <blocking-timeout-milliseconds>5000</blocking-timeout-milliseconds>
>               <idle-timeout-minutes>30</idle-timeout-minutes>
>               <match-one/>
>             </single-pool>
>           </connectionmanager>
>         </connectiondefinition-instance>
>       </connection-definition>
>     </outbound-resourceadapter>
>   </resourceadapter>
> </connector>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app
> xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.0"
>          xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.0"
>          configId="atleapWAR"
>>
>
> 	<context-root>/atleap</context-root>
>     <context-priority-classloader>false</context-priority-classloader>
>     <naming:resource-ref>
>         <naming:ref-name>jdbc/atleap_db</naming:ref-name>
>         <naming:resource-link>atleapDataSource</naming:resource-link>
>     </naming:resource-ref>
> </web-app>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <web-app id="web-app_1"
> 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/web-app_2_4.xsd"
> version="2.4">
>    <display-name>atleap</display-name>
>
>      <resource-ref id="ResourceRef_1">
>         <description>DB Connection</description>
>         <res-ref-name>jdbc/atleap_db</res-ref-name>
>         <res-type>javax.sql.DataSource</res-type>
>         <res-auth>Container</res-auth>
>         <res-sharing-scope>Shareable</res-sharing-scope>
>     </resource-ref>
> </web-app>
>
>
> Any ideas? Maybe after you have removed <global-jndi-name>
> I should specify JNDI in some other place? Or maybe I
> should specify some explicit dependences for class-loader?
>
> Thanks beforhand.
>
> --
> Best regards.
> Andrey Grebnev
> ----------------------------------------------------
> Треть суток на треть дешевле!
> МАРК-ИТТ ввёл льготные цены на ночной трафик в Народном Интернете
> цены на трафик на 30% ниже дневных в период с 1:00 до 9:00.
> 600-й - 1.75р, Профессиональный - 1.89р, Деловой - 1.96р, 5-ка -  
> 2,03р, Домашний - 2,10р
>