Nandeshwar
Nandeshwar

Reputation: 94

Why struts2-junit plugin complains about convention plugin in?

I have a running project in Maven, Struts 2. I'm trying to add struts2-junit-plugin for testing.

So I added the plugin for struts2-junit.

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-junit-plugin</artifactId>
    <version>2.3.20</version>
</dependency>

After I run, I got this error:

java.lang.NoClassDefFoundError: javax/servlet/jsp/PageContext

Then I added the plugin for jsp-api.

<dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>jsp-api</artifactId>
    <version>2.2</version>
    <scope>prototype</scope>
</dependency>

When I ran it, I got a different error:

java.io.FileNotFoundException: class path resource [WEB-INF/content/] cannot be resolved to URL because it does not exist

I tried to do the following change to my struts.xml:

<constant name="struts.convention.result.path" value="/src/main/webapp/WEB-INF"

But it also did not work.

When I remove the struts2-convention-plugin from my pom file, it works.

But I need the struts2-convention-plugin. Can any one tell that what is the problem here?

Upvotes: 1

Views: 177

Answers (3)

Sahil Bhalla
Sahil Bhalla

Reputation: 175

I faced the same issue and was resolved by adding below line in struts.xml

<constant name="struts.convention.result.path" value="/" />

Upvotes: 0

Roman C
Roman C

Reputation: 1

You have used wrong version and a scope in dependency. Replace with

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

And use the default configuration for results' path

<constant name="struts.convention.result.path" value="/WEB-INF/content" />

Upvotes: 0

Nandeshwar
Nandeshwar

Reputation: 94

I got solution with help of one of my friend, I did not use this line <constant name="struts.convention.result.path" value="/src/main/webapp/WEB-INF" in struts.xml....

but i created folder structure WEB_INF/content/user-actions inside src/main/resources and it worked.

Upvotes: 1

Related Questions