Google Cloud Endpoints - APIs not updating - java

I've been playing around with Google Cloud Endpoints (Java) and I'm having trouble getting the APIs to update after I deploy to App Engine (using both Eclipse + Google Plugin and Android Studio).
I created an Endpoint based on a class called Process (annotated with JPA). It sits in my package (let's say: com.example). The first time I deployed it I had accidentally imported the wrong class (java.lang.Process instead of my com.example.Process). So I got this error when I tested one of the methods in the API explorer:
com.google.api.server.spi.SystemService invokeServiceMethod: cause={0}
javax.persistence.PersistenceException: No meta data for java.lang.Process. Perhaps you need to run the enhancer on this class?
I have then corrected the import, re-generated the client libraries and re-deployed the app to App Engine, but I keep getting the same error. As if App Engine still thinks I'm using java.lang.Process instead of my Process class.
I also made other changes. Like class member variable types and method names and re-deployed. But App Engine doesn't seem to notice these changes.
I read about how the API explorer "violently caches" so I tried clearing the cache, opened in another browser and even on another PC. Still nothing.
Also, I opened the discovery files for my api located in https://.appspot.com/_ah/api/discovery/v1/apis//v1/rest
I noticed that the variables types I had changed are still listed as the old types.
I checked the logs for my deploys. They all look ok:
2013-07-06 18:59:59.960 /_ah/spi/BackendService.getApiConfigs 200 291ms 14kb
I 2013-07-06 18:59:59.706 com.google.api.server.spi.BackendService getApiConfigs: apiConfigDir=/base/data/home/apps/s~<my-app>/1.368601601499931812/WEB-INF
I 2013-07-06 18:59:59.707 com.google.api.server.spi.BackendService getApiConfigs: apiConfigFile=/base/data/home/apps/s~<my-app>/1.368601601499931812/WEB-INF/<my-api-name>-v1.api
I 2013-07-06 18:59:59.713 com.google.api.server.spi.BackendService getApiConfigs: apiConfigFile=/base/data/home/apps/s~<my-app>/1.368601601499931812/WEB-INF/messageEndpoint-v1
I 2013-07-06 18:59:59.740 com.google.api.server.spi.BackendService getApiConfigs: apiConfigFile=/base/data/home/apps/s~<my-app>/1.368601601499931812/WEB-INF/deviceinfoendpoint
and in Admin Logs:
2013-07-06 18:59:35 <me> Successfully updated API configuration version=1
2013-07-06 18:59:35 <me> Completed update of a new default version version=1.2013-07-06T21:59:30Z
2013-07-06 18:59:32 <me> Deployed a new version version=1.2013-07-06T21:59:30Z
Anyone has any idea?
Thanks in advance.

It doesn't seem like your .api files are regenerating properly. If you delete the .api files, do they regenerate upon loading either in dev or to the App Engine?
Common reasons why .api files are re-created with updated information (i.e., mistakes I made in the past):
Primitives and enums are not allowed. You must pass back a Bean.
API methods are not annotated
API methods are "private" instead of "public"

Related

log4j log not working in Websphere when Class loader setting is parent first

I am having two problems. In my application we are using custom email functionality with javax.mail api. Mails are going fine with out any error when the class loader setting is kept as Parent First but custom logs are not getting generated with that class loader setting.
When I update the class loader to Parent Last then logs are getting generated but the custom email functionality is not working, its getting freezed at message.saveChanges(); line and server is throwing time out error.
I have mail.jar & log4j.jar included in the WEB-INF/lib of the application and the log4j.properties file is present in the classes folder
Could any one please let me know what is causing this issue and Is there a way to make both logging and email functionality work with a single class loader setting.
Thanks.
This most likely is caused because Log4J doesn't load the configuration file (log4j.xml or log4j.properties) that you think it does.
Add the log4j.debug=true system property, restart the server and watch the logs. The logs (in SystemOut.log or SystemErr.log) will tell you exactly which configuration file was loaded.
Your version of JavaMail must be fairly old since you are using the 'mail.jar'.
Upgrade the JavaMail included with websphere to 1.5.3 which contains the fix for Bug 6668 -skip unusable Store and Transport classes. From the bug report:
In complex class loading situations, it can be possible for there to be
multiple copies of the JavaMail classes. A Store or Transport defined
by one copy may be loaded by another copy, but it won't be usable because
they're in different ClassLoaders. In this case, JavaMail should skip
over the unusable class and try to load the class from another ClassLoader.
This can happen, for example, in GlassFish if the application includes the
JavaMail classes, the application class loader is configured to prefer
application classes over system classes, and the app server itself tries
to use JavaMail when running in the context of the application.
You need to then remove that old version of JavaMail from your WEB-INF/lib and if need be, place JavaMail 1.5.3 in WEB-INF/lib too. I've tested this fix for GlassFish so I'm assuming lots of other appservers suffer this same issue.
You can download the latest snapshot and official releases from the JavaMail reference implementation home page.

error to integrate restful web service with spring and gdata api

Short version: A restful spring web service crashes when I include a dependency: com.google.gdata: core: 1.47.1
Long Version:
I was trying to make a restfull web service that consume certain information from a spreadsheet in google drive
this is my sequence of steps:
preparing classes that made the connection and the data obtained from drive (not web, only backend classes, unit and integration tests included): all ok
prepare a restfull web service with spring, basically download a spring tutorial (http://spring.io/guides/tutorials/rest/3/) and execute: all ok
then remove tutorial's business classes and include my components, change controllers to invoke my components, plus add gdata dependence in file graddle.build, try execute: houston we have a problem
It's strange, when start app context, log print something like this:
 
C:\Users\Grubhart\Documents\proyectos\error_Rest_Gdata\complete\src\main\java\com\yummynoodlebar\config\WebAppInitializer.java:39: error: can not find symbol
     servletContext.setInitParameter ("defaultHtmlEscape", "true");
                   ^
     symbol: method setInitParameter (String, String)
     location: Variable of type ServletContext ServletContext
but when the rest app is just downloaded (whitout my code, neither gdata dependency) it works, the only thing I did was add my code and the google api dependence, so I started to see what could cause the error
remove all my code (but leave the gdata jar) and... wait for it.. same error,
remove gdata dependency: it works
then add gdata dependency again and test: the same error again
So I think that by including the gdata jar does something that prevents start the entire app context
I created a repo on github to illustrate the error:
https://github.com/Grubhart/error_spring_restWS_gdata
the master branch has the code of a service that works without gdata dependence
gdata_error branch as you can imagine has added gdata dependency (only dependency, no extra code) in gradle.build file:
compile 'com.google.gdata: core: 1.47.1'
and presents the error
no need install anything (even gradle) only have jdk, download the code and run it as stated in the readme file to see errors
i do my homework, look in google, stackoverflow (great site!), spring forum but can't find nothing
if anyone has experience with this problem, or know where i can found more information would be great if you can share experiences or if you know where to look for more info about this error
The original post doesn't contains:
yummynoodlebar\config\WebAppInitializer.java:39: error: cannot find symbol
servletContext.setInitParameter("defaultHtmlEscape", "true");
ServletContext needs import javax.servlet.*; Maybe the error is for that.
Since the spring context configuration in java classes for web applications works with Servlet 3.0 maybe you have overwritten troubles between some dependencies that comes with gdata which may do use of dependencies other than the servlet version you are using to deploy the application or which it was originally configured, I hope this helps you!.

calling wsdl based webservice from within alfresco

i followed this article: http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example/
so i have:
HelloWorld http://pastebin.com/BJ3QA7pR
HelloWorldImpl http://pastebin.com/RM5SBZ5C
HelloWorldPublisher http://pastebin.com/H525WevK
which serves as the endpoint.
on the other side i have the client which i generated with wsimport:
HelloWorld http://pastebin.com/g07H1exf
HelloWorldImplService http://pastebin.com/f0YWMiYt
this runs fine in eclispe without alfresco being involved. however, i want to call the webservice from alfresco (from java backed web script for example)
i tried to copy the client side stuff to my amp file and calling it from a webscript but it fails!
Caused by: java.lang.IncompatibleClassChangeError: Class com.ibm.wsdl.DefinitionImpl does not implement the requested interface javax.wsdl.extensions.AttributeExtensible
Webscript http://pastebin.com/7JksRdtU
1 - is there a more elegant way to configure the access to the wsdl by defining a spring bean (spring-ws) or such
2 - why is it not working? full trace: http://pastebin.com/ak1qzygA
using alfresco community 5.0.a
thanks
You will see IncompatibleClassChangeError usually when the dependancy/library jar has changed. Hence the method/code dependant on the library has to be recompiled against the changes.
Guessing the problem here has much to do with some dependancy jar being mispicked or an older version of jar present or one jar prioritized over the other. A look into the jars containing 'com.ibm.wsdl.DefinitionImpl' class in your classpath should be of some help.

Cannot debug Java Web application from Netbeans

I have a Java EE 5 application which consists of three web projects. I'm using JBoss 5.1 web server and NetBeans 7.2 IDE.
I have the following problems:
I cannot start application in Debug mode. That I know of, there are two (best) approaches in NetBeans and Java: Remote debugging and debugging via shared memory. I read this post How to debug JBOSS application in netbeans? and I set debug parameters in Jboss configuration(I also know there are different parameter sets for shared memory and remote debugging), but when I go to attach debugger I got following errors:
If I use remote debugging I got error "Connection refused";
If I use shared memory I got error similar to this text "dt_shmem:file path could not be found".
These errors occur when I start JBoss by running run.bat file. If I start JBoss from Netbeans IDE, I can attach to remote process (still have problem with shared memory approach), but then I have other problems, regarding variable primitives and model binding in page life cycle (I will not write about that now).
How can I solve these problems so I can debug application? At least, how can I find a better error message when it fails. I could not find too much on the Net by looking for "Connection refused" error only.
Why I cannot just press run main project(or web project) and that netbeans start application, open it in new browser tab(as localhost) and start debug mode? I'm coming from .net background and VS is offering this as out of the box tool (called ASP .NET development server). Why I have to use external web server and with every change deploy new application and then attach to it? Why Netbeans cannot by default use JVM for running application, and later when I deploy application I will choose which web server to use!?
I hope someone will make this clear to me :)
Thanks
added Note at 03.01.2013.
Well, when I changed VM options in project.properties file of web project (added run.args.extra=-J-Xms256m -J-Xmx756m), I succeeded to debug application and heat breakpoint when executing the code. However, I still have strange problem with Managed Bean properties. I have select list on page, and it is connected to Boolean property. When nothing is selected it should be set to null value by default (and it is when I start JBoss server by running run.bat file), but its value is by default set to false! I checked parameters post values in firebug and there is no problem in posting parameters to bean. It looks to me that problem is when JSF framework is trying to map post values to Managed Beans properties, but I cannot find out why this is happening. I also checked faces-config.xml, but did not find any specific rule for mapping to this specific property. Any tips?

Delete Files and Folders Issue

My project is a Web project built using three technologies :
Icefaces for presentation layer.
Spring for business layer.
Hibernate for data access layer.
My Project deployed on WebSphere 6.1 and the user can upload files, I use ice:inputFile component to handle the upload process...
The first issue is:
When the upload process finished i expect to find the uploaded file under the following path : myWebProjectRoot/upload/"sessionId"/fileName.ext
where the "sessionId" is a folder named with the current session id and the fileName.ex is the file uploaded by the user...
But what i found is : the folder "sessionId" did not created and the file is stored directly on the upload folder..
My Configuration is like the configuration of the component-showcase of icefaces library which i deployed it on my server and it create the sessionId directory successfully....
i don't know what to do.. please help me...
The second Issue is :
When the session expired I expect the sessionId folder will be deleted, i modified the code of component-showcase in the class InputFileSessionCleaner and make it delete the folder and it's children recursevly form bottm to up, but some time i face the current problem :
Some files can not be deleted using my code -may be they are used by another process-, thus the folder will not be deleted because one of its children didn't deleted. so what to do in this case ... ?
There is an idea in my mind, which is:
Is there any way to create a process running at the background in the server-side: this process check the upload directory and if it founds any file created from at least 60 minutes -which is my session time out period specified in web.xml- this process will delete this file....
any one can help me.. every help will be appriciated .....
In answer to your second question:
WebSphere has a facility for creating worker threads and arranging for them to be initiated according to a schedule. This approach is fully supported in WebSphere - you don't violate any Java EE restrictions on thread creation by using it.
Search for Aysynchronous Beans in your WebSphere documentation.
There are a couple of flavours of this capability in WebSphere one of which is a generally standardised form that you may also find in other vendors App Servers. Some description is given here: http://www.ibm.com/developerworks/library/specification/j-commonj-sdowmt/index.html

Categories

Resources