[ 
https://issues.apache.org/jira/browse/WICKET-2826?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12903648#action_12903648
 ] 

Peter Ertl edited comment on WICKET-2826 at 8/27/10 5:46 PM:
-------------------------------------------------------------

Kill me for that ugly hack:

public class UglyCrackHoreBitchMFListener implements ServletContextListener
{
        private static final Logger log = 
LoggerFactory.getLogger(ClearJVMCacheListener.class);

        @Override
        public void contextInitialized(ServletContextEvent sce)
        {
                try
                {
                        ClassLoader cl = 
Thread.currentThread().getContextClassLoader();
                        Class<?> juc = 
cl.loadClass("sun.net.www.protocol.jar.JarURLConnection");
                        Field field = juc.getDeclaredField("factory");
                        field.setAccessible(true);
                        Object jff = field.get(null); // JarFileFactory
                        Field cacheField = 
jff.getClass().getDeclaredField("fileCache");
                        cacheField.setAccessible(true);
                        cacheField.set(null, new HashMap<Object, Object>());
                        cacheField = 
jff.getClass().getDeclaredField("urlCache");
                        cacheField.setAccessible(true);
                        cacheField.set(null, new HashMap<Object, Object>());
                }
                catch (Exception e)
                {
                        // unlucky -- different JVM, SecurityManager or 
whatever blocked you effort
                        log.error(e.getMessage(), e);
                }
        }

        @Override
        public void contextDestroyed(ServletContextEvent sce)
        {
        }
}


      was (Author: pete):
    Kill me for that ugly hack:

public class ClearJVMCacheListener implements ServletContextListener
{
        private static final Logger log = 
LoggerFactory.getLogger(ClearJVMCacheListener.class);

        @Override
        public void contextInitialized(ServletContextEvent sce)
        {
                try
                {
                        ClassLoader cl = 
Thread.currentThread().getContextClassLoader();
                        Class<?> juc = 
cl.loadClass("sun.net.www.protocol.jar.JarURLConnection");
                        Field field = juc.getDeclaredField("factory");
                        field.setAccessible(true);
                        Object jff = field.get(null); // JarFileFactory
                        Field cacheField = 
jff.getClass().getDeclaredField("fileCache");
                        cacheField.setAccessible(true);
                        cacheField.set(null, new HashMap<Object, Object>());
                        cacheField = 
jff.getClass().getDeclaredField("urlCache");
                        cacheField.setAccessible(true);
                        cacheField.set(null, new HashMap<Object, Object>());
                }
                catch (Exception e)
                {
                        // unlucky -- different JVM, SecurityManager or 
whatever blocked you effort
                        log.error(e.getMessage(), e);
                }
        }

        @Override
        public void contextDestroyed(ServletContextEvent sce)
        {
        }
}

  
> Wicket fails to read html markup from jar after updating and redeploying in 
> jetty
> ---------------------------------------------------------------------------------
>
>                 Key: WICKET-2826
>                 URL: https://issues.apache.org/jira/browse/WICKET-2826
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.7
>         Environment: Linux, jetty 6 using context deployer
>            Reporter: Adrian Sandor
>            Assignee: Igor Vaynberg
>             Fix For: 1.4.11
>
>         Attachments: jetty.xml, simplewicket.xml, simplewicket.zip
>
>
> I wrote a web application and packaged the main code and html markup files 
> into a jar. I deployed it in jetty using the "extracted war" folder structure 
> and a context descriptor. The application worked fine.
> Then I made a minor change in an html file, rebuilt the jar, copied it over 
> the old one in jetty and touched the descriptor to reload the context. Then 
> when trying to access the application in the browser, I got errors like:
> org.apache.wicket.markup.MarkupCache - Unable to find markup from 
> jar:file:/path/to/jar!/path/to/html 
> org.apache.wicket.util.resource.ResourceStreamNotFoundException: Resource 
> jar:file:/path/to/jar!/path/to/html could not be opened
>         at 
> org.apache.wicket.util.resource.UrlResourceStream.getInputStream(UrlResourceStream.java:179)
>                                                       
>         at 
> org.apache.wicket.markup.MarkupResourceStream.getInputStream(MarkupResourceStream.java:130)
>                                                        
>         at org.apache.wicket.markup.MarkupParser.parse(MarkupParser.java:265) 
>                                                                               
>  
>         at 
> org.apache.wicket.markup.loader.SimpleMarkupLoader.loadMarkup(SimpleMarkupLoader.java:52)
>                                                          
>         at 
> org.apache.wicket.markup.loader.InheritedMarkupMarkupLoader.loadMarkup(InheritedMarkupMarkupLoader.java:62)
>                                        
>         at 
> org.apache.wicket.markup.loader.DefaultMarkupLoader.loadMarkup(DefaultMarkupLoader.java:55)
>                                                        
>         at 
> org.apache.wicket.markup.MarkupCache.loadMarkup(MarkupCache.java:464)         
>                                                                     
>         at 
> org.apache.wicket.markup.MarkupCache.loadMarkupAndWatchForChanges(MarkupCache.java:559)
>                                                            
>         at 
> org.apache.wicket.markup.MarkupCache.getMarkup(MarkupCache.java:325)          
>                                                                     
>         at 
> org.apache.wicket.markup.MarkupCache.getMarkupStream(MarkupCache.java:216)    
>                                                                     
>         at 
> org.apache.wicket.MarkupContainer.getAssociatedMarkupStream(MarkupContainer.java:351)
>                                                              
>         at org.apache.wicket.Page.onRender(Page.java:1558)
> [...]
> Caused by: java.io.FileNotFoundException: JAR entry path/to/html not found in 
> /path/to/jar
> [...]
> org.apache.wicket.markup.MarkupNotFoundException: Markup of type 'html' for 
> component 'page.class.name' not found. [...]
>         at 
> org.apache.wicket.markup.MarkupCache.getMarkupStream(MarkupCache.java:227)
>         at 
> org.apache.wicket.MarkupContainer.getAssociatedMarkupStream(MarkupContainer.java:351)
>         at org.apache.wicket.Page.onRender(Page.java:1558)
> [...]
> If I restart jetty, with no other change, everything works fine.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to