Friday, October 30, 2009

How To Solve java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet

While developing and deploying our Oracle ADF application on embedded JDeveloper 11g WLS (WebLogic Server), couple of times we have experienced strange WLS behavior. When developer was trying to run application from JDeveloper 11g IDE, after WLS server was starting up, application deployment was failing with following exception - java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet.


When we first encountered this exception, we didn't found any solution except just to do fresh check-out from SVN. After fresh check-out, application was running perfectly - strange things happen, there is always some magic ;-)

Later we found real cause for this deployment exception. We found solution as well, but still we didn't found exact scenario how to reproduce it in sample application, if you know scenario - feel free to post in comments. Now I will describe the reason and solution for this exception.

Exception happens, because for some unknown reasons, JDeveloper 11g IDE in very rare cases generates ViewController files in Model project:


This happens automatically, even when developer is not doing any work in Model. And then during deployment, WLS finds ViewController files in Model. And since Model don't have appropriate JAR libraries on class path (for absolutely logical reasons), it throws exception about javax.faces.webapp.FacesServlet not found:


In order to fix this exception, just go to file system and remove public_html folder from Model project:


Now go to your Model project, refresh it - not needed Web Content is gone:


When Web Content is removed from Model, you are ready to deploy and run your application again.

31 comments:

Unknown said...

Hey Andrejus,

Will try to see on what cases this happens in the meantime let me know is somebody discovers how to reproduce so we can file the bug.

Thanks,

Juan C.

Andrej Baranovskij said...

Hi Juan,

From what I saw, it sometimes can happen when working with ADF Task Flow Diagram. But, I'm not sure about exact steps how to reproduce. Will investigate.

Regards,
Andrejus

Unknown said...

Hi Andrejus,

This behaviour, having a webapp (public_html) folder in the model project already occurs with 10g. Never figured out why and when.


Ciao
Ainoa

Andrej Baranovskij said...

Hi Ainoa,

True, I remember it was happening for me in 10g as well.

Regards,
Andrejus

vivek said...

Hey Andrejus,

I have Installed Jdev11.1.1.4 on XP system.
on running my application i am getting the same error. i removed public-html from model folder but still getting the same error.

Anonymous said...

Got the same issue after I migrated my application to JDev 11.1.2.0.0 by error.
I then opened it back with JDev 11.1.1.5.0, but then got this issue.

Reverting to a backup prior migration solved the issue.

I presume opening an ADF application with a prior version of JDeveloper shouldn't be allowed, but the IDE didn't complain about it at all...

Travel for Life said...

Removing public-html folder did solve my issue. What I was doing is to refactor an Fusion application with multiple projects. Somehow JDev generated a public-html directory in my other project named OsmModel.

In the error message, I've seen "webapp OsmModel" which I didn't know that was the clue. Anyway, if you look under OsmModel project, you will found this public-html which you need to remove.

I'm using JDev 11.1.1.5.0.

Michelle said...

Hey Andrejus,
I'm a great fan or yours. Thank you for your very informative blog. I'm fairly new to ADF stuff and have migrated an ADF application from 10.1.3.5 to JDeveloper 11.1.1.4.
I managed to deploy an application with .jsp pages to the IntegratedWLS and the standalone WLS successfully.

I have since created a new application with .jspx pages and cannot deploy to either servers above. Error:
java.lang.ClassNotFoundException: oracle.adf.view.faces.webapp.UIXComponentTag. Any ideas?

Regards
Michelle

Andrej Baranovskij said...

Hi Michelle,

You should check if there are any Web related files created in Model project. Or, it might be ViewController project is missing ADF Faces libraries?

Andrejus

Michelle said...

Hi Andrejus,

There are no web related files in the Model Project. The ViewController Project Web Content/WEB-INF/lib folder contains the following files:
afc.jar, custComps.jar, industrial-adf-faces-impl.jar and portlet-client-adf.jar.

Under the ViewController Project Properties / Libraries and Classpath, the following Classpath entries have yellow warning signs and the Descriptions are red:
ASF Faces Cache, ADF Faces Industrial, Customizable Components, ADF Portlet Runtime, Portlet Runtime Client, Portlet Runtime Client WSRP Stubs and Portlet Runtime Dependencies.

There is no Class Path, Source Path or Doc Path associated with these.
What do I do to rectify this?
Thanks again for your help.

Michelle

Michelle said...

Also, under the Project Properties / JSP Tag Libraries / Distributed libraries are the following entries:
ADF Faces Cache 1.0
ADF Faces Industrial 1.0
ADF Portlet Components 10_1_3_4_0
JSF Core 1.2
Jsf HTML 1.2
Trinidad Components 1.2
Trinidad HTML Components 1.2

Andrej Baranovskij said...

The best would be to create new simple app, and compare config differences.

Andrejus

Michelle said...

Hi Andrejus,

I also notice the following warning when cursor is over ...< ? xml version .. ? > on my jspx source page:
"The JAR File afc.jar found in the WEB-INF\lib folder is not on the project class path".

The same warning is shown for custComps.jar, industrial-adf-faces-impl.jar and portlet-client-adf.jar.

I'm sure this all makes sense to you and I know this relates to my issue. I would really appreciate you pointing me in the right direction.

Thanks
Michelle

Andrej Baranovskij said...

It means something is really wrong with ViewController setup. I suggest to create fresh ViewController project and import your files there.

Andrejus

Michelle said...

Thank you Andrejus. Will try and see if it makes a difference.

Kind Regards
Michelle

Anonymous said...

Hello
I had the same problem too. The reason was the deployment profile configuration for model project. The problem was solved when I unchecked "Include libraries from other projects" for Library Dependencies.

Anonymous said...

Helloe Andrejus,

I've got a similar issue with my application.
It was configured with projects.
One for Declarative Components, one for taskflow librairies and the third one for my webcenter application. It works well when i add one for the ADF libraries project. But when i add the two librairies to my project, then it first works well but after a restart of JDev, some of my components were not correctly interpreted. The tag for the declarative can be found in the generated HTML code.

Regards

Andrej Baranovskij said...

Thanks for reporting, it would help if you could log this bug on public Oracle bug Wiki - http://redsamoracle.wikispaces.com/About

Andrejus

Anonymous said...

Hi Andrejus, this happened when I migrated the code from 11.1.1.5 to Jdev 11.1.2 version. This new folder is created during that time. Your fix really helped.

- Ravi

Andrej Baranovskij said...

This is very good from one point and not so good from other point - means Oracle still didn't fixed this bug :)

Andrejus

Anonymous said...

I had this problem in JDev 11.1.1.6 as well. Your solution worked. Thanks a lot !!

Daya said...

Hi Andrejus,

I think its because of web.xml generated in model project.

Andrej Baranovskij said...

Of course it is because of that. My point it - why JDev generates it automatically in the Model sometimes. This is JDev bug.

Andrejus

Kevin said...

So I'm able to recreate this issue by selecting your Model project, and then hit the 'refresh' button just above it... Seems to create a public_html folder every time for me... 11.1.1.6

Hope thats helpful!

Anonymous said...

Hey,

I recently encountered this behavior with Jdeveloper 11.1.1.7.

I was trying to generate wsdl for a java class and it did generate the View controller project for me. Well it did not throw this Exception when i tried to deploy this. But next day, tried deployment to Integrated Weblogic server and it started giving this exception. Then I tried deploying on Local Weblogic server and the exception started appearing there as well.

I tried reverting to last working version of Model project and generated wsdl but still deployment for WS failed.

Finally, removing public_html resolved it.

Thanks,
LAD

Anonymous said...

i have also the same issue in 11.1.2.4.0 by restarting my application.
Removing public_html from Model resolved it.

thanks
PL

Andrej Baranovskij said...

Cool :)

Dracontis said...

Hello,

I've solved this exception for my JDeveloper 11g.

... and this solution also solved BEA-160187 error for me in JDeveloper 12c. Please add some keywords in your article about this error, because it's very hard to solve error.

Andrej Baranovskij said...

Thanks for your comment. Error code keyword will be registered from your post.

Regards,
Andrejus

Kapil Singh said...

I am using JDeveloper 12.2.1 on windows 7 64bit and this error just occurred. So many versions down the line and still JDeveloper is generating/placing web files in model project.

Unknown said...

Still dealing with 11G (JDeveloper, Oracle database, etc.) at work and this post just saved my butt.

Thank you very much.