4 Replies Latest reply on May 4, 2009 9:02 PM by Chris Simons

    Problem connecting to Oracle from Seam

    utish raj Newbie
      I am directly trying to connect to Oracle 10g R1 from Seam (jboss-seam-2.1.1.GA). I'm using jboss-4.2.2GA. I used ojdbc14.jar for the driver. My persistence.xml file:



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

      <!-- Persistence deployment descriptor for dev profile -->

      <persistence xmlns="http://java.sun.com/xml/ns/persistence"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"

      version="1.0">


      <persistence-unit name="testSeamOracle" transaction-type="JTA">

      <provider>org.hibernate.ejb.HibernatePersistence</provider>

      <jta-data-source>java:/testSeamOracleDatasource</jta-data-source>

      <properties>

      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>

      <property name="hibernate.hbm2ddl.auto" value="update"/>

      <property name="hibernate.show_sql" value="true"/>

      <property name="hibernate.format_sql" value="true"/>

      <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>

      </properties>

      </persistence-unit>


      </persistence>








      and testSeamOracle-ds.xml file:


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


      <!DOCTYPE datasources

      PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"

      "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">


      <datasources>


      <local-tx-datasource>

      <jndi-name>testSeamOracleDatasource</jndi-name>

      <connection-url>jdbc:oracle:thin:@10.30.2.10:1521:police</connection-url>

      <driver-class>oracle.jdbc.OracleDriver</driver-class>

      <user-name>frq_2</user-name>

      <password>abc123</password>

      <!--

      <exception-sorter-class-name>

      org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter

      </exception-sorter-class-name>

      <metadata>

      <type-mapping>mySQL</type-mapping>

      </metadata>

      -->

      </local-tx-datasource>


      </datasources>








      It throws the following exception:


      17:25:56,972 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null

      17:25:56,972 ERROR [JDBCExceptionReporter] You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.; - nested throwable: (javax.resource.ResourceException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.)

      17:25:56,972 ERROR [STDERR] Apr 30, 2009 5:25:56 PM com.sun.facelets.FaceletViewHandler handleRenderException

      SEVERE: Error Rendering View[/HteCmt008FeducrclassiList.xhtml]

      javax.faces.FacesException: javax.el.ELException: /HteCmt008FeducrclassiList.xhtml @47,74 rendered="#{empty hteCmt008FeducrclassiList.resultList}": Error reading 'resultList' on type org.domain.testseamoracle.session.HteCmt008FeducrclassiList_$$_javassist_1

      at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:373)

      at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:276)

      at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)

      at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:220)

      at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:215)

      at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)

      at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)

      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)

      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)

      at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)

      at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)

      at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:196)

      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)

      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)

      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)

      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)

      at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)

      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

      at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)

      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

      at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)

      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

      at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)

      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)

      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)

      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)

      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)

      at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)

      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

      at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)

      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

      at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)

      at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)

      at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)

      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)

      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)

      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

      at java.lang.Thread.run(Thread.java:595)

      Caused by: javax.el.ELException: /HteCmt008FeducrclassiList.xhtml @47,74 rendered="#{empty hteCmt008FeducrclassiList.resultList}": Error reading 'resultList' on type org.domain.testseamoracle.session.HteCmt008FeducrclassiList_$$_javassist_1

      at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)

      at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:370)

      ... 56 more

      Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Cannot open connection

      at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)

      at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:73)

      at org.jboss.seam.framework.EntityQuery.initResultList(EntityQuery.java:74)

      at org.jboss.seam.framework.EntityQuery.getResultList(EntityQuery.java:65)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:585)

      at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)

      at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)

      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)

      at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)

      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

      at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:95)

      at org.jboss.seam.util.Work.workInTransaction(Work.java:47)

      at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:89)

      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

      at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)

      at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)

      at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)

      at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)

      at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)

      at org.domain.testseamoracle.session.HteCmt008FeducrclassiList_$$_javassist_1.getResultList(HteCmt008FeducrclassiList_$$_javassist_1.java)

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

      at java.lang.reflect.Method.invoke(Method.java:585)

      at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)

      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)

      at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)

      at org.jboss.el.parser.AstPropertyS

      17:25:56,987 ERROR [STDERR] uffix.getValue(AstPropertySuffix.java:53)

      at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)

      at org.jboss.el.parser.AstEmpty.getValue(AstEmpty.java:29)

      at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)

      at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)

      ... 57 more

      Caused by: org.hibernate.exception.GenericJDBCException: Cannot open connection

      at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)

      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)

      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)

      at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426)

      at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)

      at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)

      at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)

      at org.hibernate.loader.Loader.doQuery(Loader.java:673)

      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)

      at org.hibernate.loader.Loader.doList(Loader.java:2220)

      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)

      at org.hibernate.loader.Loader.list(Loader.java:2099)

      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)

      at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)

      at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)

      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)

      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)

      at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)

      ... 90 more

      Caused by: org.jboss.util.NestedSQLException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.; - nested throwable: (javax.resource.ResourceException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.)

      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:94)

      at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)

      at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)

      ... 104 more

      Caused by: javax.resource.ResourceException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.

      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:387)

      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:842)

      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:88)

      ... 106 more

      17:25:57,003 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null

      17:25:57,003 ERROR [JDBCExceptionReporter] You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.; - nested throwable: (javax.resource.ResourceException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.)

      17:25:57,003 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null

      17:25:57,003 ERROR [JDBCExceptionReporter] You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.; - nested throwable: (javax.resource.ResourceException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.)

      17:25:57,003 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null

      17:25:57,003 ERROR [JDBCExceptionReporter] You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.; - nested throwable: (javax.resource.ResourceException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.)

      17:25:57,003 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null

      17:25:57,003 ERROR [JDBCExceptionReporter] You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.; - nested throwable: (javax.resource.ResourceException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.)

      17:25:57,066 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState: null

      17:25:57,066 ERROR [JDBCExceptionReporter] You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.; - nested throwable: (javax.resource.ResourceException: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.)


      Any help would be appreciated.
        • 1. Re: Problem connecting to Oracle from Seam
          Arbi Sookazian Master


          <connection-url>jdbc:oracle:thin:@10.30.2.10:1521:police</connection-url>

          that's cool.  the cops got shutdown!


          j/k.  I've never seen that exception before: You are trying to use a connection factory that has been shut down: ManagedConnectionFactory is null.


          Try something like this from our Seam/Oracle app:


          persistence.xml:


          <?xml version="1.0" encoding="UTF-8"?>
          <!-- Persistence deployment descriptor for dev profile -->
          <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
                       version="1.0">
                       
             <persistence-unit name="InternalJavaWebAppTemplate">
                <provider>org.hibernate.ejb.HibernatePersistence</provider>
                <jta-data-source>java:/InternalJavaWebAppTemplateDatasource</jta-data-source>
                <properties>
                   <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
                   <property name="hibernate.hbm2ddl.auto" value="validate"/>
                   <property name="hibernate.show_sql" value="true"/>
                   <property name="hibernate.format_sql" value="true"/>
                   <property name="jboss.entity.manager.factory.jndi.name" value="java:/InternalJavaWebAppTemplateEntityManagerFactory"/>
                </properties>
             </persistence-unit>
              
          </persistence>



          It looked like your persistence.xml's persistence-unit config was missing an entry for jboss.entity.manager.factory.jndi.name and there was also missing the EntityManagerFactory value as well.

          • 2. Re: Problem connecting to Oracle from Seam
            utish raj Newbie

            Thanks for the reply but that didn't help!

            • 3. Re: Problem connecting to Oracle from Seam
              Chris Simons Expert

              I have a few additional entries in my data source that you do not.


              Also, my driver-class is different than your's.  I have:


              oracle.jdbc.driver.OracleDriver


              Also, you want to include:


              <metadata>
              <type-mapping>Oracle9i</type-mapping>
              </metadata>


              And:


              <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>



              But the actual error from the JDBC driver is: Cannot open connection.  My guess is that the server you are deploying your application either does not have access to the database server, or, the user name/password is wrong.


              Can you ping the db server?  Also, if the db server is the same as the app server, you should change the IP to localhost.

              • 4. Re: Problem connecting to Oracle from Seam
                Chris Simons Expert

                In your persistence.xml, are you sure that you have something like this:



                <property name="jboss.entity.manager.factory.jndi.name" value="java:/testSeamOracleDatasource/entityManagerFactory"/>