Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem to use JPA DataSource with oracle

    Hi,

    I'm trying to use smartClient, deployed on JBOSS 7.1.1 server.
    I want to use JPA datasource using orcale DB.

    here is my datasource file:
    Code:
    <DataSource
        ID="salesOffice"
        serverType="jpa"
        schemaBean="com.eclipse.SalesOffice.model.SalesOffice"
    />
    and the persistence.xml file:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="2.0" 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_2_0.xsd">
    	<persistence-unit name="ds" transaction-type="RESOURCE_LOCAL">
    	    <class>com.eclipse.SalesOffice.model.SalesOffice</class>
    	    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    		<properties>
    			<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
    			<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin://*******:1521:VECLQA01"/>			
    			<property name="javax.persistence.jdbc.user" value="eclipse"/>
    			<property name="javax.persistence.jdbc.password" value="******"/>
    			<property name="eclipselink.logging.level" value="FINEST"/>
    			<property name="eclipselink.target-server" value="JBoss"/>
    			
    		</properties>
    	</persistence-unit>	
    </persistence>
    when trying to access my page i'm getting the following errors:
    1)
    Code:
    java.sql.SQLException: 
    No suitable driver found for jdbc:oracle:thin://*******:1521:VECLQA01
    2)
    Code:
    java.lang.Exception: 
    Unable to create autoDerive datasource for DataSource
     salesOffice. 'schemaBean' did not refer to a valid mapped JPA bean

    #2
    java.lang.Exception:
    Unable to create autoDerive datasource for DataSource
    salesOffice. 'schemaBean' did not refer to a valid mapped JPA bean
    This means exactly what it says. Your value for schemaBean ("com.eclipse.SalesOffice.model.SalesOffice") does not refer to a bean that has been registered with JPA.

    It might be due to the capitalized Java package name (which is unusual) or it may be something simple like you've made changes to files but not saved them or re-deployed them.

    Comment


      #3
      i double checked the spelling - there is no error.
      also - same spelling in the datasource file and in the persistence.xml file.

      is there something else i need to do in order to register the bean ?

      Comment


        #4
        We're just doing standard JPA calls to find your entity, so it appears it's not registered properly in some way.

        To test that it's been validly registered and is visible to your web application, you could try adding direct JPA calls in a DMI (see QuickStart Guide).

        Comment


          #5
          Hi,

          I found this thread is similar enough to my issue that I decided to reply here instead of starting a new one.

          I am similarly trying to get the default JPADatasource to work with JBoss 7.1.1. I am using MySQL instead of the OP's Oracle but I don't think that's an issue.

          I am using SmartGWTPower 3.1p. I have recently succeeded deploying the JPADS sample enclosed in the SGWT package on JBoss using my own MySQL based PersistenceUnit.

          The only changes I had to make on the sample files are the ff:
          - replace persistence.xml to use our settings
          - Change server.properties to use BMT
          - persistence unit name in web.xml as described in the server properties comments for BMT

          That setup works fine as is.

          Now, I modified the country_DataSource.ds.xml file to use autoDeriveSchema instead of listing the fields in the xml:

          Code:
          <DataSource
              ID="country_DataSource"
              serverType="jpa"
              beanClassName="com.smartgwt.sample.server.Country"
              autoDeriveSchema="true"
              autoDeriveTitles="true"
              >
          <!--     <fields>
                  <field name="countryId"     type="sequence" hidden="true"   primaryKey="true" />
                  <field name="countryCode"   type="text"     title="Code"    required="true"   />
                  <field name="countryName"   type="text"     title="Country" required="true"   />
              </fields>
           --></DataSource>
          Now, the sample doesn't work. Digging through the html and accessing the link I found there:

          JPADS_js/sc/DataSourceLoader?dataSource=country_DataSource,city_DataSource

          The servlet shows an exception similar to the OP's. Here's the full page on that URL:

          Code:
           <BR>BaseServlet Global Exception<BR>
          <PRE>
          javax.servlet.ServletException: java.lang.Exception: Unable to create autoDerive datasource for DataSource country_DataSource. 'schemaBean' did not refer to a valid mapped JPA bean
          	at com.isomorphic.jpa.JPADataSource.init(JPADataSource.java:284)
          	at com.isomorphic.datasource.DataSource.initialize(DataSource.java:400)
          	at com.isomorphic.datasource.BasicDataSource.fromConfig(BasicDataSource.java:163)
          	at com.isomorphic.datasource.DataSource.fromConfig(DataSource.java:385)
          	at com.isomorphic.datasource.FileSystemDSRepo.loadDS(FileSystemDSRepo.java:110)
          	at com.isomorphic.datasource.DataSource.forName(DataSource.java:204)
          	at com.isomorphic.datasource.DataSource.forName(DataSource.java:195)
          	at com.isomorphic.datasource.DataSource.forName(DataSource.java:184)
          	at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:119)
          	at com.isomorphic.datasource.PoolableDataSourceFactory.makeObject(PoolableDataSourceFactory.java:127)
          	at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:94)
          	at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:89)
          	at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:83)
          	at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:126)
          	at com.isomorphic.servlet.DataSourceLoader.doGet(DataSourceLoader.java:94)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
          	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
          	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
          	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
          	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
          	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
          	at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
          	at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154)
          	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
          	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
          	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
          	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
          	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
          	at java.lang.Thread.run(Thread.java:679)
          
          	at com.isomorphic.servlet.DataSourceLoader.processRequest(DataSourceLoader.java:185)
          	at com.isomorphic.servlet.DataSourceLoader.doGet(DataSourceLoader.java:94)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
          	at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:152)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
          	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
          	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
          	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
          	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
          	at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
          	at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:154)
          	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
          	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
          	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
          	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
          	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
          	at java.lang.Thread.run(Thread.java:679)
          </PRE>
          I suspect that the way autoDeriveSchema checks for JPA mapping is different or is bypassed when fields are explicitly defined in the xml. And this same lookup is not used when executing the CRUD functions since the earlier works fine.

          Now, for my questions:
          - Is there anything wrong with the modification I made to the ds.xml?
          - How exactly does the default JPADS lookup the mapped JPA bean when autoDeriving? the code snippet around here might be useful if the full source of the JPADataSource class is not available to us:
          Code:
          	at com.isomorphic.jpa.JPADataSource.init(JPADataSource.java:284)
          Thanks,

          Ech

          Comment


            #6
            daphnad:
            This may be some kind of issue with either having multiple Hibernate libs in the classpath or with the libs that come with JBoss having special issues.
            Could you run your SGWT app with JBoss Hibernate libs disabled, that way we will be sure that only Hibernate libs shipped with SGWT will be used. To disable JBoss jpa module, remove "org.jboss.as.jpa" extension and all related stuff from your server configuration. This should work.
            Then try to do the opposite - re-enable "org.jboss.as.jpa" extension and ensure that no other Hibernate libs are in classpath (remove HB libs from SGWT). Check how things work this time.


            echdskech:
            in your case "schemaBean" attribute indeed is not defined. In this context "beanClassName" is not the same, try adding this to your data source:
            Code:
            schemaBean="com.smartgwt.sample.server.Country"

            Comment


              #7
              sabaka:

              Thanks that worked. I guess this part of the documentation misled me:

              For a DataSource with serverType: "jpa1" or "jpa", automatically derive the dataSource's schema from the annotated JPA class named in the schemaBean property. If the schemaBean property is not defined, derive the schema from the annotated JPA class named in the beanClassName property
              that was from this page:

              http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/docs/serverds/DataSource.html#autoDeriveSchema

              I interpreted it as beanClassName being used as the default schemaBean when schemaBean is not defined.

              Thanks for the reply. =)

              Comment

              Working...
              X