Sling Servlet Service | Community
Skip to main content
Level 4
October 16, 2015
Solved

Sling Servlet Service

  • October 16, 2015
  • 7 replies
  • 1568 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Runal_Trivedi

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 replies

joerghoh
Adobe Employee
Adobe Employee
October 16, 2015

Hi,

what are you trying to achieve?

kind regards,
Jörg

GK-007
Level 9
October 16, 2015

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

Runal_Trivedi
Runal_TrivediAccepted solution
Level 6
October 16, 2015

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.

smacdonald2008
Level 10
October 16, 2015

can you invoke your servlet with AJAX?

Maddy737Author
Level 4
October 16, 2015

Yes, i can invoke in ajax.

Maddy737Author
Level 4
October 16, 2015

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

GK-007
Level 9
October 16, 2015

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