11 May 2012

Filtering Classloading Failing With "ServletException: Servlet class: does not implement javax.servlet.Servlet"


In Oracle Weblogic Server 12.1.1.0

Symptoms

When having a POJO with @WebService annotation and the following is been thrown by WLS:

javax.servlet.ServletException: Servlet class: 'TestWS' does not implement javax.servlet.Servlet
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:292)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:250)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.StubSecurityHelper.initServletInstance(StubSecurityHelper.java:94)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:82)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:74)
at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:60)
at weblogic.servlet.internal.StubLifecycleHelper.(StubLifecycleHelper.java:34)
at weblogic.servlet.internal.ServletStubImpl.initStubLifecycleHelper(ServletStubImpl.java:638)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:579)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1874)
at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1848)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1738)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2740)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1704)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:781)
...


Cause

This occurs when classloading filtering is being used for the packages java.* or javax.*

Although this was common in 10.3.x, this is no longer supported since 12.1.1

i.e.:

<prefer-application-packages>
<package-name>javax.jws.*</package-name>
<package-name>javax.xml.ws.*</package-name>
<package-name>javax.annotation.*</package-name>
</prefer-application-packages>

Solution

remove the following tags from weblogic-application.xml and redeploy the application again:

i.e.:

<package-name>javax.jws.*</package-name>
<package-name>javax.xml.ws.*</package-name>
<package-name>javax.annotation.*</package-name>
 
References

http://docs.oracle.com/cd/E24329_01/web.1211/e24368/classloading.htm#i1097253

3 comments :

Thomas Isaksen said...

Thank you for this post, it helped me a lot ! :)

Anonymous said...

I am getting same error while deploying application wildfly, what is the solution in wildfly

Germán said...

this solution is specific for weblogic server.
wildfly has a different approach for classloading.

My Blog List

Blog Archive

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.