Question

I have some Python services and I have defined handler locations for them in app.yaml

I also have Java services and I have configured web.xml.

I want them both to be under same APP ID, e.g.

So how can I accomplish this?

  • When I use GAE Java Eclipse plugin, it only uploads the Java service and deletes existing Python service.
  • When I use appcfg.py update it only uploads Python service and deletes existing Java service.
Was it helpful?

Solution

There is a hack: upload to different versions

You can have one instance version in Java and the other in Python. The default one will be visible to public via http://myapp.appspot.com.

You can access the other version (in browser or programmatically) viahttp://version.myapp.appspot.com, e.g. http://3.myapp.appspot.com

If you wan to acces both of them via the same URL, then you will need to proxy the request or do a redirect (if your client allows it).

OTHER TIPS

There is no official way to use two runtime environments with one app. Jython is one way to run Python code in the Java runtime environment.

Depending on your needs, you can try using two different app versions with the same app ID. One version can use the Java runtime environment, and the other can use the Python runtime environment. Both versions would see the same datastore. You can address each app version separately using appspot.com URLs, though they're not pretty: http://version-id.latest.app-id.appspot.com Only one version can be the "default" version (http://myapp.appspot.com). This uses 2 of your 10 allowed versions, and you'll have to be careful to deploy each version with the correct version IDs. So it's not an ideal solution.

I'm sure that you can have only one app at same time, because it's different app servers/VMs for each type. I mean you can't upload different parts, can't have different sdk for different url on same app, etc.

Btw, you can try to use jython, it can interpret your Pythong code in Java project. I'm not sure that it's production ready (there was a lot of problems with it when i had tried it few years ago), but maybe it's helpful for your situation

As @splix said, deploying two app with different languages into the same appid seems to be impossible. So how about a workaround instead? Set a /pythonapp servlet on your Java app that will redirect all requests to mypythonapp.appspot.com via URLFetch.

The drawback of this workaround that come into my mind is that you are losing the information about the logged in user provided by the User API, so you would need to attach the information on the redirected request. Depending on the scenario of your app, I don't know whether this would be a show stopper or not.

EDIT: What I had in mind is what Peter suggested, using different versions rather than deploying them as totally different app, sorry that I mixed them up. Deployment to a different app would mean your Python app and Java app could not use a shared datastore.

The difference on my answer is that you could use URLFetches to forward the requests between different versions of your app. But having the redirection performed on the client's side as per Peter's suggestion rather than having it done on the server side as in my answer would probably be less hacky.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top