Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8073147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:14:46+00:00 2026-06-05T14:14:46+00:00

In a Wicket 1.4 app, I have some static CSS & JS resources under

  • 0

In a Wicket 1.4 app, I have some static CSS & JS resources under [project root]/WebContent/css and [project root]/WebContent/js respectively.

enter image description here

My Wicket HTML files are in src/resources/fi/company/product/pages with corresponding Java classes in src/main/fi/company/product/pages. (In the resulting WAR file, the HTML & property files are of course in the same places as Java classes.)

The HTML files contain references to the resources such as:

<head>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script type="text/javascript" src="js/calendar.js"></script>
</head>

This works fine everywhere (or so we thought until recently). NB: my Java code does not reference these resources at all.

Looking at the source of a rendered page (whose URL is e.g. http://localhost:8080/report/42.4 or http://localhost:8080/?wicket:interface=:6:::: ), the resource reference appears as:

<link rel="stylesheet" type="text/css" href="../css/main.css"/> 

However, we just noticed that when the app is deployed somewhere else than (Tomcat) root, the resources break on non-bookmarkable pages.

In other words, when the URL is e.g.

http://localhost:8080/foobar/?wicket:interface=:2::::

and a page refers to

<link rel="stylesheet" type="text/css" href="../css/main.css"/>

…the browser tries to fetch the resource at the invalid URL

http://localhost:8080/css/main.css

Now, what is the simplest (yet non-hacky) way to get these static resources working, regarless of the deployment path?

I could switch to using bookmarkable pages exclusively (which would require changing the constructors of the pages), but I suppose that shouldn’t be necessary…


Edit: Looks like I got CSS resources working (on most places) simply by using <wicket:link>, as advised in this answer:

<head>
    <wicket:link>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    </wicket:link>
</head>

However, now the CSS references are broken on a page with an URL like http://localhost:8080/foobar/report/42.9

Wicket is trying to do something strange with the “css/main.css” path:

ERROR org.apache.wicket.RequestCycle - Can't instantiate page using constructor public fi.company.product.pages.ReportPage(org.apache.wicket.PageParameters) and argument 0 = "css" 1 = "main"
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor public fi.company.product.pages.ReportPage(org.apache.wicket.PageParameters) and argument 0 = "css" 1 = "main"
    at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:212)
    at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:89)
    at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:305)

Edit 2: Actually I’m not sure if <wicket:link> is the right solution here, since these resource files are not “class path resources“. I guess my question is, can you make this work while still using web context resources (i.e., without making these class path resources)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:14:49+00:00Added an answer on June 5, 2026 at 2:14 pm

    Right, I solved it, and the solution turned out to be very surprising.

    Earlier I wrote:

    A curious thing is that without any changes, it seems I can no longer
    reproduce the problem…

    That wasn’t quite true, as I had made one small change (that I thought was inconsequential): I had deleted a file WebContent/index.jsp which in our project was a remnant that served no purpose.

    Once it dawned on me that this could have fixed it, I did some more testing, and indeed:

    For static resources to work as expected, you must not have an index.html or index.jsp file in the root web content directory (i.e., the parent of the CSS and JS resource dirs), as that in some cases breaks ../ references.

    This probably isn’t even Wicket-specific, but perhaps it is Tomcat-specific—if anyone knows more, feel free to chime in. I’m dubious whether this question ever helps anyone else, but still, glad I got it working!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Apache Wicket 1.4: I have a panel that calls some setup Javascript in
I have a small Wicket app that I can deploy to Glassfish v3 without
In a Wicket app, I have a decimal number text field: TextField<BigDecimal> f =
We have a Wicket app with a page that includes an embedded Youtube video.
I have a Wicket 1.4.17 app in a standalone app in embedded Jetty 6.1.26.
I have plain HTML file and I want to include some JSTL tags in
In my Wicket app, I have a page with radio buttons and <label for=...>
I'm trying to run my (seam and) wicket app on an embedded jetty server.
I am currently working on a web app using Wicket and started using jQuery
I want to create a web app that will use wicket, hibernate and spring

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.