PDA

View Full Version : Help, Netbeans Hosted Mode Fails on RPC Calls ??



chalu
3 Aug 2010, 4:45 AM
I am doing my GXT development with Netbeans 6.9 and I am having trouble debugging with hosted mode. It runs and loads the app quite well but when I do anything that requires stuff from the RPC service I always get the error message "Error while dispatching incoming RPC call"



Caused by: javax.persistence.PersistenceException: [PersistenceUnit: thriftrPU] Unable to build EntityManagerFactory

// which was
Caused by: org.hibernate.HibernateException: Could not find datasource

//Also
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet para



It appears that my "thriftrPU" PersistentUnit is not been located by the hosted mode "server" which I think is Jetty. Please how do I go about this. I am developing "blindly" cos now I don't have a debugger.

Colin Alworth
3 Aug 2010, 11:04 AM
This doesn't appear to have anything to do with GWT, except that GWT started the call into your persistence code. Can you run a jsp or regular servlet and make a call like this - it looks like hibernate is having trouble finding the persistence mechanism.

Also: Try Eclipse - it works very nicely when using google's plugin. It may also deal with this issue.

chalu
11 Sep 2010, 11:45 AM
Ok, I am trying to move my development to Eclipse (Helios) and I have a simple app with JPA annotated entities, I have my persistence.xml and hibernate.cfg.xml files but I have these issues :


[WARN] Server class 'com.extjs.gxt.ui.client.data.ListLoadResult' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/C:/Java/javalibs/gxt_2.1.1/gxt.jar' to the web app classpath for this session
For additional info see: file:/C:/eclipse/plugins/com.google.gwt.eclipse.sdkbundle.2.0.4_2.0.4.v201006301309/gwt-2.0.4/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'com.bitrunk.gxt.utils.shared.model.BaseModelType' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/C:/Users/chalu/workspace/GXTUtils/war/WEB-INF/classes/' to the web app classpath for this session
For additional info see: file:/C:/eclipse/plugins/com.google.gwt.eclipse.sdkbundle.2.0.4_2.0.4.v201006301309/gwt-2.0.4/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'net.sf.gilead.pojo.gwt.LightEntity' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/C:/Java/javalibs/gilead/gilead-core-1.3.0.1169.jar' to the web app classpath for this session
For additional info see: file:/C:/eclipse/plugins/com.google.gwt.eclipse.sdkbundle.2.0.4_2.0.4.v201006301309/gwt-2.0.4/doc/helpInfo/webAppClassPath.html
[WARN] Server class 'javax.persistence.PersistenceException' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/C:/Java/javalibs/hibernate-distribution-3.5.5-Final/lib/jpa/hibernate-jpa-2.0-api-1.0.0.Final.jar' to the web app classpath for this session
For additional info see: file:/C:/eclipse/plugins/com.google.gwt.eclipse.sdkbundle.2.0.4_2.0.4.v201006301309/gwt-2.0.4/doc/helpInfo/webAppClassPath.html


And then the show stopper is this one :


Starting Jetty on port 8888
[WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.extjs.gxt.ui.client.data.ListLoadResult com.bitrunk.gxt.apps.sample.SampleApp.client.RemoteGateway.listCourses()' threw an unexpected exception: javax.persistence.PersistenceException: No Persistence provider for EntityManager named DiSCS_PU
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:581)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:188)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named DiSCS_PU
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at com.bitrunk.gxt.apps.sample.SampleApp.server.JpaController.<init>(JpaController.java:24)
at com.bitrunk.gxt.apps.sample.SampleApp.server.RemoteGatewayImpl$1.<init>(RemoteGatewayImpl.java:62)
at com.bitrunk.gxt.apps.sample.SampleApp.server.RemoteGatewayImpl.listCourses(RemoteGatewayImpl.java:62)
at com.bitrunk.gxt.apps.sample.SampleApp.server.RemoteGatewayServlet.listCourses(RemoteGatewayServlet.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
... 22 more

As you can see, the exception is caused by PersistenceException: No Persistence provider for EntityManager named DiSCS_PU
where DiSCS_PU is the persistence unit name for my app as seen here :


<?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="DiSCS_PU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DiSCS_DS</non-jta-data-source>
<class>com.bitrunk.gxt.apps.sample.SampleApp.shared.Course</class>
<class>com.bitrunk.gxt.apps.sample.SampleApp.shared.CourseType</class>
<class>com.bitrunk.gxt.apps.sample.SampleApp.shared.Gender</class>
<class>com.bitrunk.gxt.apps.sample.SampleApp.shared.Faculty</class>
<class>com.bitrunk.gxt.apps.sample.SampleApp.shared.Programme</class>
<class>com.bitrunk.gxt.apps.sample.SampleApp.shared.ProgrammeLevel</class>
<class>com.bitrunk.gxt.apps.sample.SampleApp.shared.ProgrammeType</class>
<class>com.bitrunk.gxt.apps.sample.SampleApp.shared.SemesterType</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/discsdb"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="asAdm1n"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
</persistence>

U can also see the hibernate config for completeness :


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.password">asAdm1n</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/discsdb</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.default_schema">discsdb</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
</session-factory>
</hibernate-configuration>

I am liking Eclipse already, but finding my way around it has not been easy at all. Please how do I solve this, what am I missing. By the way I downloaded Tomcat 6 (the zip version as instructed, not the windows installer) but I've not been able to go it from my browser as I can't figure the URL, should be something like http://localhost:8080/......

Thanks for your suggestions.

Colin Alworth
12 Sep 2010, 2:58 PM
The actual error appears to be coming from this stack trace:

Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named DiSCS_PU
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
at com.bitrunk.gxt.apps.sample.SampleApp.server.JpaController.<init>(JpaController.java:24)
at com.bitrunk.gxt.apps.sample.SampleApp.server.RemoteGatewayImpl$1.<init>(RemoteGatewayImpl.java:62)
at com.bitrunk.gxt.apps.sample.SampleApp.server.RemoteGatewayImpl.listCourses(RemoteGatewayImpl.java:62)
at com.bitrunk.gxt.apps.sample.SampleApp.server.RemoteGatewayServlet.listCourses(RemoteGatewayServlet.java:60)
...which points to an issue in your hibernate setup. I dont know a lot about hibernate, and the GXT forums are an unlikely place to get such support.

The first set of warnings you posted are odd - I suspect that you are launching tomcat by running a main class, with classpath fully assembled instead of letting it put together its own classpath from the contents of the webapp. Look into the J2EE server features in Eclipse to launch Tomcat in the same way it would be run in production, specifically the Web Tools Platform. It is possible that these warnings point to a setup issue that also causes your other problems...