- This topic has 10 replies, 5 voices, and was last updated 12 years, 11 months ago by cconway.
-
AuthorPosts
-
Stasbranger SrlMemberto starter thanks for all your helps that you gave me so far.
i’ve generated a project using a scaffolding tool. i’ve used a Entity Database with a AUTO_INCREMENT id.
so how can i do to don’t pass a ID??
i’ve tried to modify a RequestServiceImpl.java to accept a id null
/** * Save an existing Requests entity * */ @Transactional public void saveRequests(Requests requests) { if (requests.getIdrequests() != null) { Requests existingRequests = requestsDAO.findRequestsByPrimaryKey(requests.getIdrequests()); if (existingRequests != null) { if (existingRequests != requests) { existingRequests.setIdrequests(requests.getIdrequests()); existingRequests.setDate(requests.getDate()); existingRequests.setName(requests.getName()); existingRequests.setEmail(requests.getEmail()); } requests = requestsDAO.store(existingRequests); } else { requests = requestsDAO.store(requests); } }else{ requests = requestsDAO.store(requests); } requestsDAO.flush(); }
in GWT UI i’ve deleted
@UiField TextBox id;
in RequestsEditView.java
but when i’ve tried to create a Request, it doesn’t work.
this is the stacktrace
Jul 11, 2011 12:52:32 PM com.google.gwt.requestfactory.server.RequestFactoryServlet doPost SEVERE: Unexpected error java.lang.NumberFormatException: For input string: "null" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:449) at java.lang.Integer.<init>(Integer.java:660) at it.stasbranger.service.RequestsGWTAdapter.getPrimaryKeysFromGoogleKey(RequestsGWTAdapter.java:82) at it.stasbranger.service.RequestsGWTAdapter.find(RequestsGWTAdapter.java:32) at it.stasbranger.service.RequestsGWTAdapter.find(RequestsGWTAdapter.java:1) at com.google.gwt.requestfactory.shared.Locator.isLive(Locator.java:102) at com.google.gwt.requestfactory.server.LocatorServiceLayer.doIsLive(LocatorServiceLayer.java:194) at com.google.gwt.requestfactory.server.LocatorServiceLayer.isLive(LocatorServiceLayer.java:89) at com.google.gwt.requestfactory.server.ServiceLayerDecorator.isLive(ServiceLayerDecorator.java:115) at com.google.gwt.requestfactory.server.SimpleRequestProcessor.createReturnOperations(SimpleRequestProcessor.java:278) at com.google.gwt.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:235) at com.google.gwt.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:135) at com.google.gwt.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:123) 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$CachedChain.doFilter(ServletHandler.java:1097) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088) at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088) 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: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) [ERROR] 500 - POST /gwtRequest (127.0.0.1) 1420 bytes Request headers Host: 127.0.0.1:8888 Origin: http://127.0.0.1:8888 Pageurl: http://127.0.0.1:8888/ApplicationScaffold.html?gwt.codesvr=127.0.0.1:9997#ProxyPlace:it.stasbranger.client.managed.request.RequestsProxy!CREATE User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1 Content-Type: application/json; charset=UTF-8 Referer: http://127.0.0.1:8888/ApplicationScaffold.html?gwt.codesvr=127.0.0.1:9997 X-Gwt-Permutation: HostedMode Accept: */* Accept-Language: en-us Accept-Encoding: gzip, deflate Cookie: JSESSIONID=1x7qttwy1m5lh; SHOWCASE_LOCALE=fr_FR Content-Length: 313 Connection: keep-alive Response headers Content-Type: text/html; charset=iso-8859-1 Content-Length: 1420 Mon Jul 11 12:52:32 CEST 2011 WireActivityLogger SEVERE: Server Error 500 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <title>Error 500 INTERNAL_SERVER_ERROR</title> </head> <body><h2>HTTP ERROR: 500</h2><pre>INTERNAL_SERVER_ERROR</pre> <p>RequestURI=/gwtRequest</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> </body> </html> Mon Jul 11 12:52:36 CEST 2011 it.stasbranger.client.scaffold.Scaffold SEVERE: One or more exceptions caught, see full set in UmbrellaException#getCauses com.google.gwt.event.shared.UmbrellaException: One or more exceptions caught, see full set in UmbrellaException#getCauses at com.google.gwt.requestfactory.shared.impl.AbstractRequestContext.fail(AbstractRequestContext.java:608) at com.google.gwt.requestfactory.shared.impl.AbstractRequestContext$4.onTransportFailure(AbstractRequestContext.java:955) at com.google.gwt.requestfactory.client.DefaultRequestTransport$1.onResponseReceived(DefaultRequestTransport.java:146) at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395) at sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214) at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352) at java.lang.Thread.run(Thread.java:680) Caused by: java.lang.RuntimeException: Server Error 500 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <title>Error 500 INTERNAL_SERVER_ERROR</title> </head> <body><h2>HTTP ERROR: 500</h2><pre>INTERNAL_SERVER_ERROR</pre> <p>RequestURI=/gwtRequest</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> </body> </html> at com.google.gwt.requestfactory.shared.Receiver.onFailure(Receiver.java:41) at it.stasbranger.client.scaffold.place.AbstractProxyEditActivity$1.onFailure(AbstractProxyEditActivity.java:87) at com.google.gwt.requestfactory.shared.impl.AbstractRequestContext.fail(AbstractRequestContext.java:598) at com.google.gwt.requestfactory.shared.impl.AbstractRequestContext$4.onTransportFailure(AbstractRequestContext.java:955) at com.google.gwt.requestfactory.client.DefaultRequestTransport$1.onResponseReceived(DefaultRequestTransport.java:146) at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395) at sun.reflect.GeneratedMethodAccessor69.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214) at sun.reflect.GeneratedMethodAccessor29.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352) at java.lang.Thread.run(Thread.java:680) Jul 11, 2011 12:52:36 PM com.google.gwt.logging.server.RemoteLoggingServiceUtil logOnServer SEVERE: One or more exceptions caught, see full set in UmbrellaException#getCauses java.lang.Throwable: One or more exceptions caught, see full set in UmbrellaException#getCauses at com.google.gwt.requestfactory.shared.impl.AbstractRequestContext.fail(AbstractRequestContext.java:608) at com.google.gwt.requestfactory.shared.impl.AbstractRequestContext$4.onTransportFailure(AbstractRequestContext.java:955) at com.google.gwt.requestfactory.client.DefaultRequestTransport$1.onResponseReceived(DefaultRequestTransport.java:146) at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395) at sun.reflect.GeneratedMethodAccessor69.invoke() at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326) at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207) at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132) at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at com.google.gwt.core.client.impl.Impl.apply(Impl.java) at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214) at sun.reflect.GeneratedMethodAccessor29.invoke() at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167) at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352) at java.lang.Thread.run(Thread.java:680) Caused by: java.lang.Throwable: Server Error 500 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> <title>Error 500 INTERNAL_SERVER_ERROR</title> </head> <body><h2>HTTP ERROR: 500</h2><pre>INTERNAL_SERVER_ERROR</pre> <p>RequestURI=/gwtRequest</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> <br/> </body> </html> at com.google.gwt.requestfactory.shared.Receiver.onFailure(Receiver.java:41) at it.stasbranger.client.scaffold.place.AbstractProxyEditActivity$1.onFailure(AbstractProxyEditActivity.java:87) at com.google.gwt.requestfactory.shared.impl.AbstractRequestContext.fail(AbstractRequestContext.java:598) ... 28 more
jkennedyMemberWere you able to work past this issue?
You should try adding a null check to the generated code where we attempt to get the GWT ID from the primary key.
I can’t recall whether the GWT layer will handle this correctly or not but it should be worth a try. You would likely need to return a default value for the ID here so that the GWT caching that depends on the ID continues to work.
Try returning 0 when the ID is null and test the behavior.
Let me know how that works.
Thanks,
Jack
Stasbranger SrlMembertnx for your answer
I’ve tried to add a null check in RequestServiceImpl.java class (if (requests.getIdrequests() != null)) but it doesn’t work. You can see that in my previous post.
I’ve also tried to add an autoincrement entry (@GeneratedValue(strategy = GenerationType.IDENTITY)) in Requests.java class but it doesn’t work.
My two bad solutions are on the server side.
Where I have to add the null check code?
Stasbranger SrlMemberI’ve tried to follow the debug step by step: when I create a new request (I insert all data without id because I’ve deleted the id textbox) and I click on the “save” button the new object is written on db (that automatically assign to it an autoincrement id).
But on the client side, when the just added data are coming back, the GWT class ActivityManager on the method onPlaceChange calls for first RequestsEditActivityWrapper start method (that works fine) then it calls RequestsDetailsActivity start method that fails because in onSuccess the proxy object is null.
This is the RequestDetailsActivity start method:public void start(AcceptsOneWidget displayIn, EventBus eventBus) { this.display = displayIn; Receiver<EntityProxy> callback = new Receiver<EntityProxy>() { public void onSuccess(EntityProxy proxy) { if (display == null) { return; } view.setValue((RequestsProxy) proxy); display.setWidget(view); } };
Why it happens? Why the proxy object is null? Why the activityManager calls also RequestsDetailsActivity?
jkennedyMemberWould you be able to share your schema (and db type) in an email to me at jkennedy@skywaysoftware.com and I will try to work through the solution.
Thanks,
Jack
IbMemberHi
Did you find a solution on this problem ?
I got exact the same error with GWT scaffolding
i’am using myeclipse 9 and mssql 2005
jkennedyMemberAre you using AutoIncremented Ids on the DB side or passing in a primary key value from the UI?
If you put a breakpoint at the location where this exception is being thrown, you should be able to get a better sense for whether this issue is due to a null primary key being set for the Entity at creation time.
Did you try adding a Null check and returning 0 as noted above yet?
Thanks,
Jack
vsampathMemberHi ,
I am in same boat… can some one help..
Sai
cconwayMemberHi Sai,
I’d be happy to try to help you but there are unanswered questions posed by Jack Kennedy from our Development team. If you would kindly answer his questions as they relate to the problem you are encountering, I would be happy to attempt to help.
vsampathMemberI checked for null. below is code. but still not working.
if( keyValuesAsText[0].compareTo(“null”) == 0)
keyValues[0] = new Integer(0);
else
keyValues[0] = new Integer(keyValuesAsText[0]);
return keyValues;can you tell me the list of files that i need to modify or look into it?
I followed below post to add search. it is very very clear.
http://www.myeclipseide.com/PNphpBB2-printview-t-27471-start-0.htmlThanks,
Sai
cconwayMemberI’ve spent some time fiddling with this and what I believe is happening is that GWT has a stale reference to the entity. If you send an object with a null Id to the Spring service’s save method, the entity is saved and assigned the autogenerated id from the database. The problem is that after the save, the server gets a new reference to the entity (it’s actually a new entity because it has a new id). GWT is still pointing to the old entity with the null id.
To prove that this is the case, and see if this is the same problem you are experiencing, perform these steps:
1. Open the <EntityName>ServiceImpl.java file.
2. Find the save<EntityName>() method.
3. Create a local variable and assign the entity to it prior to the store() method that is called when the entity is new.
4. After the call to store(), get the id from the stored entity and set it on your local reference.For example, I have an entity named ‘Autotest’. In my AutotestServiceImpl.java, I now have:
public void saveAutotest(Autotest autotest) { Autotest existingAutotest = autotestDAO.findAutotestByPrimaryKey(autotest.getIdField()); if (existingAutotest != null) { if (existingAutotest != autotest) { existingAutotest.setIdField(autotest.getIdField()); existingAutotest.setValueField(autotest.getValueField()); } autotest = autotestDAO.store(existingAutotest); } else { Autotest temp = autotest; <-- safe a reference. autotest.setIdField(null); <-- I left the key field on screen so I nulled the id here. autotest = autotestDAO.store(autotest); temp.setIdField(autotest.getIdField()); <-- set the id on the old reference. } autotestDAO.flush(); }
Now, I don’t know the implications of this approach, but would like to know if this resolves your null issue.
-
AuthorPosts