Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap3: Fails to load with out webjars when using a theme #344

Closed
dmbeer opened this issue Mar 21, 2014 · 11 comments
Closed

Bootstrap3: Fails to load with out webjars when using a theme #344

dmbeer opened this issue Mar 21, 2014 · 11 comments
Assignees
Milestone

Comments

@dmbeer
Copy link
Contributor

dmbeer commented Mar 21, 2014

When using a theme wicket-bootstrap fails to load properly. Themes should use the CDN as well.

/**
     * configures wicket-bootstrap and installs the settings.
     */
    private void configureBootstrap() {
        final ThemeProvider themeProvider = new BootswatchThemeProvider() {
            {
                defaultTheme("spacelab");
            }

        };

        final BootstrapSettings settings = new BootstrapSettings();
        settings.setThemeProvider(themeProvider);
        Bootstrap.install(this, settings);
        BootstrapLess.install(this);
    }

Produces the following error:

12:40:56,328 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Tansu]] (MSC service thread 1-4) Exception starting filter wicket.Tansu: java.lang.ExceptionInInitializerError
    at de.agilecoders.wicket.webjars.util.WebjarsVersion.useRecent(WebjarsVersion.java:47) [wicket-webjars-0.4.1.jar:]
    at de.agilecoders.wicket.webjars.request.resource.WebjarsCssResourceReference.<init>(WebjarsCssResourceReference.java:27) [wicket-webjars-0.4.1.jar:]
    at de.agilecoders.wicket.core.markup.html.themes.bootstrap.BootstrapCssReference.<init>(BootstrapCssReference.java:34) [wicket-bootstrap-core-0.9.3-SNAPSHOT.jar:0.9.3-SNAPSHOT]
    at de.agilecoders.wicket.core.markup.html.themes.bootstrap.BootstrapCssReference.<init>(BootstrapCssReference.java:10) [wicket-bootstrap-core-0.9.3-SNAPSHOT.jar:0.9.3-SNAPSHOT]
    at de.agilecoders.wicket.core.markup.html.themes.bootstrap.BootstrapCssReference$Holder.<clinit>(BootstrapCssReference.java:17) [wicket-bootstrap-core-0.9.3-SNAPSHOT.jar:0.9.3-SNAPSHOT]
    at de.agilecoders.wicket.core.markup.html.themes.bootstrap.BootstrapCssReference.instance(BootstrapCssReference.java:27) [wicket-bootstrap-core-0.9.3-SNAPSHOT.jar:0.9.3-SNAPSHOT]
    at de.agilecoders.wicket.core.markup.html.themes.bootstrap.BootstrapTheme.<init>(BootstrapTheme.java:26) [wicket-bootstrap-core-0.9.3-SNAPSHOT.jar:0.9.3-SNAPSHOT]
    at de.agilecoders.wicket.core.settings.DefaultThemeProvider.<init>(DefaultThemeProvider.java:35) [wicket-bootstrap-core-0.9.3-SNAPSHOT.jar:0.9.3-SNAPSHOT]
    at de.agilecoders.wicket.themes.settings.BootswatchThemeProvider.<init>(BootswatchThemeProvider.java:18) [wicket-bootstrap-themes-0.9.3-SNAPSHOT.jar:0.9.3-SNAPSHOT]
    at com.copperarrow.tansu.web.WicketApplication$1.<init>(WicketApplication.java:88) [classes:]
    at com.copperarrow.tansu.web.WicketApplication.configureBootstrap(WicketApplication.java:88) [classes:]
    at com.copperarrow.tansu.web.WicketApplication.init(WicketApplication.java:68) [classes:]
    at org.apache.wicket.Application.initApplication(Application.java:819) [wicket-core-6.14.0.jar:6.14.0]
    at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:424) [wicket-core-6.14.0.jar:6.14.0]
    at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:351) [wicket-core-6.14.0.jar:6.14.0]
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
Caused by: java.lang.IllegalStateException: you have to call WicketWebjars.install() before you can use an IWebjarsResourceReference or any other component.
    at de.agilecoders.wicket.webjars.WicketWebjars.settings(WicketWebjars.java:81) [wicket-webjars-0.4.1.jar:]
    at de.agilecoders.wicket.webjars.util.WebjarsVersion$Holder.<clinit>(WebjarsVersion.java:29) [wicket-webjars-0.4.1.jar:]
    ... 24 more
@decebals
Copy link

Try to add WicketWebjars.install(this) as first line in your configureBootstrap() method

@dmbeer
Copy link
Contributor Author

dmbeer commented Mar 21, 2014

I can't use WicketWebjars due to incompatability with JBoss AS 7.1. Thanks for trying to help.

@l0rdn1kk0n
Copy link
Collaborator

bootswatch is based on webjars, but you can use the cdn resources instead (since 0.9.3-SNAPSHOT):

/**
     * configures wicket-bootstrap and installs the settings.
     */
    private void configureBootstrap() {

        final BootstrapSettings settings = new BootstrapSettings();
        settings.useCdnResources(true);

        final ThemeProvider themeProvider = new BootswatchThemeProvider(settings) {{
                defaultTheme("spacelab");
        }};
        settings.setThemeProvider(themeProvider);

        Bootstrap.install(this, settings);
        BootstrapLess.install(this);
    }

@dmbeer
Copy link
Contributor Author

dmbeer commented Mar 24, 2014

@l0rdn1kk0n This works if set theme as above with the new changes authored this morning. However if no theme is specified it fails to add css #345.

@l0rdn1kk0n l0rdn1kk0n added this to the 0.9.x milestone Mar 25, 2014
@l0rdn1kk0n l0rdn1kk0n self-assigned this Mar 25, 2014
@dmbeer
Copy link
Contributor Author

dmbeer commented Mar 25, 2014

@l0rdn1kk0n After this mornings change I change the code to the following:

final IBootstrapSettings settings = new BootstrapSettings();
        settings.useCdnResources(true);     

        BootswatchThemeProvider themeProvider = new BootswatchThemeProvider("Spacelab");
        settings.setThemeProvider(themeProvider);

        Bootstrap.install(this, settings);

I now get a NPE at at de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchTheme.getVersion(BootswatchTheme.java:78)

@martin-g
Copy link
Owner

I've improved it a bit with 463d027.

@dmbeer
Copy link
Contributor Author

dmbeer commented Mar 25, 2014

@martin-g Thanks this removes the NPE. The application loads but I get not theme css added. However I do get <html lang="en" class="theme-Spacelab"> Added to the html. Thanks for help on this one not really sure what to change to get the CSS added.

@martin-g
Copy link
Owner

Put a breakpoint at de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchTheme#renderHead and see what happens.

@dmbeer
Copy link
Contributor Author

dmbeer commented Mar 25, 2014

@martin-g Thanks for pointer. Debugging showed that at line 53 the CssHeaderItem was being created correctly but not added to the response I have fixed this locally by changing line 53 to the following:

response.render(CssHeaderItem.forReference(new UrlResourceReference(Url.parse(cdnUrl))));

I will commit changes and create a PR in the morning.

Thanks

@martin-g
Copy link
Owner

I've committed the fix.
Thanks!

@dmbeer
Copy link
Contributor Author

dmbeer commented Mar 26, 2014

Thanks

On 26 March 2014 07:21, Martin Grigorov [email protected] wrote:

I've committed the fix.
Thanks!

Reply to this email directly or view it on GitHubhttps://github.com//issues/344#issuecomment-38655891
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants