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?
Related
I am working on java web application using eclipse with wildfly 20+.
I am debugging an issue on java side, for that I have started wildfly server in Debug mode. I have added some printline inside one method and saved. When I start the application, I can see that my debugger go into that method because i have put breakpoint there but the added printlns and variables inside that methods are not available which means that new changes have no affect. I have also restarted wildfly server and have the same issue. my wilfly configuration looks like this (find attached screenshot):
What else can I check?
Updating code with jpda doesn't work well with WildFly because of the many classloaders involved. You should use jboss tools for this.
First of all, I am aware that there are other questions regarding Tomcat, Eclipse, and the infamous 404 error. However, none of them manages to resolve the issue. I have spent well over 24 hours on this issue.
To save time, when I configured everything (including Tomcat, and creating a server in Eclipse), I:
• Changed the server location from "workspace metadata" to its correct location by using the "Switch Location" button located in the server's Properties window.
• I chose the "Use Tomcat Installation" option in Server Locations, and saved the choice I made.
In both cases, I restarted the server. If you're curious as to what app I'm currently working on, it's a simple Hello World app, found at: http://theopentutorials.com/examples/java-ee/servlet/how-to-create-a-servlet-with-eclipse-and-tomcat/
• I have included the Java file in the "welcome file" list inside web.xml.
Lastly, out of curiosity, why does the Eclipse browser only go to the project directory, and not the servlet itself? (If I add on the servlet name, then "Hello World" appears).
• Yes, if I enter "http://localhost:8080", the default Tomcat page appears, so no issues there.
Can anyone clue me in, as to why I am still getting 404s after all this, and following advice that has been marked as "Accepted" here at SO, such as the following:
HTTP Status 404 - The requested resource (/) is not available
Thanks in advance for any help, it is greatly appreciated.
The error 404 may occur because of large amount of different reasons. In order to resolve that, you should check your tomcat log file out first. It contains by the path:
%PATH_TO_WORKSPACE%\.metadata\.plugins\org.eclipse.wst.server.core\tmp%SERVER_NUMBER%\
logs
Usually it contains some stacktraces which discribes the problem. If not, then you should check your deployed application out there:
%PATH_TO_WORKSPACE%\.metadata\.plugins\org.eclipse.wst.server.core\
tmp%SERVER_NUMBER%\___YOUR_APP____
It might happen that your application was not deployed correctly by eclipse plugin (happens very often) and you should try this:
Project --> clean
'Right click on your server' --> clean
Or just remove your webapp from the directory I mentioned erlier and redeploy it from scratch.
There is something basic you need to understand regarding using tomcat(or application server for that matter). There is a slight difference between using from Eclipse and using from outside
Using From within Eclipse
What happens here is that Eclipse (by default) uses a copy of your tomcat installation and places it in its metadata workplace. This secondary tomcat is used by Eclipse for all deployments, re-deployments and all. Keep in mind that this is not your original copy of tomcat installation.
The difference in this tomcat installation is that is actually a minimal server, meaning that although it has all the deployment capabilities, it does not have some of the extra features that come with the tomcat installation and one main feature is the tomcat's homepage (the only reason why people out there get the infamous 404 resource not found when they try to run-on-server their application).
Workaround
Although not an issue (nor a bug from the Apache's end), you can still view your application by changing the URL to your application's url, homepage or no homepage ! All you have to do is change the url from http://localhost:8080 to http://localhost:8080/yourApplicationName and voila , the default page of your application will be shown that you mentioned in the welcome-page-list. Keep note that if you didn't specify a default page in your web.xml, you will again wind up with, yet again, the dreaded 404 resource not found page. The reason is that Tomcat has found your application, but it doesn't know what to do at the root context of your application. You can either map your servlet to the root of the application (that way it will always run at http://localhost:8080/yourApplicationName) or you can change the URL to the url-pattern that you mapped with the servlet in the web.xml, it must be something like http://localhost:8080/myApplicationName/myServletMappingPattern
I am working on a web-app front end (spring mvc) which depends on war file (created also by me).
Both module web and core communicate via REST (Jersey).
Both modules are separate maven projects.
On some occasions during development I screw up something in the core and exception is thrown. Many times I need to setup a breakpoint there and trap the issue.
The problem is: I start the debug when running the web-app fine. But will never stop on any breakpoint in core (doooh). (core is build using maven package command, to generate war file).
I could start only the core and debug it. Problem some complex functions expect many attributes (form object json format).
Any ideas?
Tnx
Start the core on debug mode, if you can do this in your IDE then you are all set, otherwise you can set up your IDE for remote debugging, There are instructions to do this for popular Ide's. Set up for eclipse, Set up for Intellij
You can debug the core and start web-app regularly and make it send the request you want to debug on the core side.
Have the core source code open in your IDE. Configure it for remote debug of the JVM that the servlet container/app server is running the app. Enable remote debugging on the servlet container/app server. Start the server, start the remote debugging in the IDE. Set a break point and enjoy.
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.
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.