NetBeans development Series for Google App Engine for Java (2)

In previous article, we talk about how to create a new project in NetBeans. Here we will try to make it final work for App Engine.

Update build.xml

  • Put dependency class libraries for 'compile' task 
  • Copy all of those libraries to deploy directory
  • Create some task to make debug ready
  • Make those xml files ready for JDO/JPA enhancement

Here is my build.xml file, It worked on my environment. I map test action to 'debug' as there is no debug item there for map:

Please remember to update propery 'appengine.sdk' accourding to your environment, and keep in mind that I put third-party jar files under '<Project Base>/lib' directory.

Now, most of things are ready in NetBeans, you can create application and run/debug it in NetBeans now.

How to create Servlet

You can new a Servlet after right click on project. NetBeans couldn't auto generate information in web.xml for free-form and you just need go to web.xml and manully did servlet/url mapping like this:

That's different thing for Servlet support.

How to debug application for Google App Engine

Since we already map 'test' action to 'debug', we should right click on project and choose 'test' to do debug'. When system is running and listenning on Java remote debug port 5005, attach debugger under menu 'Debug':

Enhancement

I remove datanucleus-enhancer-1.1.1.jar under directory 'lib' as there have duplicated one under 'lib\\user\\orm'. It will cause duplicated registration error during enhancement.

How to stop running container

We need manully kill it outside of NetBeans. We can use 'kill' on Unix and 'Task Manager' on Windows to kill that java process. I bet you won't make mistake to kill NetBeans process as it use more memory than that container's. You need finish debugger session in NetBeans first if you are debugging it.

Now, we can easily debug Servlet/JDO/JPA in NetBeans. You can download NetBeans here!


Comments:

Good post!
hopefully provide more introduction about the app server's role in GAE development.

Posted by jim jiang on April 16, 2009 at 07:15 PM PDT #

Thank for this article.

Posted by nuboat on April 17, 2009 at 03:29 AM PDT #

I have problem when i click debug process then it show

================
clean:
Deleting directory D:\\Souces\\GAESrc\\Guestbook\\www
copyjars:
Copying 7 files to D:\\Souces\\GAESrc\\Guestbook\\www\\WEB-INF\\lib
Copying 1 file to D:\\Souces\\GAESrc\\Guestbook\\www\\WEB-INF\\lib
compile-debug:
Created dir: D:\\Souces\\GAESrc\\Guestbook\\www\\WEB-INF\\classes
Compiling 1 source file to D:\\Souces\\GAESrc\\Guestbook\\www\\WEB-INF\\classes
enhance-debug:
DataNucleus Enhancer (version 1.1.0) : Enhancement of classes

DataNucleus Enhancer completed with success for 0 classes. Timings : input=95 ms, enhance=0 ms, total=95 ms. Consult the log for full details
DataNucleus Enhancer completed and no classes were enhanced. Consult the log for full details
war-debug:
Copying 1 file to D:\\Souces\\GAESrc\\Guestbook\\www
Copying 2 files to D:\\Souces\\GAESrc\\Guestbook\\www\\WEB-INF
Copying 1 file to D:\\Souces\\GAESrc\\Guestbook\\www\\WEB-INF\\classes\\META-INF
DataNucleus Enhancer (version 1.1.0) : Enhancement of classes

DataNucleus Enhancer completed with success for 0 classes. Timings : input=91 ms, enhance=0 ms, total=91 ms. Consult the log for full details
DataNucleus Enhancer completed and no classes were enhanced. Consult the log for full details
debug:
Launching dev_appserver on Web port 8080, Java remote debug port 5005
Listening for transport dt_socket at address: 5005
================================
But i can't connect web port.

I use netbean6.5 and java1.6u11 on window7

Posted by nuboat on April 17, 2009 at 04:58 AM PDT #

You need attach debugger in NetBeans before you access web port as container is hanging on and waiting for that connection if you run it in debug mode. You can access web port directly if you clean and run it without debug.

Posted by Jian-Guo Leon Fan on April 17, 2009 at 12:43 PM PDT #

Thank Jian-Guo Leon Fan

Posted by nuboat on April 18, 2009 at 04:34 PM PDT #

Post a Comment:
Comments are closed for this entry.
About

leonfan

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today