I'm trying to setup deploy on save (or compile on save, or whatever I should setup) correctly in Netbeans.
I'm trying to achieve this:
1) hot-replace some class when needed if the structure didn't change (push the button, new code replacing the old one)
2) copy my jsf pages (.xhtml) to glassfish on save
1) works most of the time; it sometimes doesn't after I deploy many times (why?), or if Netbeans decides for whatever reason that it should deploy the whole thing (it does... sometimes)
2) works in some project, not in others
Seems like black magic.
How is it supposed to work? I can't seem to have 1) and 2) working on the same time for all my projects. How should I configure that? I must have done something wrong, I just need to know what the checklist is.
I opened this some time ago: https://netbeans.org/bugzilla/show_bug.cgi?id=218806
UPDATE: this is a maven project
This update from the Jira issue should clarify it:
At the moment there are two important features:
--> Compile on Save (will be referred as CoS) which basically means that your java files are compiled immediately when you save them
(typically to the target/classes).
--> Deploy on Save (will be referred as DoS) is supplementary feature that enables you to deploy your .class file changes to the server
immediately when you save them.
So currently you have few possibilities:
1) Turn on both (CoS and DoS) --> That means your changed .java files
will be compiled on save and redeployed to the server and also your
static resources (html, jsp etc.) will be copied to the server after
the save.
2) Turn DoS off but let CoS on --> in such case you will loose
everything related to "server refresh". Which means you should have
actual class files compiled in the target/classes but you won't see
any change in the browser
3) Turn both off --> NB let you to take care of build/deployment
--> It doesn't make semantic sense to have DoS activated while CoS is disabled which is why if you disable CoS, NetBeans automatically
disables also DoS
How should I configure that?
So the conclusion here is, you are not doing anything wrong and you
can't configure it that way.. NetBeans just don't support such
possibility yet. BUT the good thing is I'm currently starting to work
on issue 218345 which is exactly what you need. There will be a new
check box (already available in Ant Web project) named "Copy static
resources on save" that allows you to copy your html/jsp/jsf pages
while having DoS disabled.
I experienced exactly the same behavior. No problems with Ant but hot deployment with maven does not work properly. So far what you just wrote.
The answer was to switch to Eclipse >= 4. You can convert your NetBeans project in a console using maven:
mvn eclipse:eclipse
All you then need is an adapter for your app server e.g. for GlassFish. Try it, it's worth a try.
Related
I am working on a GWT project. After having made changes server-side and compiled it useing GWT Compile, the changes are not reflected when I deploy the application on Tomcat Server. But if I run the application in dev.mode in Eclipse, the changes are reflected!
Any idea how to make the compiler use the latest code?
I have deleted all compiled filed, build and cleaned the project tons of times - none of it working.
This is typical if your cache settings aren't correct. Your broswer doesn't download the changed files because it has the old ones in cache and doesn't know they changed.
Try erasing the browser cache and/or pressing ctrl-f5 in your browser.
On production systems, you need to properly configure you web server to explicitly cache GWT files matching *.cache.*, and explicitly NOT caching *.nocache.*.
See this for a server filter example that takes care of the cache configuration (i.e., as geert3 explained so your server does not let your browser cache an obsolete version, search for section with requestURI.contains(".nocache.")) and to make your app crawlable as well.
first of all I am sorry on my English.
I have a problem in my Gwt application.
I build Gwt application and I work on application every day
Yesterday I want to still work on my application but is stopped worked and i do not know why and I not get errors
The application compiled and I get the Url to run on browser
I copy the Url to my Firefox browser and not happened nothing.
I put break point in my entry point class and I see the application not arrived to entry point and I do not know why.
I try to open new project to check maybe the problem in eclipse or in Gwt plug in but the new project worked excellent so I understand the problem in specific this project.
I need help
thank you everyone
Okay i have 3 possible suspicions:
You updated your Application, but for some reason some JavaScript stayed inside the Firefox cache. Solution: Go to options and "Clean cache" and always try to press CTRL+F5 instead of just reloading, this will clean the current website's cache saved in your Browser.
Your HDD is full(less likely). You said you work everyday on the app. The caching in dev-mode is very VERY bad(for me it once contained 300GB of cached data). there is a folder called <win_user>/AppData/Local/Temp - delete everything inside if you find a lot of "gwt-<something>" files and check the folder's size. There is nothing valuable inside it(if you didn't place anything inside :D)
P.S. Turns out it was a Firefox Memory-leak that has been fixed in GWT 2.6.0 :)
Your Eclipse messed up some random stuff. As always - Project > Clean...
Then right click on app and let gwt recomile your app(if you have an ant file that uses the gwt-compiler, execute that)
I can't really think of anything else...
The only thing that could be is that YOU changed something, but you said you didn't so...
Hopefully it works,
Laurenz
I am new to building Java web applications & WAR files. I am working with a fairly large web application that is built on Java & JSP pages. We have a ANT file that will re-build the entire application every time a single change was made. I want to know if it is possible to only re-build the part of the application that was modified instead of the whole entire project.
Testing is a 10 minute process because I will make a change, shutdown Tomcat, run the ANT script, start Tomcat, re-load application in browser which now takes 7min to do load for the first time after a re-build (I'm also curious to know what it's doing here?)...Basically complete hell for testing.
If anyone could suggest a better testing strategy I would be awesome! Also maybe anyway we would just have the ANT script re-build only modified classes.
There are several things one can do.
One can modify jsp in the tomcat/temp directory. The change will be available immediately without any recompiling/reloading
One can use the remote Tomcat debugging (from Eclipse). This debugging allows one to change the source code and this change will be propagated to Tomcat immediately
The best way to organize your ant script is to separate compiling into several jars and then creating a war file. Then recompilation for one change will happen only in one jar.
It is not required to restart Tomcat under redeployment if you specify reloadable=true for the context
I made a simple command-line based game in java, only two classes (using Eclipse). But I was wondering how I can make this into a usable application for anyone, without running it through eclipse (ie send it to someone who knows nothing about java but would still be able to play the game)? Thanks!
You want to create a runnable jar file.
Eclipse has an option for this in the "Export" menu. For more options, search for "executable jar file" here or on Google.
You want to make sure that you also include any jar files your code depends on as well (Eclipse can also do that for you).
Users will be able to start this by double-clicking on the file on most platforms. If you need better integration (such as a custom icon), you will need to bundle it up further into an OS-specific executable. But for starters, a simple runnable jar works fine.
send it to someone who knows nothing about java
You need to get them to at least install the Java runtime on their machine (if it is not already there).
Just to be clear, "command-line" and "knows nothing about java" are probably not going to work very well for you given that:
java is OS agnostic, therefore, if you send (presumably) a jar file to say...your grandma and she has a mac and you have a PC chances are her getting it to work is not going to be "out of the box easy" so to speak.
Left with this, I think you have a couple choices...first off, you do need to package your classes - a runnable jar will work fine. Aside from that, you will most likely have to build OS specific scripts (batch scripts for Windows, shell scripts for unix, etc.) and you will have to hand these out with your jar file. That being said, the intended user will still need to have java installed, and the batch scripts themselves are not likely to be trivial endeavors.
Your next option would be to use JNLP. However, I don't think JNLP has a command line mode, so you will likely have to simulate a console with something like a JTextArea.
As far as I see it, your last option it to use one of the many products (not sure if there are any free ones) that package java into native code. I think Exe4j is one such example - but, like I said, I am not sure if there are any free ones and I am not sure how hard they are to use.
Best of luck, and if you can't get your jar to work you should probably move that to its own question.
I am developing a web based java app, running on jboss and sql server.
I seem to find myself spending an inordinate amount of time recompiling/deploying just to tweak the interface in jquery/javascript/css/html.
Any tips for reducing the turnaround ?
Its deployed to an ear file, so I can not alter the jsps/javascript after deployment(?). Yes, I have created the a static version of the webpage frontends but they do not give me the full functionality - none of the data from db/jstl processing.
To clarify its not so much the actual compile time itself (30seconds) as the ant builds are set-uo well and are very modular; its the subsequent deployment to jboss and accessing the application that cause the real headache.
If you do not work directly in an exploded war inside the hotdeploy folder of JBoss, then strongly consider it.
when developing with application server i've used this product in the past: JRebel from zeroturnaround.
It will prevent having to restart and redeploy an application running within an application server. It works for most scenario's however i found that there were a few occasions when a server restart were required(in my case making changes to the application initialisation). But if you're only working on the interface this product will save you a great number of deployments and restarts.
I have not used Jrebel in combination with JBoss but they mention it as a supported container so thta shouldn't be a problem.
I am an average web designer (at best!) and writing complicated HTML and CSS is a pain for me. A lot of what I do with styles and layout is trial and error and involves a lot of tweaking. I also change my mind frequently about exactly what shade of color I want things. Basically, I'm in the same boat as you.
Long ago I abandoned the idea of the tweak-deploy-test iteration cycle (mvn clean tomcat:deploy takes 2 minutes on my current project) as by the 10th iteration trying to sort a simple layout problem and waiting for the deployment would drive me round the bend. I now use two strategies;
Get a static copy of the HTML I want to work with. This usually means deploying the app, navigating to the page and saving it to a work directory somewhere. This saves the static HTML as well as any images. Next I copy the CSS files from my workspace into the work directory and hand edit the saved HTML file to point to these CSS files.
Open the static HTML page in Firefox. Now I can tweak the CSS or HTML and simply refresh Firefox to show the changes. Iteration time is now down to about 1 second. I can further improve my tweaking using the Firebug addon. This allows you to manipulate the CSS and HTML from within Firefox. This is especially useful for getting margin and padding size right. Once I've tweaked it in Firebug I hand edit the saved HTML and CSS then refresh Firefox to make sure I'm happy with the result.
At certain key stages I then make the changes to my workspace to reflect my tweaking on the static files. I then redeploy and test to make sure I got it right. As I use Firefox for all my development I have to pay special attention to browser compatibility, especially with IE, but this usually comes at a later stage.
Edit:
I didn't mention Javascript, but this process works great for JS too!