Hi, all:
I'm using Smartclient 9.0, and trying to get a simple JPA server side example to work. I've searched and found a couple of tips, but none of them work for me.
I know that i have JPA set up right because I have a regular java class that can access and use the JPA entities-- i run the class to populate the default database.
When i start up and load the ds on the page, i get three exceptions ( in this order, full stack traces are below but summarized here for clarity):
My Datasource looks like this:
And my persistence.xml:
I know my persistence.xml class references are right because i have a test class that works:
I do not understand where the 'EntityManager named ds' message is coming from-- i dont have anything called 'ds', so i presume this is an isomorphic thing.
Of course the model class names match the ds-- checked that.
I found several threads and documentation that recommended various combinations of schemaBean and beanClassName. I've tried with each one specified, and with both specified.
I've seen another post in the forum in which ISOMorphic Administrators said [paraphrasing] "JPA messages are confusing, that's why you should use SQLDatasources as a first choice". In our case, we really need to use JPA, so switching to SQLDataSource is not an option. I will say that the search on this topic does not give me any hope that JPA integration actually works.
The source view of the JPA feature samples do not work as written. For example, in the feature explorer, the source .js file leaves out defining the data source.
What can i try next? Full traces are below, thanks in advance for help.
I'm using Smartclient 9.0, and trying to get a simple JPA server side example to work. I've searched and found a couple of tips, but none of them work for me.
I know that i have JPA set up right because I have a regular java class that can access and use the JPA entities-- i run the class to populate the default database.
When i start up and load the ds on the page, i get three exceptions ( in this order, full stack traces are below but summarized here for clarity):
Code:
javax.persistence.PersistenceException: Unable to initialize default EMF provider: com.isomorphic.jpa.EMFProviderLMT Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named ds java.lang.Exception: Unable to create autoDerive datasource for DataSource locations. 'schemaBean' did not refer to a valid mapped JPA bean
Code:
<DataSource ID="locations" serverType="jpa" autoDeriveSchema="true" schemaBean="com.colinx.model.Location" beanClassName="com.colinx.model.Location" />
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="locations" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>com.colinx.model.Area</class> <class>com.colinx.model.Location</class> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="javax.persistence.jdbc.url" value="jdbc:h2:c://temp/testlocs"/> <property name="javax.persistence.jdbc.password" value="sa"/> <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/> <property name="javax.persistence.jdbc.user" value="sa"/> <!-- create tables on the fly --> <property name="eclipselink.ddl-generation" value="create-tables"/> <!-- run the sql directly against the database --> <property name="eclipselink.ddl-generation.output-mode" value="database"/> <property name="eclipselink.logging.level" value="FINE"/> </properties> </persistence-unit> </persistence>
Code:
public class SampleDataGenerator { public static String PERSISTENCE_UNIT = "locations"; public SampleDataGenerator(){ } protected EntityManager em = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT).createEntityManager(); public void loadJsonFromResource(String resourceUrl) throws IOException{ String json = FileUtils.readFileToString( FileUtils.toFile(this.getClass().getResource(resourceUrl))); loadJson(json); } public void loadJson(String json){ Type listType = new TypeToken<ArrayList<Area>>() { }.getType(); List<Area> areas = new Gson().fromJson(json, listType); em.getTransaction().begin(); for (Area loc : areas){ em.persist(loc); } em.getTransaction().commit(); } public List<Area> fetchAll(){ return em.createQuery(em.getCriteriaBuilder().createQuery(Area.class)).getResultList(); } public static void main(String[] args) throws IOException{ SampleDataGenerator sg = new SampleDataGenerator(); sg.loadJsonFromResource("/sampledata.json"); //now do a select to see how many we have List<Area> areas = sg.fetchAll(); System.out.println(String.format("Created %d Entities Found After Load",areas.size()) ); } }
Of course the model class names match the ds-- checked that.
I found several threads and documentation that recommended various combinations of schemaBean and beanClassName. I've tried with each one specified, and with both specified.
I've seen another post in the forum in which ISOMorphic Administrators said [paraphrasing] "JPA messages are confusing, that's why you should use SQLDatasources as a first choice". In our case, we really need to use JPA, so switching to SQLDataSource is not an option. I will say that the search on this topic does not give me any hope that JPA integration actually works.
The source view of the JPA feature samples do not work as written. For example, in the feature explorer, the source .js file leaves out defining the data source.
What can i try next? Full traces are below, thanks in advance for help.
Code:
=== 2013-09-18 08:53:25,451 [ec-4] INFO RequestContext - URL: '/locedit/locations.jsp', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36': Safari with Accept-Encoding header === 2013-09-18 08:53:25,869 [ec-4] DEBUG LoadISCTag - isomorphicURI not specified in tag, defaulting to: isomorphic/ === 2013-09-18 08:53:25,899 [ec-4] DEBUG XML - Parsed XML from C:\Users\dcowden\Documents\NetBeansProjects\locedit\target\locedit\shared\ds\locations.ds.xml: 1ms === 2013-09-18 08:53:25,942 [ec-4] DEBUG EMF - Initializing default EMF provider: com.isomorphic.jpa.EMFProviderLMT === 2013-09-18 08:53:25,994 [ec-4] WARN JPA2DataSource - Failed to derive data source 'locations_inheritsFrom' for class com.colinx.model.Location javax.persistence.PersistenceException: Unable to initialize default EMF provider: com.isomorphic.jpa.EMFProviderLMT at com.isomorphic.jpa.EMF.initializeProvider(EMF.java:259) at com.isomorphic.jpa.EMF.getProvider(EMF.java:243) at com.isomorphic.jpa.EMF.getEntityManager(EMF.java:129) at com.isomorphic.jpa.JPA2DataSource.deriveDS(JPA2DataSource.java:46) at com.isomorphic.jpa.JPADataSource.init(JPADataSource.java:343) at com.isomorphic.datasource.DataSource.initialize(DataSource.java:452) at com.isomorphic.datasource.BasicDataSource.fromConfig(BasicDataSource.java:166) at com.isomorphic.datasource.DataSource.fromConfig(DataSource.java:437) at com.isomorphic.datasource.FileSystemDSRepo.loadDS(FileSystemDSRepo.java:110) at com.isomorphic.datasource.DataSource.forName(DataSource.java:228) at com.isomorphic.datasource.DataSource.forName(DataSource.java:220) at com.isomorphic.datasource.DataSource.forName(DataSource.java:209) at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:130) at com.isomorphic.datasource.PoolableDataSourceFactory.makeObject(PoolableDataSourceFactory.java:138) at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1220) at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:84) at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:95) at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:86) at com.isomorphic.taglib.LoadDSTag.outputJS(LoadDSTag.java:87) at com.isomorphic.taglib.LoadDSTag.doStartTag(LoadDSTag.java:59) at org.apache.jsp.locations_jsp._jspx_meth_isomorphic_005floadDS_005f0(locations_jsp.java:149) at org.apache.jsp.locations_jsp._jspService(locations_jsp.java:78) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named ds at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at com.isomorphic.jpa.EMFProviderLMT.<init>(EMFProviderLMT.java:73) at com.isomorphic.jpa.EMFProviderLMT.<init>(EMFProviderLMT.java:52) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at com.isomorphic.jpa.EMF.initializeProvider(EMF.java:257) ... 47 more === 2013-09-18 08:53:26,016 [ec-4] ERROR LoadDSTag - Exception while attempting to process a loadDS tag. java.lang.Exception: Unable to create autoDerive datasource for DataSource locations. 'schemaBean' did not refer to a valid mapped JPA bean at com.isomorphic.jpa.JPADataSource.init(JPADataSource.java:350) at com.isomorphic.datasource.DataSource.initialize(DataSource.java:452) at com.isomorphic.datasource.BasicDataSource.fromConfig(BasicDataSource.java:166) at com.isomorphic.datasource.DataSource.fromConfig(DataSource.java:437) at com.isomorphic.datasource.FileSystemDSRepo.loadDS(FileSystemDSRepo.java:110) at com.isomorphic.datasource.DataSource.forName(DataSource.java:228) at com.isomorphic.datasource.DataSource.forName(DataSource.java:220) at com.isomorphic.datasource.DataSource.forName(DataSource.java:209) at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:130) at com.isomorphic.datasource.PoolableDataSourceFactory.makeObject(PoolableDataSourceFactory.java:138) at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1220) at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:84) at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:95) at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:86) at com.isomorphic.taglib.LoadDSTag.outputJS(LoadDSTag.java:87) at com.isomorphic.taglib.LoadDSTag.doStartTag(LoadDSTag.java:59) at org.apache.jsp.locations_jsp._jspx_meth_isomorphic_005floadDS_005f0(locations_jsp.java:149) at org.apache.jsp.locations_jsp._jspService(locations_jsp.java:78) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at com.isomorphic.servlet.CompressionFilter.doFilter(CompressionFilter.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
Comment