can't debug play with netbeans

1,252 views
Skip to first unread message

sas

unread,
Dec 6, 2009, 8:01:07 PM12/6/09
to play-framework
I'm trying to debug a play application in order to see how things
work...

I've already downloaded the sources

compiled them with ant

created an application with play new myApp

netbeansfied it

and opened both apps (the framework and myApp) with netbeans

then I set a breakpoint on Server.Java main method
then I click Run -> Run project (nb-debug) and I get the following
error:

nb-debug:
/home/sas/play/src/play/framework/build.xml:158: Source resource does
not exist: /home/sas/play/src/play/framework/${application.path}/conf/
application.conf
BUILD FAILED (total time: 0 seconds)

checking build.xml I find

<target name="nb-profile-application">
<property name="application.path" value="/Users/guillaume/
Desktop/webmail" />

I tried changing it to

/home/sas/play/src/play/myApp

same error, so I added it to

<target name="nb-debug">
<property name="application.path" value="/home/sas/play/src/
play/myApp" />

and this time it seems to work...

but when I try to run the project

in the debugger console I get

Attaching to localhost:8000
Connection refused.

and in the output

nb-debug:
org.netbeans.api.debugger.jpda.DebuggerStartException: Conexión
rechazada
at
org.netbeans.modules.debugger.jpda.JPDADebuggerImpl.waitRunning
(Unknown Source)
at org.netbeans.api.debugger.jpda.JPDADebugger.attach(Unknown
Source)
at org.netbeans.modules.debugger.jpda.ant.JPDAConnect$1.run
(JPDAConnect.java:212)
at org.openide.util.RequestProcessor$Task.run(Unknown Source)
at org.openide.util.RequestProcessor$Processor.run(Unknown
Source)
Caused by: java.net.ConnectException: Conexión rechazada
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect
(AbstractPlainSocketImpl.java:310)
at java.net.AbstractPlainSocketImpl.connectToAddress
(AbstractPlainSocketImpl.java:176)
at java.net.AbstractPlainSocketImpl.connect
(AbstractPlainSocketImpl.java:163)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:384)
at java.net.Socket.connect(Socket.java:542)
at com.sun.tools.jdi.SocketTransportService.attach
(SocketTransportService.java:222)
at com.sun.tools.jdi.GenericAttachingConnector.attach
(GenericAttachingConnector.java:116)
at com.sun.tools.jdi.SocketAttachingConnector.attach
(SocketAttachingConnector.java:90)
at
org.netbeans.api.debugger.jpda.AttachingDICookie.getVirtualMachine
(Unknown Source)
at
org.netbeans.modules.debugger.jpda.actions.StartActionProvider.doStartDebugger
(Unknown Source)
at
org.netbeans.modules.debugger.jpda.actions.StartActionProvider.access
$100(Unknown Source)
at
org.netbeans.modules.debugger.jpda.actions.StartActionProvider$1.run
(Unknown Source)
... 2 more
BUILD FAILED (total time: 0 seconds)

then I click debug, attach to debugger, choose port 8000

run again

and this time

nb-debug:
Attached JPDA debugger to localhost:8000
BUILD SUCCESSFUL (total time: 0 seconds)

but in the debugger console I get

Attaching to localhost:8000
Connection refused.

and the server is not running (http://localhost:9000/ not working)

--

if instead of run, I try to debug the project, I'm told I have to
create a build target.

I configure the main class

<!-- TODO configure the main class for your project here: -->
<java classname="play.server.Server" fork="true">

but I get the following error:

debug-nb:
Exception in thread "main" java.lang.NoClassDefFoundError: play/server/
Server
Caused by: java.lang.ClassNotFoundException: play.server.Server
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
332)
Could not find the main class: play.server.Server. Program will exit.
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

this is the generated ide-file-targets.xml

<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".." name="Play! framework 1.0-IDE">
<property name="ant.script" value="framework/build.xml"/>
<!-- TODO: edit the following target according to your needs -->
<!-- (more info: http://www.netbeans.org/kb/articles/freeform-config.html#debugj2se)
-->
<target name="debug-nb">
<path id="cp">
<!-- TODO configure the runtime classpath for your project
here: -->
</path>
<nbjpdastart addressproperty="jpda.address" name="Play!
framework 1.0" transport="dt_socket">
<classpath refid="cp"/>
</nbjpdastart>
<!-- TODO configure the main class for your project here: -->
<java classname="play.server.Server" fork="true">
<classpath refid="cp"/>
<jvmarg value="-Xdebug"/>
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=$
{jpda.address}"/>
</java>
</target>
</project>

--

and finally, if I just debug file, on Server.java I get:

debug-selected-file-in-src:
Exception in thread "main" java.lang.NullPointerException
at java.io.File.<init>(File.java:239)
at play.server.Server.main(Server.java:82)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

the error takes me to

File root = new File(System.getProperty("application.path"));

I guess it can't read the application root path...

So I tried adding <property name="application.path" value="/home/sas/
play/src/play/myApp" /> to ide-file-tagets.xml...

but with no luck...

any idea?

some info:
Product Version: NetBeans IDE 6.7.1 (Build 090826)
Java: 1.6.0_0; OpenJDK Client VM 14.0-b16
System: Linux version 2.6.31-16-generic running on i386; UTF-8; es_AR
(nb)
Userdir: /home/sas/.netbeans/6.7

Guillaume Bort

unread,
Dec 7, 2009, 2:25:51 AM12/7/09
to play-fr...@googlegroups.com
I'm not sure. The simplest way is to run a application in DEV mode (it
will listen for JDPA on port 8000) and then connect the JPDA Remote
debugger of Netbeans.
> --
>
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>
>

sas

unread,
Dec 8, 2009, 2:34:29 PM12/8/09
to play-framework
You were right

The mistake was that I was trying to start de application from
netbeans...

I started it from the command line, attached the debugger and
everything went fine...

Now I'm having a look into play's internals... pretty impresive...

thanks a lot...
> > and the server is not running (http://localhost:9000/not working)

Kyle Partridge

unread,
Dec 8, 2009, 6:11:57 PM12/8/09
to play-fr...@googlegroups.com
I think you can use the run command from NetBeans still. Then you could click the debug button to attach the debugger.

That's the way I've been using it, at least.


--
kP
Reply all
Reply to author
Forward
0 new messages