I am getting this error while trying to save something to Datastore.
I have tried to search but not getting anything.
This is the code where i am saving to datastore :
Student temp = null;
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
Student stu = new Student(name);
temp = pm.makePersistent(stu);
} finally {
pm.close();
}
return temp;
Any kind of information on this is appreciated!
EDIT: adding stack trace :
at com.sample.dbops.DBManager.saveStudent(DBManager.java:18)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:64)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at com.google.appengine.tools.development.PrivilegedJspServlet.access$101(PrivilegedJspServlet.java:23)
at com.google.appengine.tools.development.PrivilegedJspServlet$2.run(PrivilegedJspServlet.java:59)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.tools.development.PrivilegedJspServlet.service(PrivilegedJspServlet.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
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:712)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:54)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:268)
at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
at com.google.appengine.tools.development.StaticFileUtils.serveWelcomeFileAsForward(StaticFileUtils.java:80)
at com.google.appengine.tools.development.LocalResourceFileServlet.maybeServeWelcomeFile(LocalResourceFileServlet.java:251)
at com.google.appengine.tools.development.LocalResourceFileServlet.doGet(LocalResourceFileServlet.java:117)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1093)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:124)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
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:712)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:54)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:313)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:313)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:506)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:830)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:381)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:396)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
The stack trace did not help much, but one reason for not initializing the PersistenceManagerFactory is that it could not find a persistence unit that you specified in the JDOHelper.getPersistenceManagerFactory(String) method.
e.g. If your PMF's get() method looks like this:
public static synchronized PersistenceManagerFactory get() {
if(pmfInstance == null) {
pmfInstance = JDOHelper.getPersistenceManagerFactory(
"transactions-optional");
}
return pmfInstance;
}
Then you must have a jdoconfig.xml in your classpath (e.g. WEB-INF/classes) that defines a persistence unit as follows: (with same name that you used in getPersistenceManagerFactory). In this case "transactions-optional"
<persistence-manager-factory name="transactions-optional">
<property name="javax.jdo.PersistenceManagerFactoryClass" value="org.datanucleus.store.appengine.jdo.DatastoreJDOPersistenceManagerFactory"/>
<property name="javax.jdo.option.ConnectionURL" value="appengine"/>
<property name="javax.jdo.option.NontransactionalRead" value="true"/>
<property name="javax.jdo.option.NontransactionalWrite" value="false"/>
</persistence-manager-factory>
Solved : I was calling the above code from a static method, now i made it an instance method and it worked.
but still confused?
Related
I'm trying to connect to Google Cloud SQL database from a servlet hosted in local AppEngine Server. I'm able to connect when project is deployed on Google app engine but not from localhost appengine server. I'm getting the below error messages.
HTTP ERROR 500
Problem accessing /. Reason:
java.lang.IllegalAccessError: com/google/appengine/repackaged/com/google/common/base/Platform
Caused by:
java.sql.SQLException: java.lang.IllegalAccessError: com/google/appengine/repackaged/com/google/common/base/Platform
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:877)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:873)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:443)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:233)
at com.example.appengine.cloudsql.CloudSqlServlet.doGet(CloudSqlServlet.java:88)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:134)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:95)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:508)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.IllegalAccessError: com/google/appengine/repackaged/com/google/common/base/Platform
at com.google.appengine.repackaged.com.google.common.base.Ticker$1.read(Ticker.java:69)
at com.google.appengine.repackaged.com.google.common.base.Stopwatch.elapsedNanos(Stopwatch.java:178)
at com.google.appengine.repackaged.com.google.common.base.Stopwatch.elapsed(Stopwatch.java:191)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$LoadingValueReference.elapsedNanos(LocalCache.java:3665)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$Segment.getAndRecordStats(LocalCache.java:2382)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2337)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2295)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2208)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache.get(LocalCache.java:4062)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4066)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4995)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:5001)
at com.google.appengine.api.appidentity.AppIdentityServiceImpl.getAccessToken(AppIdentityServiceImpl.java:272)
at com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential.intercept(AppIdentityCredential.java:98)
at com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential$AppEngineCredentialWrapper.intercept(AppIdentityCredential.java:243)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at com.google.cloud.sql.mysql.SslSocketFactory.obtainInstanceMetadata(SslSocketFactory.java:370)
at com.google.cloud.sql.mysql.SslSocketFactory.fetchInstanceSslInfo(SslSocketFactory.java:282)
at com.google.cloud.sql.mysql.SslSocketFactory.getInstanceSslInfo(SslSocketFactory.java:262)
at com.google.cloud.sql.mysql.SslSocketFactory.createAndConfigureSocket(SslSocketFactory.java:181)
at com.google.cloud.sql.mysql.SslSocketFactory.create(SslSocketFactory.java:150)
at com.google.cloud.sql.mysql.SocketFactory.connect(SocketFactory.java:47)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2251)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2284)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:140)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:148)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
... 42 more
Caused by:
java.lang.IllegalAccessError: com/google/appengine/repackaged/com/google/common/base/Platform
at com.google.appengine.repackaged.com.google.common.base.Ticker$1.read(Ticker.java:69)
at com.google.appengine.repackaged.com.google.common.base.Stopwatch.elapsedNanos(Stopwatch.java:178)
at com.google.appengine.repackaged.com.google.common.base.Stopwatch.elapsed(Stopwatch.java:191)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$LoadingValueReference.elapsedNanos(LocalCache.java:3665)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$Segment.getAndRecordStats(LocalCache.java:2382)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2337)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2295)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2208)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache.get(LocalCache.java:4062)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4066)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4995)
at com.google.appengine.repackaged.com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:5001)
at com.google.appengine.api.appidentity.AppIdentityServiceImpl.getAccessToken(AppIdentityServiceImpl.java:272)
at com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential.intercept(AppIdentityCredential.java:98)
at com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential$AppEngineCredentialWrapper.intercept(AppIdentityCredential.java:243)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at com.google.cloud.sql.mysql.SslSocketFactory.obtainInstanceMetadata(SslSocketFactory.java:370)
at com.google.cloud.sql.mysql.SslSocketFactory.fetchInstanceSslInfo(SslSocketFactory.java:282)
at com.google.cloud.sql.mysql.SslSocketFactory.getInstanceSslInfo(SslSocketFactory.java:262)
at com.google.cloud.sql.mysql.SslSocketFactory.createAndConfigureSocket(SslSocketFactory.java:181)
at com.google.cloud.sql.mysql.SslSocketFactory.create(SslSocketFactory.java:150)
at com.google.cloud.sql.mysql.SocketFactory.connect(SocketFactory.java:47)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2251)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2284)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2083)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:806)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:140)
at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:148)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:410)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:328)
at java.sql.DriverManager.getConnection(DriverManager.java:571)
at java.sql.DriverManager.getConnection(DriverManager.java:233)
at com.example.appengine.cloudsql.CloudSqlServlet.doGet(CloudSqlServlet.java:88)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:134)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:95)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:508)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Powered by Jetty://
Here is the servlet code
package com.example.appengine.cloudsql;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
// [START example]
#SuppressWarnings("serial")
public class CloudSqlServlet extends HttpServlet {
#Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException,
ServletException {
String path = req.getRequestURI();
if (path.startsWith("/favicon.ico")) {
return; // ignore the request for favicon.ico
}
// store only the first two octets of a users ip address
String userIp = req.getRemoteAddr();
InetAddress address = InetAddress.getByName(userIp);
if (address instanceof Inet6Address) {
// nest indexOf calls to find the second occurrence of a character in a string
// an alternative is to use Apache Commons Lang: StringUtils.ordinalIndexOf()
userIp = userIp.substring(0, userIp.indexOf(":", userIp.indexOf(":") + 1)) + ":*:*:*:*:*:*";
} else if (address instanceof Inet4Address) {
userIp = userIp.substring(0, userIp.indexOf(".", userIp.indexOf(".") + 1)) + ".*.*";
}
GoogleCredential credential = GoogleCredential.getApplicationDefault();
final String createTableSql = "CREATE TABLE IF NOT EXISTS visits ( visit_id INT NOT NULL "
+ "AUTO_INCREMENT, user_ip VARCHAR(46) NOT NULL, timestamp DATETIME NOT NULL, "
+ "PRIMARY KEY (visit_id) )";
final String createVisitSql = "INSERT INTO visits (user_ip, timestamp) VALUES (?, ?)";
final String selectSql = "SELECT user_ip, timestamp FROM visits ORDER BY timestamp DESC "
+ "LIMIT 10";
PrintWriter out = resp.getWriter();
resp.setContentType("text/plain");
String url;
if (System
.getProperty("com.google.appengine.runtime.version").startsWith("Google App Engine/")) {
// Check the System properties to determine if we are running on appengine or not
// Google App Engine sets a few system properties that will reliably be present on a remote
// instance.
url = System.getProperty("ae-cloudsql.cloudsql-database-url");
try {
// Load the class that provides the new "jdbc:google:mysql://" prefix.
Class.forName("com.mysql.jdbc.GoogleDriver");
} catch (ClassNotFoundException e) {
throw new ServletException("Error loading Google JDBC Driver", e);
}
} else {
// Set the url with the local MySQL database connection url when running locally
url = System.getProperty("ae-cloudsql.local-database-url");
}
log("connecting to: " + url);
try (Connection conn = DriverManager.getConnection(url);
PreparedStatement statementCreateVisit = conn.prepareStatement(createVisitSql)) {
conn.createStatement().executeUpdate(createTableSql);
statementCreateVisit.setString(1, userIp);
statementCreateVisit.setTimestamp(2, new Timestamp(new Date().getTime()));
statementCreateVisit.executeUpdate();
try (ResultSet rs = conn.prepareStatement(selectSql).executeQuery()) {
out.print("Last 10 visits:\n");
while (rs.next()) {
String savedIp = rs.getString("user_ip");
String timeStamp = rs.getString("timestamp");
out.print("Time: " + timeStamp + " Addr: " + savedIp + "\n");
}
}
} catch (SQLException e) {
throw new ServletException("SQL error", e);
}
}
}
// [END example]
When developing and testing locally, you have a few choices:
access a local MySQL server
access a Cloud SQL instance
The J7 example is configured to use the Google MySQL driver in the cloud injected by the <use-google-connector-j>true</use-google-connector-j> in appengine-web.xml and to use the standard MySQL driver with the Google SocketFactory when running locally.
To run using your own local MySQL instance, in WEB-INF/appengine-web.xml change the ae-cloudsql.local-database-url property to the connection string for your database, probably something like: jdbc:mysql:localhost:3306/${database}?user=${user}&password=${password}&useSSL=false (assuming you update the properties in your pom.xml or mvn appengine:devserver -Duser=... -Dpassword=... -Ddatabase=... -D INSTANCE_CONNECTION_NAME=projectID:region:instance
The error you are seeing is saying that your connection string is specifying a driver that isn't recognized. If you are sure that all is well, then you might try adding the following (which shouldn't be needed anymore):
try {
Class.forName("com.mysql.jdbc.Driver")
} catch (ClassNotFoundException e) {
...
}
I will run the driver example, but it should work.
I am having issues with GAE in the api explorer.I am trying to use objectify to save to a datastore but I am getting this error:
{
"error": {
"message": "java.lang.NoClassDefFoundError: Could not initialize class Project.service.OfyService",
"code": 503,
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "java.lang.NoClassDefFoundError: Could not initialize class Project.service.OfyService"
}
]
}
}
I tried to google it a bunch but came up empty handed. I am really new to GAE and somewhat new to Java. Here is what shows up in intelliJ's console:
java.lang.NoClassDefFoundError: Could not initialize class Project.service.OfyService
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestrict ed(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at Project.saveProfile(ProjectApi.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
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:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:491)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Jan 25, 2015 12:39:14 PM com.google.api.server.spi.SystemService invokeServiceMethod
SEVERE: Could not initialize class Project.service.OfyService
java.lang.NoClassDefFoundError: Could not initialize class Project.service.OfyService
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:191)
at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
at Project.saveProfile(ProjectApi.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
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:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:127)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:98)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:491)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Here is my OfyService:
public class OfyService {
/**
* This static block ensure the entity registration.
*/
static {
factory().register(Game.class);
factory().register(Platform.class);
factory().register(Profile.class);
}
/**
* Use this static method for getting the Objectify service object in order to make sure the
* above static block is executed before using Objectify.
* #return Objectify service object.
*/
public static Objectify ofy() {
return ObjectifyService.ofy();
}
/**
* Use this static method for getting the Objectify service factory.
* #return ObjectifyFactory.
*/
public static ObjectifyFactory factory() {
return ObjectifyService.factory();
}
}
And my api:
#ApiMethod(name = "saveProfile", path = "profile", httpMethod = HttpMethod.POST)
public Profile saveProfile(final User user, ProfileForm profileForm)
throws UnauthorizedException {
if(user == null)
{
throw new UnauthorizedException("Authorization Required.");
}
String mainEmail = user.getEmail();
String userId = user.getUserId();
String displayName = profileForm.getDisplayName();
Profile profile = new Profile(userId, displayName, mainEmail);
ofy().save().entity(profile).now();
return profile;
}
GAE SDK Version: 1.9.17
Objectify Version: 5.1.4
I have tried multiple different version combinations to see if it was the SDK's.
NoClassDefFound is thrown if the class cannot be found, or if it cannot be loaded. So, if static initialisation fails, you will get this error. In your case, the class failing to load is your own ObjectifyService, so its likely that factory().register(...) is throwing an exception.
To help diagnose the issue, you can wrap all the registrations in your static init block in a try/catch, log the exception/stacktrace then rethrow. The stack trace will help identify which of Profile, Game and Platform are causing the exception.
There is also no reason to wrap ObjectifyService like this, if you're using dependency injection you could just register classes at startup using your standard DI pattern, that way any exceptions will flow out of your startup as normal.
Don't forget to declare #Entity for persisted objects
and #Id for their unique identifiers
#Entity
public class Profile {
#Id
Long userId;
String displayName;
String mainEmail;
...
}
I just wanted to put this into an answer because I also just spent a few hours having the same problem + solution as the OP and it wasn't till later that I bothered to read the comments =P
Putting this here so it is clearer for people to see:
The issue was I did not have #Entity on all of my entities that I was registering!
I am trying to update an entity in the datastore but when mgr.close gets called, the entity manager is null.
I don't set the entity manager to null anywhere in the code. I don't think that app engine is setting the entity manager to null for me either, it just seems like the entity manager may have crashed or something on its own.
Does the entity manager have a life cycle or something I am not aware of? Is there something I could be doing in the code to make the entity manager close prematurely?
While waiting on this question to be answered I noticed that my update method (generated by cloud endpoints and then altered by myself) didn't have the contains method that checks to see if the object is already present in the datastore. I edited the method and got the same error except it occurred inside the contains method. The code is displayed below.
#ApiMethod(name = "updateParty")
public Party updateParty(Party party) {
EntityManager mgr = getEntityManager();
//update party with serving url
try {
if (!containsParty(party)) {
throw new EntityNotFoundException("Object does not exist");
}
if (party.getFlyerServingUrl() == null && party.getFlyerStr() != null) {
blob = new BlobKey(party.getFlyerStr());
options = Builder.withBlobKey(blob);
servingUrl = imagesService.getServingUrl(options);
party.setFlyerServingUrl(servingUrl);
}
mgr.persist(party);
} finally {
mgr.close();
}
return party;
}
contains method:
private boolean containsParty(Party party) {
EntityManager mgr = getEntityManager();
boolean contains = true;
try {
if(party.getId() == null){
contains = false;
}else{
Party item = mgr.find(Party.class, party.getId());
if (item == null) {
contains = false;
}
}
} finally {
mgr.close();
}
return contains;
}
EDIT
*updated DEBUG level stack trace for the second set of methods:*
2014-03-05 10:20:40.484 /_ah/spi/com.mastermindcode.theincrowd.PartyEndpoint.updateParty 500 15ms 0kb Google-HTTP-Java-Client/1.16.0-rc (gzip) module=default version=1
75.108.229.93 - - [05/Mar/2014:10:20:40 -0800] "POST /_ah/spi/com.mastermindcode.theincrowd.PartyEndpoint.updateParty HTTP/1.1" 500 117 - "Google-HTTP-Java-Client/1.16.0-rc (gzip)" "incrowdmobile.appspot.com" ms=15 cpu_ms=0 cpm_usd=0.000013 app_engine_release=1.9.0 instance=00c61b117c5f081d6ff00df1aac468f916fc26
D 2014-03-05 10:20:40.474
com.google.api.server.spi.SystemServiceServlet execute: serviceName=com.mastermindcode.theincrowd.PartyEndpoint methodName=updateParty
D 2014-03-05 10:20:40.474
com.google.api.server.spi.SystemService findService: com.mastermindcode.theincrowd.PartyEndpoint => com.mastermindcode.theincrowd.PartyEndpoint#2c3abe
D 2014-03-05 10:20:40.474
com.google.api.server.spi.ConfiguredObjectMapper$Builder build: Cache hit, reusing ObjectMapper
D 2014-03-05 10:20:40.474
com.google.api.server.spi.SystemServiceServlet execute: serviceMethod=Method: public com.mastermindcode.theincrowd.Party com.mastermindcode.theincrowd.PartyEndpoint.updateParty(com.mastermindcode.theincrowd.Party) , Resolved Return Type: class com.mastermindcode.theincrowd.Party, Resolved Parameter Types: [class com.mastermindcode.theincrowd.Party]
D 2014-03-05 10:20:40.474
com.google.api.server.spi.SystemService findService: com.mastermindcode.theincrowd.PartyEndpoint => com.mastermindcode.theincrowd.PartyEndpoint#2c3abe
D 2014-03-05 10:20:40.474
com.google.api.server.spi.ConfiguredObjectMapper$Builder build: Cache hit, reusing ObjectMapper
D 2014-03-05 10:20:40.474
com.google.api.server.spi.SystemService findService: com.mastermindcode.theincrowd.PartyEndpoint => com.mastermindcode.theincrowd.PartyEndpoint#2c3abe
D 2014-03-05 10:20:40.474
com.google.api.server.spi.request.ServletRequestParamReader read: requestBody={"Id":{"appId":"s~incrowdmobile","complete":true,"id":"5317797651415040","kind":"Party"},"featuredPosition":0,"flyerStr":"AMIfv968K2J3isP3BSq67ru69rgCgnDkA0n0Fq1rqk8XhvuqeAItMXImE9JI-trSr3RxMEkLswCRAZib_FnsVtF3BVrCtVmJtkxDnSmIcgIKtcXhq1KNsOxy3EnWEdBc73boMhGr4EcVQqZhbPhiTru81JEtPqX-G-MZCQzw6lb4tyforoGVII8","flyerUploadUrl":"https://incrowdmobile.appspot.com/_ah/upload/AMmfu6bB660x2WmQHniLC84sjVvyOwlGwJEGLWCbp6-tBbalHrqo6vmc0lSDeR0CY18kOmphXxAZf5FGV9Lb5Hw2Ln74ZDCUX1DCmxiwS1QHv3iGXWTjqzg60hA5W34x_RSzklXtq3M3/ALBNUaYAAAAAUxdtHwJEZ3edBNcVIp_G5tbuCBUYtJ6o/","genre":"Electronic Dance","headPromoterId":"24001","headPromoterName":"Kreshendo","isClaimable":false,"location":{"latitude":30.088441848754883,"longitude":-95.11273193359375},"maxAge":0,"minAge":0,"partyHashtag":"#hdvfcdg","partyLocation":{"latitude":30.088441848754883,"longitude":-95.11273193359375},"partyName":"hfcdcvh","promoTeamId":"0","id":{"kind":"Party","appId":"s~incrowdmobile","id":"5317797651415040","complete":true},"kind":"partyendpoint#resourcesItem","etag":"\"o5z31f-yQaEVGsxCvjrmPxs4_Z4/I4PX-YUoH_IOu_T_IRwC_CBHXwQ\""}
D 2014-03-05 10:20:40.475
com.google.api.server.spi.request.ServletRequestParamReader deserializeParams: deserialize: class com.mastermindcode.theincrowd.Party com.mastermindcode.theincrowd.Party#f2869f injected into unnamed param[0]
D 2014-03-05 10:20:40.475
com.google.api.server.spi.SystemService invokeServiceMethod: params=[com.mastermindcode.theincrowd.Party#f2869f] (String)
I 2014-03-05 10:20:40.479
com.google.api.server.spi.SystemService invokeServiceMethod: cause={0}
java.lang.NullPointerException
at com.google.appengine.api.datastore.KeyTranslator.convertToPb(KeyTranslator.java:49)
at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl$V3KeyBatcher.toPb(AsyncDatastoreServiceImpl.java:111)
at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl$V3KeyBatcher.toPb(AsyncDatastoreServiceImpl.java:102)
at com.google.appengine.api.datastore.Batcher$BatchIterator.<init>(Batcher.java:176)
at com.google.appengine.api.datastore.Batcher$1.<init>(Batcher.java:270)
at com.google.appengine.api.datastore.Batcher.getBatches(Batcher.java:270)
at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl.doBatchGet(AsyncDatastoreServiceImpl.java:301)
at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl.get(AsyncDatastoreServiceImpl.java:280)
at com.google.appengine.api.datastore.DatastoreServiceImpl$1.runInternal(DatastoreServiceImpl.java:69)
at com.google.appengine.api.datastore.DatastoreServiceImpl$1.runInternal(DatastoreServiceImpl.java:66)
at com.google.appengine.api.datastore.TransactionRunner.runInTransaction(TransactionRunner.java:29)
at com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:66)
at com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:56)
at com.google.appengine.datanucleus.WrappedDatastoreService.get(WrappedDatastoreService.java:60)
at com.google.appengine.datanucleus.EntityUtils.getEntityFromDatastore(EntityUtils.java:665)
at com.google.appengine.datanucleus.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:543)
at org.datanucleus.state.JDOStateManager.loadFieldsFromDatastore(JDOStateManager.java:1638)
at org.datanucleus.state.JDOStateManager.loadUnloadedFieldsInFetchPlan(JDOStateManager.java:1363)
at org.datanucleus.state.JDOStateManager.detach(JDOStateManager.java:2718)
at org.datanucleus.ObjectManagerImpl.performDetachOnCloseWork(ObjectManagerImpl.java:4571)
at org.datanucleus.ObjectManagerImpl.performDetachOnClose(ObjectManagerImpl.java:4534)
at org.datanucleus.ObjectManagerImpl.close(ObjectManagerImpl.java:1105)
at org.datanucleus.api.jpa.JPAEntityManager.close(JPAEntityManager.java:193)
at com.mastermindcode.theincrowd.PartyEndpoint.containsParty(PartyEndpoint.java:440)
at com.mastermindcode.theincrowd.PartyEndpoint.updateParty(PartyEndpoint.java:393)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:45)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:124)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:82)
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:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:188)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at java.lang.Thread.run(Thread.java:724)
E 2014-03-05 10:20:40.479
com.google.api.server.spi.SystemService invokeServiceMethod: null
java.lang.NullPointerException
at com.google.appengine.api.datastore.KeyTranslator.convertToPb(KeyTranslator.java:49)
at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl$V3KeyBatcher.toPb(AsyncDatastoreServiceImpl.java:111)
at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl$V3KeyBatcher.toPb(AsyncDatastoreServiceImpl.java:102)
at com.google.appengine.api.datastore.Batcher$BatchIterator.<init>(Batcher.java:176)
at com.google.appengine.api.datastore.Batcher$1.<init>(Batcher.java:270)
at com.google.appengine.api.datastore.Batcher.getBatches(Batcher.java:270)
at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl.doBatchGet(AsyncDatastoreServiceImpl.java:301)
at com.google.appengine.api.datastore.AsyncDatastoreServiceImpl.get(AsyncDatastoreServiceImpl.java:280)
at com.google.appengine.api.datastore.DatastoreServiceImpl$1.runInternal(DatastoreServiceImpl.java:69)
at com.google.appengine.api.datastore.DatastoreServiceImpl$1.runInternal(DatastoreServiceImpl.java:66)
at com.google.appengine.api.datastore.TransactionRunner.runInTransaction(TransactionRunner.java:29)
at com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:66)
at com.google.appengine.api.datastore.DatastoreServiceImpl.get(DatastoreServiceImpl.java:56)
at com.google.appengine.datanucleus.WrappedDatastoreService.get(WrappedDatastoreService.java:60)
at com.google.appengine.datanucleus.EntityUtils.getEntityFromDatastore(EntityUtils.java:665)
at com.google.appengine.datanucleus.DatastorePersistenceHandler.fetchObject(DatastorePersistenceHandler.java:543)
at org.datanucleus.state.JDOStateManager.loadFieldsFromDatastore(JDOStateManager.java:1638)
at org.datanucleus.state.JDOStateManager.loadUnloadedFieldsInFetchPlan(JDOStateManager.java:1363)
at org.datanucleus.state.JDOStateManager.detach(JDOStateManager.java:2718)
at org.datanucleus.ObjectManagerImpl.performDetachOnCloseWork(ObjectManagerImpl.java:4571)
at org.datanucleus.ObjectManagerImpl.performDetachOnClose(ObjectManagerImpl.java:4534)
at org.datanucleus.ObjectManagerImpl.close(ObjectManagerImpl.java:1105)
at org.datanucleus.api.jpa.JPAEntityManager.close(JPAEntityManager.java:193)
at com.mastermindcode.theincrowd.PartyEndpoint.containsParty(PartyEndpoint.java:440)
at com.mastermindcode.theincrowd.PartyEndpoint.updateParty(PartyEndpoint.java:393)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:45)
at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:124)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:82)
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:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:437)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:188)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at java.lang.Thread.run(Thread.java:724
Following thread [entities cannot be cast to javassist.util.proxy.Proxy, i do have now a server side error ( tks thomas)
I wasn't able to face the real problem within my app.
java.lang.ClassCastException: org.nit.persistance.entities.Manufacturers_.$$_javassist_3 cannot be cast to javassist.util.proxy.Proxy
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:148)
at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:73)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:758)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:4419)
at org.hibernate.event.internal.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:333)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:259)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1017)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:944)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:671)
at org.hibernate.type.EntityType.resolve(EntityType.java:489)
at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:168)
at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1112)
at org.hibernate.loader.Loader.processResultSet(Loader.java:969)
at org.hibernate.loader.Loader.doQuery(Loader.java:917)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:348)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:318)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2143)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3939)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:461)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:430)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:207)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:263)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1017)
at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:173)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2413)
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:913)
at org.nit.persistance.dao.impl.FichesImpl.readbyPK(FichesImpl.java:24)
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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy13.readbyPK(Unknown Source)
at org.nit.server.CEM.CEMFiches.fetch(CEMFiches.java:52)
at org.nit.server.service.FichesService.fetch(FichesService.java:11)
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.web.bindery.requestfactory.server.ReflectiveServiceLayer.invoke(ReflectiveServiceLayer.java:182)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.invoke(ServiceLayerDecorator.java:111)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.invoke(ServiceLayerDecorator.java:111)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.processInvocationMessages(SimpleRequestProcessor.java:463)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:233)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:135)
at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:133)
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)java.lang.ClassCastException: org.nit.persistance.entitesManufacturers_.$$_javassist_3 cannot be cast to javassist.util.proxy.Proxy
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:148)
at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:73)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:758)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:4419)
at org.hibernate.event.internal.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:333)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:259)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1017)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:944)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:671)
at org.hibernate.type.EntityType.resolve(EntityType.java:489)
at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:168)
at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1112)
at org.hibernate.loader.Loader.processResultSet(Loader.java:969)
at org.hibernate.loader.Loader.doQuery(Loader.java:917)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:348)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:318)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2143)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3939)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:461)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:430)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:207)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:263)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1017)
at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:173)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2413)
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:913)
at org.nit.persistance.dao.impl.FichesImpl.readbyPK(FichesImpl.java:24)
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 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy13.readbyPK(Unknown Source)
at org.nit.server.CEM.CEMFiches.fetch(CEMFiches.java:52)
at org.nit.server.service.FichesService.fetch(FichesService.java:11)
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.web.bindery.requestfactory.server.ReflectiveServiceLayer.invoke(ReflectiveServiceLayer.java:182)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.invoke(ServiceLayerDecorator.java:111)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.invoke(ServiceLayerDecorator.java:111)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.processInvocationMessages(SimpleRequestProcessor.java:463)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:233)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:135)
at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:133)
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)
What does this part means ?
at com.sun.proxy.$Proxy13.readbyPK(Unknown Source)
at org.nit.server.CEM.CEMFiches.fetch(CEMFiches.java:52)
at org.nit.server.service.FichesService.fetch(FichesService.java:11)
Error is on Manufacturers entity, but I am working on Fiches.
Fiches is linked by a many-to-one relation with References
References is linked by a many-to-one relation with Products
Products is linked by a many-to-one relation with Manufacturers.
Could it be a problem with one of my proxies ?
CEMFiches : ( Line 52 is return fichesDAO.readbyPK(fichesPK);)
public static Fiches fetch (String metier, String sitegeo, String cptdossier, Integer numligne) {
if (fichesDAO == null) {
HttpServletRequest request = RequestFactoryServlet.getThreadLocalRequest();
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
fichesDAO =context.getBean(IFichesDAO.class);
}
try {
FichesPK fichesPK = new FichesPK(metier,sitegeo, cptdossier, numligne);
return fichesDAO.readbyPK(fichesPK);
} catch (PersistanceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
IfichesDAO is ( #transactional is used )
public interface IFichesDAO {
#Transactional(readOnly=true)
public void save(Fiches fiches) throws PersistanceException;
public Fiches readbyPK(FichesPK fichesPK) throws PersistanceException;
}
FichesImpl is
#Transactional(readOnly=true)
public Fiches readbyPK(FichesPK fichesPK){
return (Fiches)getSessionFactory().getCurrentSession().get(Fiches.class, fichesPK);
}
FichesService :
public class FichesService
{
public Fiches fetch(FichesPK id) { return CEMFiches.fetch(id); }
public FichesPK fetchPK(FichesPK id) { return CEMFiches.fetchPK(id); }
public Fiches fetch(String metier, String sitegeo, String cptdossier, Integer numligne) { return CEMFiches.fetch(metier, sitegeo, cptdossier, numligne); }
}
I also hit this issue while attempting to render an entity as JSON using Spring's #ResponseBody annotation. The issue turned out to be a relationship annotated as #ManyToOne with a FetchType of LAZY. The error message was not at all helpful. Switching to EAGER fetch solved the problem.
It may be helpful to note that in my case, the target entity also had a relationship of #ManyToOne which was recursive (target table had a foreign key to itself) which was also mapped as LAZY. Both relationships had to be switched to EAGER to get the problem resolved.
I encountered the same error and the strange thing is that all the other entities in my project run ok, except one. According to Boris the Spider's suggestion, I checked my project and found that there is a jar called weld-osgi-bundle.jar(in theJava EE 6 Libraries, provided by myEclipse10.0) contains some javassist code which may be conflict with javassist-3.18.1-GA.jarin my web libraries. So I removed it, and the problem gets solved.
So I ran into this issue, and I thought I would add some additional details for those who might have the same problem.
I had a collection of dependencies, and one imported org.javassist:javassist:3.18.1-GA, while the other imported javassist:javassist:3.11.0.GA.
Because of the different groups (it would seem that javassist:javassist became org.javassist:javassist), the build tool wasn't excluding one in favour of the other, and my WAR file had both.
I had to manually exclude the old javassist dependency, and once it was removed everything was fine.
I'm slowly getting through my exceptions on my code using GWT + Hibernate, my server side class is as follows...
public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
public String greetServer(String input) throws IllegalArgumentException {
// Verify that the input is valid.
if (!FieldVerifier.isValidName(input)) {
// If the input is not valid, throw an IllegalArgumentException back to
// the client.
throw new IllegalArgumentException(
"Name must be at least 4 characters long");
}
// Escape data from the client to avoid cross-site script vulnerabilities.
input = escapeHtml(input);
User user = new User();
user.setFirstName(input);
DaoFactory factory = new DaoFactory();
try {
factory.create(user);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "User : " + input + " added";
}
/**
* Escape an html string. Escaping data received from the client helps to
* prevent cross-site script vulnerabilities.
*
* #param html the html string to escape
* #return the escaped string
*/
private String escapeHtml(String html) {
if (html == null) {
return null;
}
return html.replaceAll("&", "&").replaceAll("<", "<")
.replaceAll(">", ">");
}
This receives a string, sets the users firstname as this string and commits it to the db but I get the following error...
[ERROR] javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String com.behaviour.app.client.GreetingService.greetServer(java.lang.String) throws java.lang.IllegalArgumentException' threw an unexpected exception: java.lang.ExceptionInInitializerError
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
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:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:58)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:351)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.ExceptionInInitializerError
at com.behaviour.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:21)
at com.behaviour.hibernate.DaoFactory.create(DaoFactory.java:9)
at com.behaviour.app.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
... 34 more
Caused by: java.lang.ExceptionInInitializerError
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:620)
at java.sql.DriverManager.getConnection(DriverManager.java:169)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:113)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2863)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2859)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
at com.behaviour.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:15)
... 42 more
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:393)
at java.security.AccessController.checkPermission(AccessController.java:553)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:166)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkAccess(DevAppServerFactory.java:191)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:315)
at java.lang.Thread.init(Thread.java:353)
at java.lang.Thread.<init>(Thread.java:437)
at java.util.TimerThread.<init>(Timer.java:478)
at java.util.Timer.<init>(Timer.java:100)
at java.util.Timer.<init>(Timer.java:146)
at com.mysql.jdbc.Connection.<clinit>(Connection.java:201)
... 51 more
I'm not sure really how to approach this. The classes involved are as follows...
public class HibernateUtil
{
private static final SessionFactory sessionFactory;
static
{
try
{
// Create the SessionFactory from hibernate.cfg.xml
sessionFactory = new Configuration().configure().buildSessionFactory();
}
catch (Throwable ex)
{
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory()
{
return sessionFactory;
}
}
and
public class DaoFactory
{
public void create(Object obj)throws Exception
{
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.save(obj);
session.getTransaction().commit();
}
}
Thanks,
Apologies for not really explaining but I'm new to GWT and Hibernate.
You seem to be running your application in Google App Engine's development server.
If your server application is a Google App Engine application, it may not use Hibernate. The only way to persist data in a GAE application is to use the App Engine DataStore. The App Engine development server has a security manager that replicates what is done on the actual Google App Engine server, and which forbids the MySQL driver to create and modify thread groups, as the stack trace indicates.
If your server application is a traditional web application intended to be deployed in a standard Java EE appserver (Tomcat, Jetty, GlassFish, etc.), then make it a web application and deploy it in one of those servers.