previously initiated loading for a different type with name "javax/servlet/http/HttpServletRequest"

I'm having a problem trying to get URL data using 

HttpServletRequest servReq = ServletActionContext.getRequest();
String test = servReq.getParameter("param");

Now i know that the first line "getRequest()" works fine, it is a problem with the "servReq.getParameter("param")".

I get the error stated in the title.

"Error rendering macro 'myMacro' : loader constraint violation: loader (instance of org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) previously initiated loading for a different type with name "javax/servlet/http/HttpServletRequest"

Have no idea what this means really, i've been trying to figure it out for a while and still no luck.

This is the dependency in the POM

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.4</version>
    <scope>provided</scope>
</dependency>

No i've tried to change somethings in the POM such as version and scope but nothing seems to stop the error.

Anyone know whats up with it or how to solve it?

If you you need any other information please comment.

Thanks.

1 answer

This looks like a dependency conflict - the bundle class loader for your add-on has erroneously loaded the HttpServletRequest class. This means that this class is somehow packaged in your add-on. Your dependency scope seems correct, so there must be something else wrong with your pom. Do mvn clean install and open the produced jar file - do you see classes from javax.* packages inside? If yes - you need to figure out why this happens. If not, try running confluence again, maybe you did not run a clean build after your experiments with the pom?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Opsgenie

Getting the Most out of Atlassian and Opsgenie Together

We’re excited to invite you to this action-packed webinar where we will demonstrate how to integrate Opsgenie’s powerful alerting and on-call management tools with your entire Atlassian stack. Mar...

21 views 0 0
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you