Debugging appengine in Java with breakpoints - java

I'm struggling to get breakpoints to work in a Google Appengine project. I followed the guide here https://cloud.google.com/appengine/docs/java/webtoolsplatform which explains how to set up a google app engine server on your local machine and run your app locally. I can do all that.
I can access my app via http://localhost:8888 as well as http://localhost:8888/_ah/api/explorer etc.
Now onto my problem. None of my breakpoints stop! Even when I place a break point in every possible location the server could go to, nothing happens. This is true when I browse code normally on the regular http://localhost:8888 site, or the /_ah/api/explorer section.
When I shut down the server, everything stops (so I know the server created by Eclipse is the one running the show) and when I am in debug-view I can manually suspend the entire app (which will also
I am running the Google App Engine tutorial project from Udacity:
https://www.udacity.com/course/progress#!/c-ud859
It is a maven based project (though for this debugging, I am compiling using the Google App Engine tutorial linked at the top)
It github repo is here https://github.com/udacity/ud859
And my forked repo where I have my exact code is here:
https://bitbucket.org/esend7881/udacity-googleapp.git
I really can't tell what I am missing here.

This could be anything...it is working for me (using tic tac toe example: https://github.com/GoogleCloudPlatform/appengine-endpoints-tictactoe-java
One question, is how are you invoking your API? I don't see a "HttpMethod.GET" in yoru screen
shot.
Are your break points enabled, makes sure that "Skip All Breakpoints" isn't clicked":
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fviews%2Fbreakpoints%2Fref-skipall_viewaction.htm
I run my eclipse as "administrator" on windows to make sure it has privilege to access the director eclipse is in (Right Click on Eclipse->Run As Administrator)
If above fails, you can try a namespace filter (take your API out of the path) and set a break point in it. I don't have a great example online, but you can follow the "multitenant" example on google to try it: https://cloud.google.com/appengine/docs/java/multitenancy/multitenancy#Java_Setting_the_current_namespace

Related

installing play framework 2.4 on windows 7

some questions:
i unzipped the full offline distribution (400+ mb) to C:\Program Files\Play2.4
Unzipping created a directory "activator-dist-1.3.5" within which are bin, lib, repository, templates, etc.
i assume i put the contents of activator-dist-1.3.5 into C:\Program Files\Play2.4?
i setup an user environment variable name: PLAY_HOME, value: C:\Program Files\Play2.4 and then added ;%PLAY_HOME% to the end of the system variable "Path"
i've tried calling "play" from dos both with and without "activator-dist-1.3.5" directory and both return "play is not recognized as an internal or external command"
some other answers to this question mention the root play dir should have "play.bat" but all i see is "activator.bat"
i read readme.html and opened activator.bat, it launched a dos window, which promptly closed.
http://localhost:8888/home goes nowhere.
For those who don't yet speak "play", what is Activator UI?
Since play 2.3, the play command was replaced with the activator command. Take a look to this.
If you put the folder activator-dist-1.3.5 into C:\Program Files\Play2.4 then your enviroment variable must be set to C:\Program Files\Play2.4\activator-dist-1.3.5\bin. You can also put that path directly into the PATH environment variable.
Activator UI is a web aplication that helps you create play applications. You can think of it as the graphical version of the activator command line tool. Here is the documentation
ok, here is what ive figured out:
the environment variable has to point to the bin directory (thx Victor)
from w/in dos window (the "console"), cd to the the root play dir (not bin) and type "activator" not "play"
all other documentation and stackoverflow answers refer to the pre 2.3 versions of play and will not help you.
then a bunch of stuff happens: online maven call (even though i downloaded the offline dist) and a bunch of calls to the play root dir/repository for jars.
of course localhost:9000 and localhost:8888 still get connection refused.
now if you manually open activator.bat in root play dir it launches another dos window, makes a network call (firewall allow) and opens a browser win to: http://127.0.0.1:8888/home which is some sort of "welcome to activator" screen with sample apps .. sort of like the tomcat mngt page.
i hope to only define and start/stop apps from w/in my IDE, so eventually i'll be looking for how to disable this default activator behavior
next up.. how to setup intelliJ:
i went here: https://www.playframework.com/documentation/2.4.x/IDE and defined an SBt task instead of a play task in run/debug configurations of my new project.
now project start makes maven calls for jars but then dies on:
[error] Server access Error: Connection timed out: connect url=...repo.typesafe.com/typesafe/ivy-releases/org.apache/apache/14/jars/apache.jar
stopping and restarting did a bunch more maven calls (really slow) but eventually "done updating" and localhost:9000/ now shows welcome screen :)
not completely painless but certainly simpler than a spring app
onEdit:
sorry play, but i've moved to spring boot because:
i create new projects by copying existing and making changes. its much faster than creating a new proj from scratch. Thus the activator thing (which does not work) is not useful to me and just represents a security prob (like apache web management screen) that need be disabled
no where is there a clear, concise and complete list of settings to get play running correctly in intelliJ (the 2nd most popular IDE avail)
asynchronous, non-blocking and micro services are not unique to play and spring (or others) can be made to work in a similar fashion
We have so many technologies to learn and it does'nt make sense to invest a lot of time mastering one with limited corporate buy in
i want to stop/start from w/in my IDE and not have to have a bunch of dos windows open. i know this is possible in play, but documentation makes it feel as though its not the preferred method
although i appreciate that the play directory structure is less flexible, its still not the command/controller/manager/dao/model world that is the most often seen for java apps
i investigated play because spring was getting to the point of having too many ways to configure too many things in too many places that were documented differently across versions. Also, large sub-projects in spring (like security) garnered their own books on the subject because they were so complex to figure out. At the end of the day, the level of security (for example) needed (or the manner in was implemented) went beyond what avail via simple configuration and after all the customization we were left wondering whether spring security just got in the way instead of providing real time saving and usefulness.
Spring boot hopes to help in that its an opinionated configuration where a collection of configuration basic best practices are encouraged/enforced.
and lets re real.. time saving on a slightly more concise language or a slightly different proj structure or dynamic class loading is not whats important.
The majority of time spent on projects, by far, is the time spent researching, thinking and investigating architectures, technologies, databases and presentation schemes.
I prob only spend 20% of my time coding and 80% trying to figure out the strategic vision needed to create software that has maximum usefulness and is "future friendly" (not needing to be re-coded every 3 years)
so far i've deleted my project and recreated about 10 times.. trying diff settings, still w/ no luck.
checking google play mailing group, i tried to create via activator ui.. but could not launch activator until i deleted the RUNNING_PID file in the play root dir
now i'm back at: http://127.0.0.1:8888/home to create a new app
at create new proj i get error: "cannot find project/build.properties".
lets try adding a blank build.properties where its expected.. nope, error: "destination already has files in it"
not that it really matters, sample templates have no knowledge of IDE and thus provide no insight into how to configure IJ. New\Import project does not list IJ as an option in choosing an external model
...whatever...
"Mr McKitrick.. after careful consideration ..."
trying to get working in IJ 14 ultimate:
jamesward.com has a tutorial and video, but its for older versions of IJ and play and only covers a small % of necc. configurations.
jetbrains has a tutorial but it also only covers play 2 and older IJ which does not translate to 14 and 2.4
https://www.playframework.com/documentation/2.4.x/IDE helps, but just w/ setting up an SBT Task
all the other project settings are a mystery for example:
project source need be defined to even show your project directories in proj tree
facet setup add does not list scala as option
why is scala lib pointing to users[me].ivy2\cache..? (i would think all necc libs are w/in play root\lib
should i setup a global lib pointed to play\lib?
run/debug config need env var pointed to PLAY_HOME?
basically all classes are not being resolved in IJ editor.
project structure lists 109 problems like:
Library SBT: joda-time:joda-time:2.3:jar is not used [Fix]
seems like i'm missing a global lib definition.
i'm able to get my app running, but i dont know how useful its going to be when the 2nd most popular IDE throws red bars at every import: "play."

Why can't I get the Google Cloud Debugger to work?

I've connected my Java based app engine app to Cloud Debugger via GitHub. I can see the source code and navigate the source files. But, when I place a breakpoint on a line in a source file, the debugger never captures local variables when I execute my app. How can I troubleshoot/fix this?
There might be few reasons why the snapshot will not hit.
Make sure that you are using the source code version that is deployed with your app. Many times the head revision is ahead of the deployed version.
If you use appcfg version 1.9.20 or above, it includes source hints for the debugger to display the correct version of the source.
more info here: https://cloud.google.com/tools/cloud-debugger/setting-up-on-app-engine
The 'Watch Target' selected in the UI is inactive.
If the application is deployed while using the Cloud Debugger UI. It does not give an indication that the selected 'minorversion' is inactive and the snapshot will never hit.
Refresh the UI after deploying to allow the UI to pick the latest minorversion of the application.
Make sure that your application is executing that file:line.
The file:line has to execute for the debugger to capture an execution snapshot. It may happen that the requests that the application is processing do not execute that specific file and line.
Make sure that the the specified condition actually evaluate to true.
First simple check is to simply remove the condition.

track changes in eclipse

I have eclipse installed on a local computer, and am working on a project by myself. No one else is collaborating on the coding, I am doing it all myself.
Sometimes, I get ambiguous error messages in my spring mvc app when I run it on tomcat server using eclipse's run as...run on server command. For example, there is sometimes NO stack trace. In those cases, I would like to at least be able to see when each file in the app was last saved, so that I can try to figure out what I changed since the last time the app ran successfully. Ideally, I would like to also be able to see what changes I made to specific files.
Can anyone show me how to accomplish this?
Eclipse has Local History feature: try Team > Show Local History from context menu.
But I recommend you to use some version control system (svn, git) even if you work on your project alone.

Eclipse subversive on dev box issue

I recently started on a new project where they do not have eclipse working with subversion. They say it is not possible because our dev boxes do not get internet connection. However, I'm not so quick to give up.
We are currently using TortoiseSVN over our secured network just fine. Surely we must be able to set-up Eclipse to do the same?
I have done some research and am having a hard time finding an answer off google searches and thought I'd ask here. Most of the SVN eclipse guides ive seen require a web address to host the file. Any thoughts?

How can I run an app's source code that I got from the Android source code?

For all of you android devs out there that have the Android simulator running on your comp, you know that there are a few built in apps that are already installed on your 'phone'. I had an idea for an app that would utilize a function that is already being done in the spare parts app that comes already installed.
I went on to the android developer site, dug through the source code files, and found the spare parts app, and am now trying to set it up so that running it from eclipse on my machine actually runs the app in the simulator. In other words, I want to be able to make changes to and adjust some of the things in that app for my own needs. But it won't compile, because of a number of different errors.
How do I get that source code running on my local machine? Is there some special trick that I just dont know about? I thought that if I could get the source code than the rest would be easy, but it isn't being too easy.
Not knowing what the error is, it is hard to say. But there are some tricks. First, you want the entire spare parts app in Eclipse, not just the code you are interested in running. Second, right click on your project, and go down to the "Android Tools" menu. Then click on "Fix Project Properties". Do a clean on your project and hopefully that will help.

Categories

Resources