• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NetBeans issue - can it unexplode the war file

 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know how to force NetBeans to deploy as an exploded war? It keeps everything zipped up so it's impossible to test such things as file uploads.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe Netbeans is exploded by default, especially if you run/deploy inside Netbeans. In the "build/web" folder if I recall correctly.

If you export the war and put it into the app server, different server setting applies (eg jboss is NOT exploded, tomcat is)
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You shouldn't be uploading files into a WAR. First of all, if the WAR wasn't exploded, it simply won't work. Secondly, because if the WAR is re-deployed, all the uploaded files will get nuked.

Always upload to someplace that's external to both webapp and webapp server.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

K. Tsang wrote:I believe Netbeans is exploded by default, especially if you run/deploy inside Netbeans. In the "build/web" folder if I recall correctly.


I haven't quite figured out how NetBeans does it. I have that build folder under my projects folder, but my app does not show up under the tomcat/webapps folder, so it must be running it from the war. (this is my local tomcat instance). This means things like creating files will fail because paths don't return correctly.

I just want to see my app under the webapps folder, just like it is on the Linux web server.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:You shouldn't be uploading files into a WAR.


Sorry, poor example. What I'm actually doing is creating a png file from a charting package. I am trying to create that png in a specific folder so it can be displayed and then deleted when the session ends.

I can't test it properly on the local install, so I have to keep pushing new files up the test server and trying to debug it without benefit of using breaks. Frustrating.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Start the server in debug mode and use the Remote Debugging feature on NetBeans. It will save a lot of trouble.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Start the server in debug mode and use the Remote Debugging feature on NetBeans. It will save a lot of trouble.


I didn't even know this was an option. How you start tomcat in debug mode?
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, that's how your IDE does it on your local machine internally.

Every JVM has a built-in debugger. A crude command-line debug console comes with the JDK, but IDEs leverage that with more user-friendly presentation.

To start Tomcat in debug mode, the command "catalina.sh jpda start" will do it (or "catalina.bat jpda start", for Windows). The default debug port is 8000, although you can optionally override JPDA options.

To connect from the IDE machine, make sure that the server's firewall has port 8000 opened, and create a remote debug session in your IDE with the server's IP address/port 8000.

Other than that, the only thing to watch for is that your source code on the IDE and the compiled classes on the server need to be in sync. Because if they're not, stepping through the code will give strange results!
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you! This is my project for tomorrow.
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

J. Kevin Robbins wrote:

K. Tsang wrote:I believe Netbeans is exploded by default, especially if you run/deploy inside Netbeans. In the "build/web" folder if I recall correctly.


I haven't quite figured out how NetBeans does it. I have that build folder under my projects folder, but my app does not show up under the tomcat/webapps folder, so it must be running it from the war. (this is my local tomcat instance). This means things like creating files will fail because paths don't return correctly.

I just want to see my app under the webapps folder, just like it is on the Linux web server.



When running inside Netbeans, it won't copy the files to the the app server's webapps folder. Unless you hard-coded or specifically say tomcat/... for the upload path, it should work.
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat can run either exploded or unexploded WARs. They can be located anywhere in the filesystem that the Tomcat userid can read from, but the standard server configuration will look in TOMCAT_HOME/webapps for WARs, and deploy them. Unexploded WARs will be exploded and then ignored in favor of the exploded copy.

Tomcat will also look in TOMCAT/conf/Catalina/localhost for Context XML files and follow any codeBase paths listed there. On my production servers, I usually point the codeBase to /opt/mousetech/mywebapp/mywebapp.war and have the "explode" option turned off. On my test machine, however, I point it to the IDE/maven "target/mywebapp" directory, since the WAR is assembled there in exploded form before being ZIPped up and it therefore is the quickest build.

When an IDE runs Tomcat as an embedded process, it may ignore or override the configuration file in the TOMCAT_HOME/conf/server.xml and simply Tomcat as a JavaBean whose properties correspond to server.xml settings (not coincidentally, that's how the Digester sets up Tomcat when launching from the catalina script). And as a result, the IDE Tomcat may or may not match what's in the TOMCAT_HOME/conf/server.xml settings. Which would possibly explain the lack of an exploded WAR.

One of the things that I loathe about the J2EE WTP plugin that comes with the Eclipse IDE is that it makes an imperfect copy of the TOMCAT_HOME/conf directory and uses that. And, to add insult to injury, it has to be occasionally hit with a hammer if you want to change the Tomcat configuration settings.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:
When an IDE runs Tomcat as an embedded process, it may ignore or override the configuration file in the TOMCAT_HOME/conf/server.xml and simply Tomcat as a JavaBean whose properties correspond to server.xml settings (not coincidentally, that's how the Digester sets up Tomcat when launching from the catalina script). And as a result, the IDE Tomcat may or may not match what's in the TOMCAT_HOME/conf/server.xml settings. Which would possibly explain the lack of an exploded WAR.


I always setup Tomcat first so it runs as a standalone server using the scripts in the bin folder. Only after Tomcat is running correctly do I point NetBeans to it and create a server instance in the Tomcat configuration. I've had problems in the past when I installed it as part of the NetBeans installation. So I should have a pretty clean Tomcat setup.

As soon as I've had some coffee and get through my morning tasks, I'm going to try this remote debugging. I'm not really awake yet.
 
reply
    Bookmark Topic Watch Topic
  • New Topic