コミュニティアチーブメントバーを展開する。

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

この会話は、活動がないためロックされています。新しい投稿を作成してください。

解決済み

Sling Servlet Service

Avatar

Level 4

Hi Team,

I have create a POST sling servlet in CQ.

And on form submit to this servlet am running the junit test case as below.

    @Override
    protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException
    {
        //Do something fun here
        response.setContentType("text/plain");
        response.getOutputStream().print("Hello POST AbsoluteUrlServlet World!");
        JUnitCore testcase = new JUnitCore();
        testcase.run(SampleTestMadhu.class);
    }

But am getting the below error

 

org/junit/runner/JUnitCore

Cannot serve request to /bin/acme/my/servlet in com.mycompany.myproject.AbsoluteUrlServlet

Exception:

java.lang.NoClassDefFoundError: org/junit/runner/JUnitCore

 

I have installed Junit and junit runner bundle is osgi container but still getting this error.

 

Please help.

1 受け入れられたソリューション

Avatar

正解者
Level 7

Maddy737 wrote...

 

 

I have installed Junit and junit runner bundle is osgi container but still getting this error.

Kindly make sure the imported bundles are in active state, also validate the API version for bundle that you have imported in OSGI and the one that you are referring in code is same.

元の投稿で解決策を見る

7 返信

Avatar

Employee Advisor

Hi,

what are you trying to achieve?

kind regards,
Jörg

Avatar

Level 9

Is this OSGi bundle in active state and also please share the entire class of your servlet.

Avatar

正解者
Level 7

Maddy737 wrote...

 

 

I have installed Junit and junit runner bundle is osgi container but still getting this error.

Kindly make sure the imported bundles are in active state, also validate the API version for bundle that you have imported in OSGI and the one that you are referring in code is same.

Avatar

Level 10

can you invoke your servlet with AJAX?

Avatar

Level 4

Yes, i can invoke in ajax.

Avatar

Level 4

i want to run selenium junit test case from my component.

Avatar

Level 9

If possible please share the pom.xml which has references to these jars.