This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 218806 - jsf pages are not deployed on save
Summary: jsf pages are not deployed on save
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.2
Hardware: PC Windows 7
: P3 normal with 2 votes (vote)
Assignee: Martin Janicek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-22 06:42 UTC by ymajoros
Modified: 2013-09-30 14:27 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ymajoros 2012-09-22 06:42:32 UTC
I have an EAR project (EJB + 2 WARS). It used to be ant-based (netbeans-generated), but I switched to maven recently (structure: PARENT POM/EAR/EJB/WAR1/WAR2). 

Most things seem ok, but my jsf pages (or other web resources) aren't copied when I save them.

I can't attach the project here (although I'm ok to send it to someone if he keeps it private).

I'm almost sure it's a bug. I see no reason for it not to work. I compared with similar projects (netbeans-generated pom's) and I see no obvious difference. I tried checking "deploy on save" on the WAR and EAR, and various "compile of save" options, with no luck.

BTW, is there any way to debug this myself?
Comment 1 ymajoros 2012-09-22 06:44:07 UTC
FYI, also tried with build 201209031048, but didn't see any difference. Also, most of the time, I'm debugging my project rather than just running, but it doesn't seem to matter.
Comment 2 David Konecny 2012-09-23 20:26:00 UTC
Deploy on save was not working in dev builds - see issue 218518. Could this problem be a duplicate?
Comment 3 ymajoros 2012-09-23 20:32:27 UTC
7.2 is broken too, so i guess it's not a duplicate of  issue 218518
Comment 4 ymajoros 2012-09-24 05:48:33 UTC
Doesn't work in 201209230001 neither.
Comment 5 Martin Janicek 2012-09-24 07:35:48 UTC
I thought it could be duplicate of the issue 215976, but based on the comment 4 it doesn't seem like it is (215976 has been already fixed few weeks ago and I've just tried to reproduce it with the current daily build with no success - but I was trying only few basic use cases).

Would it be possible to create simple project with a minimalistic structure and attach it here? Alternatively you can send me your project - of course I'll keep it private..

BTW: If you would like to debug this by yourself you need to download NetBeans sources first [1]

[1] NetBeans sources: http://wiki.netbeans.org/WorkingWithNetBeansSources
Comment 6 ymajoros 2012-09-24 15:05:18 UTC
mjanicek@netbeans.org: sent you an email with link to private project.
Comment 7 Martin Janicek 2012-10-04 08:39:32 UTC
Thanks, I'm on it ;)
Comment 8 Martin Janicek 2012-11-01 12:34:28 UTC
Ymajoros, I have some troubles with getting your project run-able in my environment. Could you please try to narrow the problem to a specific set of steps which I should follow to reproduce?

From your description I understand that the problem occurs in Maven web projects when you are changing xhtml files (or some other resources). But I tried to create new project with index.xhtml inside and after running the project, I'm still able to see new changes after saving the file in NetBeans. Could you please confirm this behavior?
Comment 9 Martin Janicek 2012-11-06 08:31:14 UTC
Closing as INCOMPLETE for now. Can't do much without additional information and all the basic scenarios works as expected (at least for me).
Comment 10 ymajoros 2012-11-06 09:08:35 UTC
It happens on the WAR of an EAR project.

Changing a page, then saving... Not deployed.

I can confirm it works with new projects too, on the same machine. The problem is only with this one.

Maybe I can help running my project? I guess the main problem will be the servlet listener (database migration). It will fail, you could safely remove it. The application won't run properly, but you could at least see the problem.

I guess you have the right datasource in Glassfish, too (even on an empty database)?

To run the project, just run the EAR (not WAR) after building all projects.
Comment 11 mrauscher 2012-11-30 22:40:06 UTC
Got the same here with 7.2.1 (Build 201210100934) with a project that was created in an earlier version of NB. Closing NB and removing all contents from the var-directory 'helped'. Whereas 'helped' means that deploy on save is performed now but it is alternating between incremental and full redeployment.

To narrow the problem I tried it with a new project. Steps to reproduce:

1. Create a new Maven Enterprise Application project
2. Add a session bean to the ejb-project
3. Clean & build the main project
4. Run the ear
5. Modify index.jsp in the web-project
6. Save
7. Reload browser

At 6 and 7 three things happen: first, the browser reflects the changes that have been made to index.jsp. Second, NB status line shows "mavenproject1-ear failed". Third, the IDE log contains:

INFO [org.netbeans.modules.j2ee.deployment.impl.TargetServer]: Cannot incrementally deploy to more than one target
WARNING [glassfish-eecommon]: Deployment plan not supported in GlassfishConfiguration.save()
WARNING [glassfish-eecommon]: Deployment plan not supported in GlassfishConfiguration.save()
WARNING [glassfish-eecommon]: Deployment plan not supported in GlassfishConfiguration.save()
INFO [org.netbeans.modules.j2ee.deployment.impl.TargetServer]: On save deployment failed

8. Modify index.jsp again
9. Save

Now, a full redeployment is performed and in the status line appears a friendly "mavenproject1-ear deployed."

Don't know, if these things are related to each other. If not, I'll file a new bug.
Comment 12 Martin Janicek 2012-12-06 16:09:26 UTC
mrauscher your problem looks actually like a different issue. Could you please try to reproduce your problem with a different application server than Glassfish?
Comment 13 ymajoros 2013-02-25 15:59:20 UTC
Really, that would be difficult. There is a lot of configuration, and I have a custom authentication module. There is definitely a problem with web app refresh in Netbean with Glassfish.

Now, the strange part is... it sometimes works!

I have 4 projects which have a similar setup (EAR, EJB+WAR). Some of them work fully, others work sometimes. If I uncheck "compile on save" / "deploy on save", it doesn't seem to work. 

First, how is it supposed to work? I mostly run my apps in debug mode. I don't need "deploy on save", just being able to hot-replace some code from time to time, and having my jsf pages being refreshed. BTW, it never works if I redeploy my app, I have to undeploy / stop glassfish / debug for it to work. Which options should I check?
Comment 14 ymajoros 2013-04-19 19:24:15 UTC
Can someone answer to my last comment?

"how is it supposed to work? I mostly run my apps in debug mode. I don't
need "deploy on save", just being able to hot-replace some code from time to
time, and having my jsf pages being refreshed. BTW, it never works if I
redeploy my app, I have to undeploy / stop glassfish / debug for it to work.
Which options should I check?"
Comment 15 Martin Janicek 2013-06-05 08:17:39 UTC
(In reply to comment #14)
> "how is it supposed to work? I mostly run my apps in debug mode. I don't
> need "deploy on save", just being able to hot-replace some code from time to
> time, and having my jsf pages being refreshed.

I'm sorry for the late response, I didn't have enough of time to follow all the comments in all areas.
Compile on save is working on both, static resources (jsp, html pages etc.) and on Java classes. In Ant based projects we also have a feature called "Copy Static Resources on Save" which does only the first part without any javac compilation. It sounds to me that you are looking for something like that, right? Unfortunately we don't support similar feature in Maven (follow the issue [1] if you are interested in).

More details about Compile on Save in Maven projects can be found here [2].

[1] https://netbeans.org/bugzilla/show_bug.cgi?id=220493
[2] http://wiki.netbeans.org/FaqCompileOnSave#Using_Compile_on_Save_in_Maven_Projects
Comment 16 Martin Janicek 2013-08-19 07:47:48 UTC
I'm sorry but I'm still not able to reproduce the problem. Ymajoros, would it be possible to send me your project one more time (original link you sent me is obsolete at the moment)? We are in the middle of 7.4 fixing phase and I have some time to play with it, if the problem still persist. Thanks
Comment 17 ymajoros 2013-08-26 19:25:19 UTC
Well, I still don't know what the current situation is.

I read https://netbeans.org/bugzilla/show_bug.cgi?id=220493. There, https://netbeans.org/bugzilla/show_bug.cgi?id=221258 is mentioned where it seems to be implied that jsp's should be copied.

My projects all look the same: parent POM, EAR consisting of one or more WARs and ejb-JAR.

I want to be able to:

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 if I deployed 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. 

I think this is the point where a wiki page, describing the various compile/deploy on save tricks, would be perfect.

What are the rules? 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.

If you can give me some explanations, I volunteer to write that wiki page.

If after explanations, it seems that it doesn't work as expected, I'll complete this bug report. I might even try to fix it myself, just need time for that, and maybe some pointers to know where to look without extensive searching.

Posted this to Stackoverflow: http://stackoverflow.com/questions/18451517/netbeans-deploy-on-save-how-is-it-supposed-to-work
Comment 18 Martin Janicek 2013-09-05 12:33:40 UTC
(In reply to ymajoros from comment #17)
> 1) works most of the time; it sometimes doesn't if I deployed many times
> (why?)

Don't know. I would need a reproducible use case to be able to debug the problem.

> 2) works in some project, not in others

Same situation as above. If it sometimes works and sometimes don't, it's probably an internal code issue, but I can hardly do anything without real project.

> What are the rules? How is it supposed to work? I can't seem to have 1) and
> 2) working on the same time for all my projects.

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.

> If you can give me some explanations, I volunteer to write that wiki page.

Would be nice to do that I guess, so if you find some spare time it would be awesome ;)
Comment 19 ymajoros 2013-09-05 13:41:10 UTC
Still, some combinations of options on WAR or EAR seem to do it for me. In some project, static resources are copied, without redeployment.

Sounds like a bug, then, but one that is quite interesting in my case ;-)

Can you see anything in the source that would make this possible?
Comment 20 Martin Janicek 2013-09-09 14:04:37 UTC
(In reply to ymajoros from comment #19)
> Can you see anything in the source that would make this possible?

Nope :( ..but today I have implemented official support for Copy on save for static resources (see issue 218345). Could you try it once the change-set will gets propagated?

There is a new combo box in Run properties that allows you to setup copying only static resources, so you should be finally able to correctly setup your projects.

It should work this way:

- With "Compile on save" enabled, classes are compiled to the target directory on save
- With "Copy static resources on save" enabled, all resources (html, xhthml, jsp) should be copied to the target directory
- With "Deploy on save" everything that is updated in target directory is also deployed to the server on save

..that means DoS doesn't make any sense if both CoS and CSRoS are disabled (because nothing gets updated in target directory, there is nothing to re-deploy to the server)

Please if you find any issue, open a new ticket about it.
Comment 21 Martin Janicek 2013-09-09 14:06:44 UTC
Also if you would agree, I'm voting for closing this issue as it doesn't provide any useful information at the moment. And if anything shows up related to the new feature, creating new tickets would make things much clearer.
Comment 22 ymajoros 2013-09-09 18:54:07 UTC
I'm ok to close the issue, but I think I hit a bug and would like to know if it's worth investigating.

I definitely have some project (parent pom + EAR + EJB-JAR + 2 WARs) where saving a static resource (jsf xhtml) copies it to the deployed path, making it immediately available. DoS is off on EAR, CoS is on. Same on WAR (but I'd guess it doesn't matter).

I always start my project in debug mode, could this enable static resources copy on save?

Is there something I can check with 7.3 or any specific dev version?

Let's see if I can trigger a bug on my project, and if it's not corrected in dev version, then we can close this issue.
Comment 23 Martin Janicek 2013-09-10 07:47:49 UTC
(In reply to ymajoros from comment #22)
> I definitely have some project (parent pom + EAR + EJB-JAR + 2 WARs) where
> saving a static resource (jsf xhtml) copies it to the deployed path, making
> it immediately available. DoS is off on EAR, CoS is on. Same on WAR (but I'd
> guess it doesn't matter).

I guess it's not possible to attach it, right? Would it be possible to try to create a similar project structure (with the same settings on each sub-project) and try if the problem is also there? At least we would be able to say if it's in the project setting or somewhere else (?) if thats even possible..

> I always start my project in debug mode, could this enable static resources
> copy on save?

Nope it should not make any difference for sure.

> Is there something I can check with 7.3 or any specific dev version?

Don't have any other idea to be honest. But if something comes to my mind I'll let you know
Comment 24 Martin Janicek 2013-09-30 14:27:34 UTC
Closing as FIXED. Please let me know if you consider current behavior (with two check boxes - one for java class files and the second one for static resources) comfortable. And file a new ticket in case of any troubles (this one is starting to be really chaotic). Thanks!