Debug GlassFish global filter with Eclipse - java

I'm developping a filter to handle all request made to my GlassFish v3.01 so I added a configuration in the default-web.xml Everything is working fine, but I'm not able to start debugging session in Eclipse. The compiled jar file is under domain1/lib.
Does someone have an idea on how I could achieve this?
Thank you, have a nice day.

I found a solution to the problem. To be able to debug a GlassFish Global filter with eclipse, we need to create a new debug configuration. This must be a remote java application config with port 9009. You must activate the Debugger in the JVM Setting on the admin page. Then we're able to start the debug configuration and the break points will work just fine.
I found the information here:
http://www.shareyourwork.org/roller/ralphsjavablog/entry/debugging_glassfish_with_eclipse
Thanks.

Related

Configuring embedded tomcat in Java Spring

im new to Java Spring and when i am starting netbeans with a new web project, i have the option to choose a framework. When I'm choosing Spring MVC, i have got an embedded tomcat out of the box. I liked it very much! So easy it can be! But this make it complicated to understand what is happing behind. I want to know, how to create a https connection, without configuring in the tomcat settings. (Or is this the only way?) I tried this one, but than you have to start tomcat manually with the batch-file. When using http-connection und you running your project it usally reachable and you do not need to start tomcat! I dont know how it works, but i think it starts the embedded tomcat and listing to a random port, the url is printing out when starting project. Another question is, where can i change the url name? Now i have this one:
http://localhost:8084/projectname/
And i want to give a customer name. Maybe someone answer to this question or post a link with useful information how to configure embedded tomcat. For me it is important to keep the default construction of java spring in netbeans!
And i want to use the dispatcher.xml, web.xml -> So don't want to switsch to use tomcat in my javacode! Hope that this is possible!
Thank you very much, Mira.

debugging an unmanaged Neo4j extension

I just started developing an unmanaged extension for Neo4j server using the Graphaware framework. Everything is fine so far. Even unit tests are working. But I would like to actually debug the extension running the Neo4j server from within Intellij.
Can anybody give me a hint on how to do that?
Many thanks in advance,
Oliver
PS: This extension is being called via rest interface from a separate web server providing hosting the actual web application.
You need to enable jvm remote debugging in conf/neo4j-wrapper.conf. Amend a new line to this file:
wrapper.java.additional=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -Xdebug-Xnoagent-Djava.compiler=NONE-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
In case you want to debug the startup sequence as well, use set suspend=y above.
In your debugger setup a remote debugging session to localhost:5005 or myhostname:5005.
For neo4j 3.0 you have to amend this line to conf/neo4j-wrapper.conf.
dbms.jvm.additional=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

Can I Debug GWT-RPC procedures run by Tomcat and static content run by Apache Webserver (with IntelliJ)

On my Windows development machine I have IntelliJ setup to run my the static html through Apache Webserver and the GWT-RPC services with Tomcat. Everything is working except the debugging of the server code of the GWT-RPC services. Is it possible to still debug the GWT-RPC server code this way?
Here is how I do it:
Configure tomcat server instance in IntelliJ and make sure you can start your application WITHOUT GWT debugger. In other words in your IntelliJ IDEA go to edit configurations and add tomcat local server and choose your war file to be deployed to tomcat
Start your tomcat in debug mode through IntelliJ
Make sure you can open your application and it works at the URL you expect it to work, should be something like that http://localhost:8080/applicationContextThatYouSpecifiedInTomcatDeployentTabConfiguration
Make sure that now you can debug your server side by clicking inside you application and checking if the requests are stopped at appropriate break points on server.
Create GWT run configuration in IntelliJ
Make sure that you have Dev Mode Parameters set to "-noserver -bindAddress 0.0.0.0" noserver means when you will start GWT configuration from intelliJ it won't start embedded server, since we're using Tomcat as our server now.
Run GWT configuration through IntelliJ in debug mode - and YES you have now two configurations running at the same time: one for client side(GWT) debug, another one for server side(Tomcat) debug.
Now, in your browser add to the end of URL following text ?gwt.codesvr=127.0.1.1:9997.
For example if in URL you have http://localhost:8080/hiThereMyApp/index.html the new URL should look like http://localhost:8080/hiThereMyApp/index.html?gwt.codesvr=127.0.1.1:9997
P.S. sometimes browser's gwt plugin will complain that 127.0.1.1 host is not allowed as a GWT codebase, in this case try either replacing 127.0.1.1 to localhost or your computer's ip address, or try to configure your browser's GWT plugin to actually allow your desired gwt codebase.
Do I understad you correct?
You have a GWT application running in dev-mode hostet in intelliJ
And you have the serverpart of this Application running hostet within a tomcat?
If so, you should start your tomcat with enabled remote-debugging and connect you intelliJ.
Ok, I now can debug server code with the described setup:
To be complete I include the steps I already knew and had done:
First you have to configure Tomcat to support remote debugging. This is described in link that Christian Kuetbach gave in his answer. In short it is adding two options to the jvm:
-Xdebug
-Xrunjdwp:transport=dt_socket,address=<yourport>,server=y,suspend=n
(I already did this step)
The seccond step is where I needed help, configure IntelliJ.
You have to include a Remote Run/Debug configuration. In this configuration you need to specify the port from step 1. Also, before starting the GWT debugging you have to start this Remote debug configuration so it will connect to the Tomcat debug socket.
Now you can debug the client code and the server code in the same IntelliJ session.

Cannot debug Java Web application from Netbeans

I have a Java EE 5 application which consists of three web projects. I'm using JBoss 5.1 web server and NetBeans 7.2 IDE.
I have the following problems:
I cannot start application in Debug mode. That I know of, there are two (best) approaches in NetBeans and Java: Remote debugging and debugging via shared memory. I read this post How to debug JBOSS application in netbeans? and I set debug parameters in Jboss configuration(I also know there are different parameter sets for shared memory and remote debugging), but when I go to attach debugger I got following errors:
If I use remote debugging I got error "Connection refused";
If I use shared memory I got error similar to this text "dt_shmem:file path could not be found".
These errors occur when I start JBoss by running run.bat file. If I start JBoss from Netbeans IDE, I can attach to remote process (still have problem with shared memory approach), but then I have other problems, regarding variable primitives and model binding in page life cycle (I will not write about that now).
How can I solve these problems so I can debug application? At least, how can I find a better error message when it fails. I could not find too much on the Net by looking for "Connection refused" error only.
Why I cannot just press run main project(or web project) and that netbeans start application, open it in new browser tab(as localhost) and start debug mode? I'm coming from .net background and VS is offering this as out of the box tool (called ASP .NET development server). Why I have to use external web server and with every change deploy new application and then attach to it? Why Netbeans cannot by default use JVM for running application, and later when I deploy application I will choose which web server to use!?
I hope someone will make this clear to me :)
Thanks
added Note at 03.01.2013.
Well, when I changed VM options in project.properties file of web project (added run.args.extra=-J-Xms256m -J-Xmx756m), I succeeded to debug application and heat breakpoint when executing the code. However, I still have strange problem with Managed Bean properties. I have select list on page, and it is connected to Boolean property. When nothing is selected it should be set to null value by default (and it is when I start JBoss server by running run.bat file), but its value is by default set to false! I checked parameters post values in firebug and there is no problem in posting parameters to bean. It looks to me that problem is when JSF framework is trying to map post values to Managed Beans properties, but I cannot find out why this is happening. I also checked faces-config.xml, but did not find any specific rule for mapping to this specific property. Any tips?

How to debug Spring MVC tomcat application?

I am trying a spring MVC application on tomcat server..
I am always getting the error as resource not found(please see the question if you have time)..I think there is some problem with the view resolver..
I want debug this application to know where i am doing wrong...
Is that possible?
I don't know if it is a lame question for senior developers :)
I would set the logging level of DispatcherServlet to DEBUG and see what it says. Spring contains mostly good logging at DEBUG level to tell you what's going on (despite that it's INFO level is nigh-useless).
If DispatcherServlet's logging doesn't say much, try some of the other classes you have configured in your application (do one at a time or you'll get overwhelmed with log messages)
If you are using Eclipse, you can add Tomcat runtime in preferences and add new server in servers view in eclipse. Then you can run the server in debug mode.
Also you can attach source code for jar files(in your case spring jars) in eclipse so that when you debug it will load proper source files.

Categories

Resources