You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Andrew Todd <an...@gmail.com> on 2011/07/13 17:32:37 UTC

Resource auto-reload with the Quickstart project

Hello,

I'm investigating writing a new project in Wicket and am playing
around with a project created from the 1.5-RC5.1 quickstart maven
archetype.

Using 'mvn jetty:run' from the command-line, none of the changes I
make to source files, either Java or HTML, are picked up unless I
restart the server.

Using the instructions here:
https://cwiki.apache.org/WICKET/maven-jetty-plugin.html

I can attach to the Jetty instance from Eclipse, and changes to Java
files, but not HTML files, are picked up on the server.

However, "development mode" promises automatic reloading of source
files. I need this to work without having to attach to an IDE in debug
mode, and for HTML as well as Java. What am I missing?


Thanks,
Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Martin Grigorov <mg...@apache.org>.
See https://issues.apache.org/jira/browse/WICKET-3878 and
https://issues.apache.org/jira/browse/WICKET-3891.
RC5.1 has some issues in that area. Try with 1.5-SNAPSHOT.

On Wed, Jul 13, 2011 at 8:04 PM, Matt Brictson <ma...@55minutes.com> wrote:
> The way I've always done it (and this works just fine outside of Eclipse as well), is to enable resource polling in Wicket for the directory that contains the HTML files.
>
> In the init() method of your WebApplication subclass (in the quickstart this is called WicketApplication.java) do something like this:
>
> getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
> String htmlDir = getServletContext().getRealPath("/");
> if(htmlDir != null && !htmlDir.endsWith("/"))
> {
>    htmlDir += "/";
> }
> getResourceSettings().addResourceFolder(htmlDir + "../java");
> getResourceSettings().addResourceFolder(htmlDir + "../resources");
>
> You can find this code and some other best practices in my company's source repo here:
>
> <http://opensource.55minutes.com/svn/java/trunk/fiftyfive-wicket/fiftyfive-wicket-core/src/main/java/fiftyfive/wicket/FoundationApplication.java>
>
> --
> Matt
>
> On Jul 13, 2011, at 8:32 AM, Andrew Todd wrote:
>
>> Hello,
>>
>> I'm investigating writing a new project in Wicket and am playing
>> around with a project created from the 1.5-RC5.1 quickstart maven
>> archetype.
>>
>> Using 'mvn jetty:run' from the command-line, none of the changes I
>> make to source files, either Java or HTML, are picked up unless I
>> restart the server.
>>
>> Using the instructions here:
>> https://cwiki.apache.org/WICKET/maven-jetty-plugin.html
>>
>> I can attach to the Jetty instance from Eclipse, and changes to Java
>> files, but not HTML files, are picked up on the server.
>>
>> However, "development mode" promises automatic reloading of source
>> files. I need this to work without having to attach to an IDE in debug
>> mode, and for HTML as well as Java. What am I missing?
>>
>>
>> Thanks,
>> Andrew
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Matt Brictson <ma...@55minutes.com>.
Yes, it is possible configure the jetty plugin to completely redeploy the webapp when it detects a class file has changed, but this isn't quite the same as what the Eclipse IDE and JRebel do. JRebel's site says: "instantly see any code change made to an app *without* redeploying."

In my experience jetty's redeploy leads to memory being exhausted after the 4th or 5th redeploy. This is not jetty's fault, but simply because it is notoriously difficult to completely eliminate classloader leaks when building webapps.

YMMV.

-- 
Matt

On Jul 13, 2011, at 11:03 AM, Martin Grigorov wrote:

> It is possible but you have to extend maven-jetty-plugin's configuration.
> There was something about Scanner. Ask Google for more info
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Andrew Todd <an...@gmail.com>.
On Thu, Jul 14, 2011 at 1:22 PM, Matt Brictson <ma...@55minutes.com> wrote:
> Hmm. I would expect that your LoginPage would see changes reflected when you hit the browser refresh button. Sounds like a bug to me.
>
> Is it related to this one?
>
> https://issues.apache.org/jira/browse/WICKET-3891

This bug says that "With 1.5RC5.1 Wicket does not pick markup changes
unless I change requested version," which is the phenomenon that I'm
seeing. (The version indicator is the little "?1" at the end of the
URL, right?) So that is probably my bug. Not using JRebel.

Thanks,
Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Matt Brictson <ma...@55minutes.com>.
Hmm. I would expect that your LoginPage would see changes reflected when you hit the browser refresh button. Sounds like a bug to me.

Is it related to this one?

https://issues.apache.org/jira/browse/WICKET-3891

On Jul 13, 2011, at 12:10 PM, Andrew Todd wrote:

> On Wed, Jul 13, 2011 at 2:40 PM, Matt Brictson <ma...@55minutes.com> wrote:
>> FWIW I tried 1.5-SNAPSHOT and the HTML resource reloading seems to work fine.
> I'm seeing reloading working as expected on the basic HomePage.
> 
> However, on a LoginPage that I'm working on, a I do not see changes
> reflected until I go to the URL bar, go to the home page URL, then go
> back to the URL and manually enter the Login Page URL (which I've set
> up with mountPage).
> 
> Is this related to the way that Wicket handles sessions -- I've seen
> the word "version" passed around -- or is this a bug?
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Andrew Todd <an...@gmail.com>.
On Wed, Jul 13, 2011 at 2:40 PM, Matt Brictson <ma...@55minutes.com> wrote:
> FWIW I tried 1.5-SNAPSHOT and the HTML resource reloading seems to work fine.
I'm seeing reloading working as expected on the basic HomePage.

However, on a LoginPage that I'm working on, a I do not see changes
reflected until I go to the URL bar, go to the home page URL, then go
back to the URL and manually enter the Login Page URL (which I've set
up with mountPage).

Is this related to the way that Wicket handles sessions -- I've seen
the word "version" passed around -- or is this a bug?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Matt Brictson <ma...@55minutes.com>.
FWIW I tried 1.5-SNAPSHOT and the HTML resource reloading seems to work fine. Here's what I did:

1. Generated a quickstart[1] using 1.5-SNAPSHOT using the "-U" maven option to ensure the very latest snapshot was downloaded.
2. Pasted in the resource polling code into WicketApplication#init[2].
3. Ran mvn jetty:run.
4. While jetty was running, I edited Home.html: I changed "Congratulations" to "Testing".
5. Hit refresh in my browser and the change showed up.

[1]: http://wicket.apache.org/start/quickstart.html
[2]: http://apache-wicket.1842946.n4.nabble.com/Resource-auto-reload-with-the-Quickstart-project-tp3665329p3665543.html

-- 
Matt

On Jul 13, 2011, at 11:27 AM, Andrew Todd wrote:

> With the latest snapshot, I still wasn't seeing changes propagate. Until --
> 
> On Wed, Jul 13, 2011 at 2:03 PM, Martin Grigorov <mg...@apache.org> wrote:
>> It is possible but you have to extend maven-jetty-plugin's configuration.
>> There was something about Scanner. Ask Google for more info
> 
> Adding the scanIntervalSeconds configuration parameter to the Jetty
> plugin, as per
> 
> http://stackoverflow.com/questions/2369851/hot-deploy-in-embedded-jetty
> 
> suddenly changes in Java and HTML were picked up. Eclipse is set to
> auto-build, so I don't have to explicitly run 'mvn compile' for it to
> redeploy. However Matt's reply, which just came in, is correct that
> JRebel is doing something different.
> 
> The answer seems to be that
> 
> 1) HTML reload may still be broken in SNAPSHOT
> 2) For making changes to Java code, run in Debug mode and connect with
> an IDE, or use JRebel
> 
> 
> Thanks,
> Andrew
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Andrew Todd <an...@gmail.com>.
With the latest snapshot, I still wasn't seeing changes propagate. Until --

On Wed, Jul 13, 2011 at 2:03 PM, Martin Grigorov <mg...@apache.org> wrote:
> It is possible but you have to extend maven-jetty-plugin's configuration.
> There was something about Scanner. Ask Google for more info

Adding the scanIntervalSeconds configuration parameter to the Jetty
plugin, as per

http://stackoverflow.com/questions/2369851/hot-deploy-in-embedded-jetty

suddenly changes in Java and HTML were picked up. Eclipse is set to
auto-build, so I don't have to explicitly run 'mvn compile' for it to
redeploy. However Matt's reply, which just came in, is correct that
JRebel is doing something different.

The answer seems to be that

1) HTML reload may still be broken in SNAPSHOT
2) For making changes to Java code, run in Debug mode and connect with
an IDE, or use JRebel


Thanks,
Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Martin Grigorov <mg...@apache.org>.
On Wed, Jul 13, 2011 at 9:00 PM, Matt Brictson <ma...@55minutes.com> wrote:
> Just to clarify, the resource polling should allow you to see HTML changes (but note Martin's comment about this potentially being broken in 1.5RC1). It does not affect Java reloading.
>
> For Java changes I believe this is not possible without an IDE or perhaps a commercial product like JRebel[1]. For Eclipse, the way I've seen it done is to create a class like the Start.java that comes with the quickstart, right click on that class, and choose Debug. This will launch a Jetty container inside Eclipse's debugger, which gives you auto-reloading of Java files.
It is possible but you have to extend maven-jetty-plugin's configuration.
There was something about Scanner. Ask Google for more info
>
> [1]: http://www.zeroturnaround.com/jrebel/
>
> --
> Matt
>
> On Jul 13, 2011, at 10:37 AM, Andrew Todd wrote:
>
>> On Wed, Jul 13, 2011 at 1:04 PM, Matt Brictson <ma...@55minutes.com> wrote:
>>> The way I've always done it (and this works just fine outside of Eclipse as well), is to enable resource polling in Wicket for the directory that contains the HTML files.
>>>
>>> In the init() method of your WebApplication subclass (in the quickstart this is called WicketApplication.java) do something like this:
>>>
>>> getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
>>> String htmlDir = getServletContext().getRealPath("/");
>>> if(htmlDir != null && !htmlDir.endsWith("/"))
>>> {
>>>    htmlDir += "/";
>>> }
>>> getResourceSettings().addResourceFolder(htmlDir + "../java");
>>> getResourceSettings().addResourceFolder(htmlDir + "../resources");
>>
>> Thanks for the link. I added this code to init() and confirmed that
>> the paths being added are the correct ones for my Maven project.
>> However, I'm still not seeing HTML changes being updated when I do a
>> 'mvn jetty:run.' (Or Java changes, for that matter). Resources in the
>> htmlDir that was already set, like CSS, are also not updating.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Matt Brictson <ma...@55minutes.com>.
Just to clarify, the resource polling should allow you to see HTML changes (but note Martin's comment about this potentially being broken in 1.5RC1). It does not affect Java reloading.

For Java changes I believe this is not possible without an IDE or perhaps a commercial product like JRebel[1]. For Eclipse, the way I've seen it done is to create a class like the Start.java that comes with the quickstart, right click on that class, and choose Debug. This will launch a Jetty container inside Eclipse's debugger, which gives you auto-reloading of Java files.

[1]: http://www.zeroturnaround.com/jrebel/

-- 
Matt

On Jul 13, 2011, at 10:37 AM, Andrew Todd wrote:

> On Wed, Jul 13, 2011 at 1:04 PM, Matt Brictson <ma...@55minutes.com> wrote:
>> The way I've always done it (and this works just fine outside of Eclipse as well), is to enable resource polling in Wicket for the directory that contains the HTML files.
>> 
>> In the init() method of your WebApplication subclass (in the quickstart this is called WicketApplication.java) do something like this:
>> 
>> getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
>> String htmlDir = getServletContext().getRealPath("/");
>> if(htmlDir != null && !htmlDir.endsWith("/"))
>> {
>>    htmlDir += "/";
>> }
>> getResourceSettings().addResourceFolder(htmlDir + "../java");
>> getResourceSettings().addResourceFolder(htmlDir + "../resources");
> 
> Thanks for the link. I added this code to init() and confirmed that
> the paths being added are the correct ones for my Maven project.
> However, I'm still not seeing HTML changes being updated when I do a
> 'mvn jetty:run.' (Or Java changes, for that matter). Resources in the
> htmlDir that was already set, like CSS, are also not updating.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Andrew Todd <an...@gmail.com>.
> 'Resources in the
> htmlDir that was already set, like CSS, are also not updating.

I apologize for sending that last message prematurely; things in the
webapp/ directory are updating. HTML in the java/ subfolder is not,
however.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Andrew Todd <an...@gmail.com>.
On Wed, Jul 13, 2011 at 1:04 PM, Matt Brictson <ma...@55minutes.com> wrote:
> The way I've always done it (and this works just fine outside of Eclipse as well), is to enable resource polling in Wicket for the directory that contains the HTML files.
>
> In the init() method of your WebApplication subclass (in the quickstart this is called WicketApplication.java) do something like this:
>
> getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
> String htmlDir = getServletContext().getRealPath("/");
> if(htmlDir != null && !htmlDir.endsWith("/"))
> {
>    htmlDir += "/";
> }
> getResourceSettings().addResourceFolder(htmlDir + "../java");
> getResourceSettings().addResourceFolder(htmlDir + "../resources");

Thanks for the link. I added this code to init() and confirmed that
the paths being added are the correct ones for my Maven project.
However, I'm still not seeing HTML changes being updated when I do a
'mvn jetty:run.' (Or Java changes, for that matter). Resources in the
htmlDir that was already set, like CSS, are also not updating.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Resource auto-reload with the Quickstart project

Posted by Matt Brictson <ma...@55minutes.com>.
The way I've always done it (and this works just fine outside of Eclipse as well), is to enable resource polling in Wicket for the directory that contains the HTML files.

In the init() method of your WebApplication subclass (in the quickstart this is called WicketApplication.java) do something like this:

getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
String htmlDir = getServletContext().getRealPath("/");
if(htmlDir != null && !htmlDir.endsWith("/"))
{
    htmlDir += "/";
} 
getResourceSettings().addResourceFolder(htmlDir + "../java");
getResourceSettings().addResourceFolder(htmlDir + "../resources");

You can find this code and some other best practices in my company's source repo here:

<http://opensource.55minutes.com/svn/java/trunk/fiftyfive-wicket/fiftyfive-wicket-core/src/main/java/fiftyfive/wicket/FoundationApplication.java>

-- 
Matt

On Jul 13, 2011, at 8:32 AM, Andrew Todd wrote:

> Hello,
> 
> I'm investigating writing a new project in Wicket and am playing
> around with a project created from the 1.5-RC5.1 quickstart maven
> archetype.
> 
> Using 'mvn jetty:run' from the command-line, none of the changes I
> make to source files, either Java or HTML, are picked up unless I
> restart the server.
> 
> Using the instructions here:
> https://cwiki.apache.org/WICKET/maven-jetty-plugin.html
> 
> I can attach to the Jetty instance from Eclipse, and changes to Java
> files, but not HTML files, are picked up on the server.
> 
> However, "development mode" promises automatic reloading of source
> files. I need this to work without having to attach to an IDE in debug
> mode, and for HTML as well as Java. What am I missing?
> 
> 
> Thanks,
> Andrew
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org