Objectify dependency in Android Studio 1.0 - google-app-engine

In Android Studio 1.0 when we generate Cloud Endpoints from Java Class then it adds necessary things in web.xml automatically,
the changes made by Android Studio in web.xml files are,
1.
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2.
<param-value>ADDS ENDPOINTS HERE AUTOMATICALLY</param-value>
Which wasn't done before (In Android Studio 0.8.6). The problem is it fails to start the local server. It says ERROR 503 SERVICE_UNAVAILABLE. Now I checked the build log. Then I saw that it was throwing java.lang.ClassNotFoundException: com.googlecode.objectify.ObjectifyFilter exception.
So I added the line compile 'com.googlecode.objectify:objectify:5.0.3' in build.gradle. It worked fine then.
Also I noticed if I remove the following portion from web.xml, it also works fine.
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Now is that a bug? Or am I missing something? Also what are the Objectify and ObjectifyFilters? Why do we need them?

This is a bug. Thank you for letting us know. Objectify is a framework for persisting data to the cloud datastore, as you noticed, if you aren't using it you can simply remove the filter declaration and it should work fine.

Objectify is an API for the GAE datastore:
https://code.google.com/p/objectify-appengine/

Related

Remove appstats from web.xml (Java)

it seems ridicolous, but I am unable to remove appstats.
If I remove the following from the web.xml:
<filter>
<filter-name>appstats</filter-name>
<filter-
class>com.google.appengine.tools.appstats.AppstatsFilter</filter-
class>
<init-param>
<param-name>logMessage</param-name>
<param-value>Appstats available: /appstats/details?
time={ID}</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>appstats</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
my static content is not accessible any more and produces a 404 error.
I narrowed it down to the filter and filter-mapping tags, since I
removed the other tags from
http://code.google.com/appengine/docs/java/tools/appstats.html
step by step.
Only if those specific tags remain in the web.xml, the static content
becomes inaccessible after deployment.
Last night I had strange errors in the logs which are linked to source
files of appstats.
Hopefully you guys can help me.
Greets
upscale
Did you also delete the servlet definition :
<servlet>
<servlet-name>appstats</servlet-name>
<servlet-class>com.google.appengine.tools.appstats.AppstatsServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>appstats</servlet-name>
<url-pattern>/appstats/*</url-pattern>
</servlet-mapping>
Also, if you included it, you should clean up your appengine-web.xml :
<admin-console>
<page name="Appstats" url="/appstats" />
</admin-console>

BlobStore Redirects being ignored by ServletModule wired servlets

After the blobstore handles the upload request of a file it redirects to the url it is given, in this case "/upload". If I configure the UploadServlet url in web.xml like this:
<servlet>
<servlet-name>uploadServlet</servlet-name>
<servlet-class>com.....servlet.UploadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>uploadServlet</servlet-name>
<url-pattern>/upload</url-pattern>
</servlet-mapping>
It works. If I use Guice to wire the servlet:
serve("/upload").with(UploadServlet.class);
I get the error:
Problem accessing /upload. Reason:NOT_FOUND
It seems as though the com.google.inject.servlet.ServletModule does not handle redirects. Is there a way around this?
I have struggled with the same issue myself today. This solved my problem and may be related:
https://groups.google.com/forum/#!topic/google-appengine-java/oqfvEmZGrdw
In dev mode, the blobstore service uses
RequestDispatcher.forward() rather than an HTTP request:
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
Of course, may be too late for you but for others it might help :-)

Web.xml:welcome file displayed incorrectly

Welcome file is not displayed correctly on hosting.
web.xml:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
on local Tomcat:
http://localhost:8099/Teal-0.1-BETA/ is OK
equals to
http://localhost:8099/Teal-0.1-BETA/index.html is OK
on hosting:
http://domain/index.html is OK
http://domain/ is displayed non correctly
As I observed this is displayed not correctly too:
http://domain/index.xhtml
I suspect web.xml config. Looks like problem in .html vs .xhtml extension.
Real file name is index.xhtml
I think that the problem is that you use JSF, but Tomcat renders welcome-file only with JSP engine. That might have been adressed in newer tomcat (7.x) which you have locally, but server uses older Tomcat.
But that's just my guess. Still I don't have much info.
Either case, try setting a welcome page to a plain file with immediate redirection to /index.html . Or better, handle it in Apache (or whatever you have in front of Tomcat).

Jboss webservice error using topdown approach

I started creating a sample webservice using top-down approach in jboss4.2.2 GA.
From the wsdl, i generated stubs using wsconsume
I created a new java class: SalesTaxImpl implementing the interface in the generated stub. Configured #WebService with endpointInterface, portname, wsdllocation.
My war application has the following:
WEB-INF/classes/
WEB-INF/wsdl/SalesTaxService.wsdl
WEB-INF/web.xml
In web.xml i have,
<web-app>
<servlet>
<servlet-name>SalesTax</servlet-name>
<servlet-class>com.hp.np.ws.SalesTaxImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SalesTax</servlet-name>
<url-pattern>/tax</url-pattern>
</servlet-mapping>
</web-app>
After placing the war in <JBOSS_HOME>/server/default/deploy path, i am getting the following error:
19:25:05,046 INFO [DefaultEndpointRegistry] register: jboss.ws:context=JbossWST
opDown,endpoint=SalesTax
19:25:05,078 INFO [TomcatDeployer] deploy, ctxPath=/JbossWSTopDown, warUrl=.../
tmp/deploy/tmp13893JbossWSTopDown-exp.war/
19:25:05,171 ERROR [MainDeployer] Could not start deployment: file:/C:/jboss-4.2
.2.GA/server/default/deploy/JbossWSTopDown.war
org.jboss.ws.WSException: Cannot build meta data: Cannot get URL for: WEB-INF/ws
dl/SalesTaxService.wsdl
at org.jboss.ws.metadata.builder.jaxws.JAXWSWebServiceMetaDataBuilder.bu
ildWebServiceMetaData(JAXWSWebServiceMetaDataBuilder.java:207)
at org.jboss.ws.metadata.builder.jaxws.JAXWSServerMetaDataBuilder.setupP
roviderOrWebService(JAXWSServerMetaDataBuilder.java:50)
I tried giving different combination, but no luck

Sessions enabled - do we have to clean them up ourselves?

When we turn sessions on in google app engine like:
// appengine-web.xml
<sessions-enabled>true</sessions-enabled>
does app engine automatically clean up expired sessions, or do we have to do it ourselves? After turning them on, I see in the datastore that some entries are being generated like _ah_session, I'm wondering if those are them?
Thanks
Yes those are the session entries. Google's app engine documentation includes the following:
The implementation creates datastore entities of the kind _ah_SESSION, and memcache entries using keys with a prefix of _ahs.
(http://code.google.com/appengine/docs/java/config/appconfig.html)
As for cleaning up session data. I found the following 2 discussions:
http://groups.google.com/group/google-appengine-java/browse_thread/thread/4f0d9af1c633d39a
http://www.mail-archive.com/google-appengine-java#googlegroups.com/msg01372.html
HTH,
Steve
From Cleaning Up Expired Sessions From App Engine Datastore:
You need to configure the cleanup servlet provided by Google to be run regularly. Note: the servlet cleans at most 100 entries at time. Be sure to decide how often do you need this to be called and determine the interval as appropriate to you.
In web.xml:
<web-app...>
<servlet>
<servlet-name>_ah_sessioncleanup</servlet-name>
<servlet-class>com.google.apphosting.utils.servlet.SessionCleanupServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>_ah_sessioncleanup</servlet-name>
<url-pattern>/_ah/sessioncleanup</url;-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>session-cleanup</web-resource-name>
<url-pattern>/_ah/sessioncleanup</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
...
</web-app>
And in cron.xml:
<cronentries>
<cron>
<url>/_ah/sessioncleanup?clear</url>
<description>Clean up sessions</description>
<schedule>every 15 minutes</schedule>
</cron>
...
</cronentries>

Resources