views:

149

answers:

2

I got

javax.servlet.ServletException: Error instantiating servlet class servlets.MemoServlet
javax.naming.NameNotFoundException: Name servlets.MemoServlet is not bound in this Context

when using

<form action="MemoServlet">

I know I could use managedbeans, but I've to use servlets.

I suspect the problem has to do with JSF.

context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/MemoWeb/faces"/>

web.xml:

<servlet-mapping>
    <servlet-name>MemoServlet</servlet-name>
    <url-pattern>/faces/MemoServlet</url-pattern>
</servlet-mapping>

<servlet>
    <servlet-name>MemoServlet</servlet-name>
    <servlet-class>servlets.MemoServlet</servlet-class>
</servlet>

I seem to have this problem all over the place:

com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean userManager
....
Caused by: javax.naming.NameNotFoundException: Name user.UserManager is not bound in this Context
A: 

Sounds like as if the servlet is incorrectly been declared as a @WebService. This has nothing to do with JSF.

I strongly recommend to forget the JSF bit for this moment as you seem to misunderstand its purposes. The phrase "I have to use servlets" hints that your problem is deeper than that. I suggest to leave this all aside and get yourself through the basic Java EE books/tutorials first to get a more decent grasp and better understanding of how all the stuff is supposed to work and to be used.

BalusC
I don't have any @WebService annotation on the servlet, and the web.xml above doesn't add it either.I intend to use jsf only for the xhtml template-clients using xhtml code and form-servlets as much as possible. I understand these as http requests sent to a server thread, that based on the request parameters (session, etc..) which I think I understand.I suspect it has to do with jsf because it changed my context to include the prefix /faces.
simpatico
You basically need to provide more code detail, but I think it's hopeless as long as you're attempting to mix JSF/Facelets with plain vanilla Servlets. If your sole purpose is easy templating, then use a template framework, not a MVC framework. For example Velocity or Freemarker.
BalusC
So jsf/facelets goes only with 'jsf' servlets (I don't know anything about these). What I know is jspx + with EL + servlets (normal ones). The behavior i want from these templates is just what I could get with includes of jspxs (header, footer, navigation) etc...Please correct this assertion:I can use jsf xhtml template clients and then within the <ui:define> write any code that would be admissable in a jspx, within the body element.
simpatico
You can also use JSPX, yes. Facelets is tied to JSF as the "View" part of the MVC framework. Forget it when you want to use it without the `FacesServlet` as "Controller" and managed beans as "Model". This is only asking for trouble and confusion. To clarify: in JSF there's means of only ONE servlet, the `FacesServlet`. You normally don't worry about it at all and just do the business jobs in model objects (managed beans) the usual MVC way. To learn more about the difference between JSP/Servlet/JSF, you may find [this answer](http://stackoverflow.com/questions/2097732#2097732) useful.
BalusC
So the assertion is wrong due to the ONE FacesServlet restriction, which I cannot even inherit to place my servlet code in. So no jsf!
simpatico
As said, you likely don't want a full fledged MVC framework. You just want a simple templating framework. Forget JSF. It's not suitable for your requirements. I've mentioned two suitable frameworks in an earlier comment. *Use the right tool for the job!*
BalusC
A: 

don't use jpa 2 in java ee 5 container.

simpatico