Follow by Email

Saturday, October 13, 2012

Weblogic BEA-149265 , Caused By: java.lang.ClassNotFoundException: HttpServlet


Problem Description
I am using weblogic 10.3.3 server and was trying to deploy a web based application (build in eclipse).

 I have configured weblogic 10.3.3 server in eclipse and the application had no errors. It was running from inside eclipse like a charm.
After finishing the development and to test the application outside eclipse environment, I started standalone server instance (weblogic 10.3.3 outside eclipse , from command prompt) and was trying to deploy the same application and saw this strange error

<Error> <Deployer> <BEA-149265> <Failure occurredin the execution of deployment request with ID '1350125256034' for task '6'. Error is: 'weblogic.management.DeploymentException: 'weblogic.management.DeploymentException:        at weblogic.application.internal.BaseDeployment.throwAppException(BaseDe
ployment.java:157)

Caused By: java.lang.ClassNotFoundException: HttpServlet
        at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(Generic
ClassLoader.java:280)
        at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClass
Loader.java:253)
        at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAw
areClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        Truncated. see log file for complete stacktrace
> 

I was surprised to see it because same machine same server instance , if I run it from eclipse it works fine , outside eclipse it doesn’t work.
As you can see from the error message it was having problem loading the HTTPServlet  while deploying the application.
But the thing which wasted a lot of time was why the hell it is working on eclipse , as I was using the same weblogic server.
Ideally the servlet jar file shouldn’t be in your webapp/lib directory and it wasn’t , server will have it’s own copy of the jar file in it’s class loader.
Solution
It took some time to find the solution but it’s easy. I used eclipse to export a war file of my web project, and then started weblogic and deployed the war file instead of web app folder and it’s working now.
Similar problem encountered at test server
I saw the same problem on test even with the war file , after trying everything we can do to get rid of this problem with no success we decided to restart the Test instance.
The application was deployed successfully after Server restart.

Infect this solution should be followed as a practice
 When you export war file eclipse takes care of all the dependent jars and puts them in your war file , so if there is any possibility that you are using an external  library in your application eclipse will take care of including it in the final war when you export the project as a war file.
It is therefore highly recommended to export your eclipse project as WAR file and then send it for deployment.  

1 comment: