EJB3 persistence in a Tomcat webapp (ThreadLocal pattern)

When you only want to use EJB3 persistence, and not the whole EJB3 stack).
First posted to http://forum.hibernate.org/viewtopic.php?t=963478 without an answer!
In the document "Using Hibernate with Tomcat" (http://www.hibernate.org/114.html), it is suggested that you create a ServletContextListener - like the one below - where the listener initializes and closes Hibernate on deployment and undeployment of your webapp.
public class HibernateListener implements ServletContextListener {
    public void contextInitialized(ServletContextEvent event) {
        HibernateUtil.getSessionFactory(); // Just call the static initializer of that class  
    public void contextDestroyed(ServletContextEvent event) {
        HibernateUtil.getSessionFactory().close(); // Free all resources
}My question is: If I want to use Hibernate as an EJB3 persistence engine in a Webapp running in Tomcat, do I make a similar ServletContextListener like this:
public class EntityManagerListener implements ServletContextListener {
    public void contextInitialized(ServletContextEvent event) {
        EntityManagerUtil.getEntityManagerFactory(); // Just call the static initializer of that class  
    public void contextDestroyed(ServletContextEvent event) {
        EntityManagerUtil.getEntityManagerFactory().close(); // Free all resources
public class EntityManagerUtil {
    private static EntityManagerFactory emf;
    public static final ThreadLocal<EntityManager> entitymanager = new ThreadLocal<EntityManager>();
    public static EntityManagerFactory getEntityManagerFactory() {
        if (emf == null) {
            // Create the EntityManagerFactory
            emf = Persistence.createEntityManagerFactory("example");
        return emf;
    public static EntityManager getEntityManager() {
        EntityManager em = entitymanager.get();
        // Create a new EntityManager
        if (em == null) {
            em = emf.createEntityManager();
            entitymanager.set(em);
        return em;
    public static void closeEntityManager() {
        EntityManager em = entitymanager.get();
        entitymanager.set(null);
        if (em != null) em.close();
}And then in my webapp use the following code:
public Person findByName(String name) {
    EntityManager em = EntityManagerUtil.getEntityManager();
    Query q = em.createQuery("select person from Person as person where name=:param");
    q.setParameter("param", name);
    Person p = (Person) q.getSingleResult();
    em.close();
    return p;
}Would that be the right way to do it?

Sun's reference JPA implementation (= EJB3 persistence) can be obtained from
https://glassfish.dev.java.net/downloads/persistence/JavaPersistence.html

Similar Messages

  • How can i use Hibernate 3.2 as my ejb3 persistence manager

    I get issues when i try to use Hibernate 3.2 as my ejb3 persistence manager in OC4J 10.1.3. I have included a persistence.xml file in META-INF/ of my ejb-jar.
    My classes are well annotated and would otherwise work with toplink, however i need to use hibernate.
    Persistence.xml >>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    version="1.0">
    <persistence-unit name="default" transaction-type="JTA">
         <provider>org.hibernate.ejb.HibernatePersistence</provider>
         <jta-data-source>appsconnDS</jta-data-source>
    <properties>
    <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
    </properties>
    </persistence-unit>
    </persistence>
    I get the following error when i deploy the jar.
    06/08/13 14:06:28 WARNING: DeployerRunnable.run java.lang.InstantiationException
    : Error initializing ejb-modules: nulloracle.oc4j.admin.internal.DeployerExcepti
    on: java.lang.InstantiationException: Error initializing ejb-modules: null
    at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:126
    at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun
    (OC4JDeployerRunnable.java:52)
    ... 4 more
    Caused by: java.lang.NullPointerException
    at java.util.Hashtable.put(Hashtable.java:396)
    at com.evermind.server.ejb.persistence.PersistenceUnitInfoImpl.addProper
    ty(PersistenceUnitInfoImpl.java:346)
    at com.evermind.server.ejb.persistence.PersistenceUnitInfoXMLFactory.par
    seProperties(PersistenceUnitInfoXMLFactory.java:126)
    2006-08-13 14:06:28.984 WARNING java.lang.InstantiationException: Error initiali
    zing ejb-modules: null

    Hi. I am also experiencing the same error as you are and would be interested in knowing how you solved it. thanks in advance

  • Getting list of applications in tomcat webapps

    Hi,
    I want to get the list of applications deployed in tomcat webapps in my java program.
    can anyone tell me how to do this
    thanks

    similar issue: since adobe reader was installed on IOS 5, I can not anymore "open in..." good reader!
    I feel like if my iPad file system had been removed!
    Removing one app (stanza) helped: confirming there is alimit of 4 "open in..." links for PDF file! Now, I have back good reader in the list.
    Just 4!? puzzling. Other had report a limit of 10.

  • [svn] 939: Bug: BLZ-67 - Should turn off session persistence in the Tomcat server we ship.

    Revision: 939
    Author: [email protected]
    Date: 2008-03-26 13:35:44 -0700 (Wed, 26 Mar 2008)
    Log Message:
    Bug: BLZ-67 - Should turn off session persistence in the Tomcat server we ship.
    QA: No
    Doc: No
    Checkintests: Pass
    Details - Turning off session persistence in the version of Tomcat that ships with BlazeDS. We don't store much in the session so session persistence doesn't make much sense for us. Users should feel free to turn this back on if they feel they need it.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/BLZ-67
    Modified Paths:
    blazeds/branches/3.0.x/servers/apache-tomcat-6.0.14/conf/context.xml

    Hi, thank you for your replies, I found out few things about my servlet, and its portability
    and i have few questions, although i marked this topic as answered i guess its ok to post
    I am using javax.servlet.context.tempdir to store my files in that servletcontext temporary directory. But i dont know how to give hyperlink
    of the modified files to the user for them to download the modified files.
    What i am using to get the tempdir i will paste
    File baseurl = (File)this.getServletContext().getAttribute("javax.servlet.context.tempdir");
    System.out.println(baseurl);
    baseurl = new File(baseurl.getAbsolutePath()+File.separator+"temp"+File.separator+"files");
    baseurl.mkdirs();so i am storing my files in that temp/files folder and the servlet processes them and modifies them, then how to present them as
    links to the user for download ?
    and as the servlet is multithreaded by nature, if my servlet gets 2 different requests with same file names, i guess one of them will be overwritten
    And i want to create unique directory for each request made to the servlet , so file names dont clash.
    one another thing is that i want my servlet to be executed by my <form action> only, I dont want the user to simply type url and trigger the servlet
    Reply A.S.A.P. please..
    Thanks and regards,
    Mihir Pandya

  • War file under tomcat/webapps (newbie)

    Quick question:
    I have a file myPrj.war and I place it under tomcat/webapps. I realize that tomcat creates a folder myPrj and I can run my application on the browser (so far so good). my question is this: say I made a revision to my application (therefore I have a new myPrj.war file) and I place the newly myPrj.jar on under the tomcat/webapps. Does tomcat 'know' that he should disregard the 'old' folder myPrj and create a new one (since there's a new myPrj.war)???
    thanks

    Generally speaking, If you replaced your java code or tag lib in jsp, you need to restart tomcat, otherwise, if you just made some changes to the basic html, you don't have to do so.

  • Tomcat WebApp Deployment question

    I am very new to tomcat and trying to get my very first web application up and running. This is the web app from the book Head First Servlet and JSP named Beer-v1
    Tomcat version: 5.0.28
    Platform: Windos 2000
    Problem:
    I have following structure
    c:\tomcat\webapps\Beer-v1\form.html
    c:\tomcat\webapps\Beer-v1\WEB-INF\web.xml
    c:\tomcat\webapps\Beer-v1\WEB-INF\classes\com\example\web\BeerSelect.class
    When I start the tomcat service and try to run my web app via IE
    http:/localhost:8080:/Beer-v1/form.html , it gives me resource could not be found error.
    If while tomcat is running, I create another folder under webapps and copy my form.html there and invoke it via IE it works fine. But if I stop and restart the tomcat service this also stops working.
    I know, I am doing something wrong and not setting some configuration files.
    Please help

    Sorry that was a typo. I am actually using this. I
    think localhost is fine as I can run the example
    applications which comes with tomcat just fine.
    Correct url:
    http:/localhost:8080/Beer-v1/form.html , it gives me
    resource could not be found error.Yes, you're correct. If the Tomcat welcome page is coming up with "localhost", then you're fine.
    Post the entire error.
    Look in the Tomcat logs. Sounds like you've either got a deployment problem or a syntax error in your web.xml that prevents Tomcat from starting the app.
    %

  • EJB3 - Persistence (Stored procedure)

    Hi All
    Can anybody help me with code (or links) -> how to call a stored procedure using EJB3 persistence.
    Regards

    A procedure is the name of a program module. And commonly used across numerous programming language.
    A stored procedure simply means that the program module is stored in the database server. The reason for adding the "stored" part to the name is because most of these other languages are client languages. Thus a module (procedure) in these languages will reside on the client (compiled in a EXE, DLL, etc).
    A stored procedure is different in that it does not exist on the client at all - it is stored on the database server and executed by the database server.
    Thus the basic difference is simply a matter of where the procedure resides.

  • JSP 2.0 running in Tomcat /webapps

    Hi Everyone,
    I've been racking my mind on figuring out how to run JSP 2.0 pages outside of Tomcat's "jsp-examples "directory. (running Tomcat 5.0.19)
    Initially, I created a subdirectory in the webapps directory called "jcce". In "jcce", I wrote a test page using JSP 2.0's Expression Language. The file included the code:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <% String s = "Work! Work! Work!";
    pageContext.setAttribute("name", s); %>
    <c:out value='${"name"}' />
    However, the page displays ${"name"}. When I place the same page inside a subdirectory of the "jsp-examples" directory, it displays "Work! Work! Work!"
    I looked at the lib directories in each WEB-INF directories and they contain the same jar files. I'm guessing it has something to do with configuring the web.xml file. The problem is that I've read so many tutorials on JSP 2.0 (even the specs), www.apache.org (jakarta project), JSTL, etc. and no one has mentioned how to configure the web.xml file appropriately to run JSP 2.0 pages on Tomcat.
    So my questions are:
    1. How can I deploy an application independently of the "jsp-examples" directory so that my JSP pages can takes advantage of the JSP 2.0 tag libraries?
    2. If I have to configure the web.xml file, can someone send me a simple configuration for the test code above?
    BTW, I've redeployed, and restarted Tomcat to see if any configuration changes would run the JSP 2.0 engine, but no success.
    Please help!
    Thanks,
    Bernard

    You're right, the web.xml file is probably the culprit.
    To retain backwards compatibility with web applications. EL is disabled in certain cases. (JSP spec section 3.3.2)
    There is a new page directive
    <%@ page isELIgnored="true|false"%>
    (Try putting <%@ page isELIgnored="false"%> at the top of your page to see if it will work with it)
    There is also a setting in the web.xml
    Check your web.xml file - if the DTD is less than version 2.4 and you haven't specified EL handling in web.xml or the page directive, EL is disabled by default.
    This should be the text at the top of web.xml.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
    Hope this helps,
    evnafets

  • Tomcat webapp jsp pages are blanc

    Hi,
    I'm using tomcat 5.5.17 and it's working fine. When I deploy my webapp to,I can start Tomcat , but when I request a jsp page, no matter which one it is, it returns a blanc page.
    Can someone help me?
    Thanks.
    Regards,
    Michiel.

    Hi,
    My Tomcat is configured well. Other webapps run just fine.
    Within my war file that Ideploy to this Tomcat installation there are several jar files included as a reference to them.Because at first I included as well the javax.servlet.jar and the javax.servlet.jsp.jar which Tomcat uses as well, I thought that there might bea conflictas I describedin my first post. But I removed them and there is no change (I stopped Tomcat before).
    Thanks.
    Michiel.

  • EJB3 Persistence

    We are trying to use our DAOs(Persistence layer) in stateless session been using dependency injection. This seems very easy with annotations. But our problem is that we want to make it generic so by changing the XML we can change the DAO which is to be injected. I read in couple of articles that its possible. But couldn't get any details and examples for the same.
    Any help and suggestions is really appreciated.
    Nidhi

    I seggest u add a property in persistence.xml that create your table automaticaly
    for example in hibernate u can write this code :
    <property name="hibernate.hbm2ddl.auto" value="update"  />

  • Deploy problem of JSF WebApp on Tomcat 5.5.17 SEVERE: Error listenerStart

    Hi there,
    My installation configuration is as followed:
    Tomcat5.5.17 using the following connector:
        <Connector
          port="8083"
          maxHttpHeaderSize="8192"
          maxThreads="150"
          minSpareThreads="25"
          maxSpareThreads="75"
          enableLookups="true"
          redirectPort="8080"
          acceptCount="100"
          debug="1"
          connectionTimeout="20000"
          disableUploadTimeout="true" />tomcat-user.xml defines:
    <?xml version='1.0' encoding='utf-8'?>
    <tomcat-users>
      <role rolename="manager"/>
      <role rolename="admin"/>
      <user username="tomcat" password="tomcat" roles="manager,admin"/>
    </tomcat-users>Tomcat starts up correctly with the following url and is runs while deploying:
    http://localhost:8083/manager/html
    My WebApp is a simple Test App and is the following:
    index.html:
    <html>
       <head>
          <meta http-equiv="Refresh" content= "0; URL=index.faces"/>
          <title>Start Web Application</title>
       </head>
       <body>
          <p>Please wait for the web application to start.</p>
       </body>
    </html>
    index.jsp:
    <html>
       <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
       <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
       <f:view>
          <head>                 
             <title>A Simple JavaServer Faces Application</title>
          </head>
          <body>
             <h:form>
                <h3>Please enter your name and password.</h3>
                <table>
                   <tr>
                      <td>Name:</td>
                      <td>
                         <h:inputText value="#{user.name}"/>
                      </td>
                   </tr>            
                   <tr>
                      <td>Password:</td>
                      <td>
                         <h:inputSecret value="#{user.password}"/>
                      </td>
                   </tr>
                </table>
                <p>
                   <h:commandButton value="Login" action="login"/>
                </p>
             </h:form>
          </body>
       </f:view>
    </html>welcome.jsp:
    <html>
       <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
       <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
       <f:view>
          <head>              
             <title>A Simple JavaServer Faces Application</title>
          </head>
          <body>
             <h:form>
                <h3>
                   Welcome to JavaServer Faces,
                   <h:outputText value="#{user.name}"/>!
                </h3>
             </h:form>
          </body>     
       </f:view>
    </html>
    UserBean.java:
    package com.jsfcore;
    public class UserBean {
         private String name;
         private String password;
         public UserBean() {
              super();
         private String getName() {
              return this.name;
         private void setName(String name) {
              this.name = name;
         private String getPassword() {
              return this.password;
         private void setPassword(String password) {
              this.password = password;
    web.xml:
    <?xml version="1.0"?>
    <!DOCTYPE web-app PUBLIC
       "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
       "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
       <display-name>Simple Login Applications</display-name>
       <servlet>
          <servlet-name>Faces Servlet</servlet-name>
          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
       </servlet>  
       <servlet-mapping>
          <servlet-name>Faces Servlet</servlet-name>
          <url-pattern>/faces/*</url-pattern>
       </servlet-mapping> 
       <welcome-file-list>
          <welcome-file>index.html</welcome-file>
       </welcome-file-list>
    </web-app>
    faces-config.xml:
    <?xml version="1.0"?>
    <!DOCTYPE faces-config PUBLIC
      "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
      "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
       <navigation-rule>
          <from-view-id>/index.jsp</from-view-id>
          <navigation-case>
             <from-outcome>login</from-outcome>
             <to-view-id>/welcome.jsp</to-view-id>
          </navigation-case>
       </navigation-rule>
       <managed-bean>
          <managed-bean-name>user</managed-bean-name>
          <managed-bean-class>com.corejsf.UserBean</managed-bean-class>
          <managed-bean-scope>session</managed-bean-scope>
       </managed-bean>
    </faces-config>I have downloaded jsf-1_1_01.zip and installed it.
    I have downloaded java_ee_sdk-5-windows.exe and installed it too.
    Path login/WEB-INF/lib contains the following jars:
    jsf/lib/jsf-api.jar
    jsf/lib/jsf-impl.jar
    tomcat/servler/lib/commons-digester.jar (fr. tomcat 4.1.3)
    tomcat/server/lib/commons-beanutils.jar (fr. tomcat 4.1.3)
    tomcat/webapps/jsp-examples/lib/jstl.jar (fr. tomcat 5.5.17)
    tomcat/webapps/jsp-examples/lib/standard.jar (fr. tomcat 5.5.17)
    The compilation and deployment was successful.
    With my build.xml, I have deployed the login.war file into path
    tomcat/webapps
    The login.war file was unpacked into the normal web application directory structure.
    That is where the problem appeared with the output display on the consol:
    Jul 27, 2006 11:10:39 AM org.apache.coyote.http11.Http11BaseProtocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8083
    Jul 27, 2006 11:10:39 AM org.apache.coyote.http11.Http11BaseProtocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8082
    Jul 27, 2006 11:10:39 AM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 750 ms
    Jul 27, 2006 11:10:40 AM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    Jul 27, 2006 11:10:40 AM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/5.5.17
    Jul 27, 2006 11:10:40 AM org.apache.catalina.core.StandardHost start
    INFO: XML validation disabled
    Jul 27, 2006 11:10:41 AM org.apache.catalina.startup.HostConfig deployWAR
    INFO: Deploying web application archive login.war
    Jul 27, 2006 11:10:41 AM org.apache.catalina.core.StandardContext start
    SEVERE: Error listenerStart
    Jul 27, 2006 11:10:41 AM org.apache.catalina.core.StandardContext start
    SEVERE: Context [login] startup failed due to previous errors
    Jul 27, 2006 11:10:42 AM org.apache.coyote.http11.Http11BaseProtocol start
    INFO: Starting Coyote HTTP/1.1 on http-8083
    Jul 27, 2006 11:10:42 AM org.apache.coyote.http11.Http11BaseProtocol start
    INFO: Starting Coyote HTTP/1.1 on http-8082
    Jul 27, 2006 11:10:42 AM org.apache.catalina.storeconfig.StoreLoader load
    INFO: Find registry server-registry.xml at classpath resource
    Jul 27, 2006 11:10:43 AM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 3047 ms
    I am unable to start the login application on the Tomcat Web Application Manager.
    The following Message appears on top:
    FAIL - Application at context path /login could not be started
    Let me say, that I have already continued developing more code for this application up to this point and wanted to test in the meantime. Since I had this failure I mentioned above, I have stripped down the application to the code above and I still have no success. I cannot go further until I am getting this very small application up and running on the server.
    Is anybody out there who could give me a hint to solve this problem?
    I really appreciate any hints, since I am circeling around the problem for guit a while.
    Thanks very much
    Markus

    Hi there,
    My installation configuration is as followed:
    Tomcat5.5.17 using the following connector:
        <Connector
          port="8083"
          maxHttpHeaderSize="8192"
          maxThreads="150"
          minSpareThreads="25"
          maxSpareThreads="75"
          enableLookups="true"
          redirectPort="8080"
          acceptCount="100"
          debug="1"
          connectionTimeout="20000"
          disableUploadTimeout="true" />tomcat-user.xml defines:
    <?xml version='1.0' encoding='utf-8'?>
    <tomcat-users>
      <role rolename="manager"/>
      <role rolename="admin"/>
      <user username="tomcat" password="tomcat" roles="manager,admin"/>
    </tomcat-users>Tomcat starts up correctly with the following url and is runs while deploying:
    http://localhost:8083/manager/html
    My WebApp is a simple Test App and is the following:
    index.html:
    <html>
       <head>
          <meta http-equiv="Refresh" content= "0; URL=index.faces"/>
          <title>Start Web Application</title>
       </head>
       <body>
          <p>Please wait for the web application to start.</p>
       </body>
    </html>
    index.jsp:
    <html>
       <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
       <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
       <f:view>
          <head>                 
             <title>A Simple JavaServer Faces Application</title>
          </head>
          <body>
             <h:form>
                <h3>Please enter your name and password.</h3>
                <table>
                   <tr>
                      <td>Name:</td>
                      <td>
                         <h:inputText value="#{user.name}"/>
                      </td>
                   </tr>            
                   <tr>
                      <td>Password:</td>
                      <td>
                         <h:inputSecret value="#{user.password}"/>
                      </td>
                   </tr>
                </table>
                <p>
                   <h:commandButton value="Login" action="login"/>
                </p>
             </h:form>
          </body>
       </f:view>
    </html>welcome.jsp:
    <html>
       <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
       <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
       <f:view>
          <head>              
             <title>A Simple JavaServer Faces Application</title>
          </head>
          <body>
             <h:form>
                <h3>
                   Welcome to JavaServer Faces,
                   <h:outputText value="#{user.name}"/>!
                </h3>
             </h:form>
          </body>     
       </f:view>
    </html>
    UserBean.java:
    package com.jsfcore;
    public class UserBean {
         private String name;
         private String password;
         public UserBean() {
              super();
         private String getName() {
              return this.name;
         private void setName(String name) {
              this.name = name;
         private String getPassword() {
              return this.password;
         private void setPassword(String password) {
              this.password = password;
    web.xml:
    <?xml version="1.0"?>
    <!DOCTYPE web-app PUBLIC
       "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
       "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
       <display-name>Simple Login Applications</display-name>
       <servlet>
          <servlet-name>Faces Servlet</servlet-name>
          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
       </servlet>  
       <servlet-mapping>
          <servlet-name>Faces Servlet</servlet-name>
          <url-pattern>/faces/*</url-pattern>
       </servlet-mapping> 
       <welcome-file-list>
          <welcome-file>index.html</welcome-file>
       </welcome-file-list>
    </web-app>
    faces-config.xml:
    <?xml version="1.0"?>
    <!DOCTYPE faces-config PUBLIC
      "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
      "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
       <navigation-rule>
          <from-view-id>/index.jsp</from-view-id>
          <navigation-case>
             <from-outcome>login</from-outcome>
             <to-view-id>/welcome.jsp</to-view-id>
          </navigation-case>
       </navigation-rule>
       <managed-bean>
          <managed-bean-name>user</managed-bean-name>
          <managed-bean-class>com.corejsf.UserBean</managed-bean-class>
          <managed-bean-scope>session</managed-bean-scope>
       </managed-bean>
    </faces-config>I have downloaded jsf-1_1_01.zip and installed it.
    I have downloaded java_ee_sdk-5-windows.exe and installed it too.
    Path login/WEB-INF/lib contains the following jars:
    jsf/lib/jsf-api.jar
    jsf/lib/jsf-impl.jar
    tomcat/servler/lib/commons-digester.jar (fr. tomcat 4.1.3)
    tomcat/server/lib/commons-beanutils.jar (fr. tomcat 4.1.3)
    tomcat/webapps/jsp-examples/lib/jstl.jar (fr. tomcat 5.5.17)
    tomcat/webapps/jsp-examples/lib/standard.jar (fr. tomcat 5.5.17)
    The compilation and deployment was successful.
    With my build.xml, I have deployed the login.war file into path
    tomcat/webapps
    The login.war file was unpacked into the normal web application directory structure.
    That is where the problem appeared with the output display on the consol:
    Jul 27, 2006 11:10:39 AM org.apache.coyote.http11.Http11BaseProtocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8083
    Jul 27, 2006 11:10:39 AM org.apache.coyote.http11.Http11BaseProtocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8082
    Jul 27, 2006 11:10:39 AM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 750 ms
    Jul 27, 2006 11:10:40 AM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    Jul 27, 2006 11:10:40 AM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/5.5.17
    Jul 27, 2006 11:10:40 AM org.apache.catalina.core.StandardHost start
    INFO: XML validation disabled
    Jul 27, 2006 11:10:41 AM org.apache.catalina.startup.HostConfig deployWAR
    INFO: Deploying web application archive login.war
    Jul 27, 2006 11:10:41 AM org.apache.catalina.core.StandardContext start
    SEVERE: Error listenerStart
    Jul 27, 2006 11:10:41 AM org.apache.catalina.core.StandardContext start
    SEVERE: Context [login] startup failed due to previous errors
    Jul 27, 2006 11:10:42 AM org.apache.coyote.http11.Http11BaseProtocol start
    INFO: Starting Coyote HTTP/1.1 on http-8083
    Jul 27, 2006 11:10:42 AM org.apache.coyote.http11.Http11BaseProtocol start
    INFO: Starting Coyote HTTP/1.1 on http-8082
    Jul 27, 2006 11:10:42 AM org.apache.catalina.storeconfig.StoreLoader load
    INFO: Find registry server-registry.xml at classpath resource
    Jul 27, 2006 11:10:43 AM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 3047 ms
    I am unable to start the login application on the Tomcat Web Application Manager.
    The following Message appears on top:
    FAIL - Application at context path /login could not be started
    Let me say, that I have already continued developing more code for this application up to this point and wanted to test in the meantime. Since I had this failure I mentioned above, I have stripped down the application to the code above and I still have no success. I cannot go further until I am getting this very small application up and running on the server.
    Is anybody out there who could give me a hint to solve this problem?
    I really appreciate any hints, since I am circeling around the problem for guit a while.
    Thanks very much
    Markus

  • Deploying a .war file - outside of Tomcat default webapps?

    I would like to deploy a war file outside of the [tomcat]/webapps directory.
    How can I get tomact to recognize AND unpack a war file in a location other then the default webapps directory?
    I have tried the following;
    altering server.xml -
    added context pointing directly to .war in other directory.
    adding context.xml entry to my war -
    added context.xml to META-INF of my war file, indicating that the docBase should be in outside directory.
    Neither of these created the desired result.
    Any suggestions?

    The following is from tomcat docs
    - http://tomcat.apache.org/tomcat-5.5-doc/config/host.html
    appBase : The Application Base directory for this virtual host. This is the pathname of a directory that may contain web applications to be deployed on this virtual host. You may specify an absolute pathname for this directory, or a pathname that is relative to the $CATALINA_BASE directory. Going by that. try making the change as below in your server.xml
    <Host name="localhost" appBase="your_directory"
           unpackWARs="true" autoDeploy="true"
           xmlValidation="false" xmlNamespaceAware="false" deployXML="true">I am going by what the doc says.
    I havent tried it out myself, so do let us know if that worked.
    cheers,
    ram.

  • Tomcat 6 Admin Webapp Headache

    Hi there,
    I've just installed Tomcat 6 and am now trying to install the Admin webapp. Firstly, I couldn't find it anywhere on the tomcat website and I eventually (after loads of searching around on google) found the following:
    http://www.apache.org/dist/tomcat/tomcat-5/v5.5.23/bin/apache-tomcat-5.5.23-admin.zip
    Obviously this is the admin app for version 5, but I can't find anything for version 6.
    I then unzipped it, and copied the webapps/admin directory to the Tomcat webapps directory. The webapp appears in the manager as started, but going to http://localhost/admin produced a blank page with the following error in the log:
    WARNING: Unexpected error forwarding to login page
    javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.apache.struts.taglib.html.HtmlTag
         at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
         at admin.login_jsp._jspService(login_jsp.java:118)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)
         at org.apache.catalina.authenticator.FormAuthenticator.forwardToLoginPage(FormAuthenticator.java:316)
         at org.apache.catalina.authenticator.FormAuthenticator.authenticate(FormAuthenticator.java:244)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.struts.taglib.html.HtmlTag
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at admin.login_jsp.class$(login_jsp.java:70)
         at admin.login_jsp._jspService(login_jsp.java:70)
         ... 19 moreHtmlTag definitely exists in webapps/admin/WEB-INF/lib/struts.jar
    Has anyone got any idea what's going on, and/or does anyone know how to get this working?
    Thanks,
    Chris.

    I found the following on apache's web site:
    There is no admin webapp for tomcat 6 and there is no plan to implement
    it. This has been answered in the archives so you could do a search for
    more details on why if you need more info.
    The URL to this is:
    http://mail-archives.apache.org/mod_mbox/tomcat-users/200707.mbox/%[email protected]om.au%3E

  • Problem in executing servlets under tomcat 4.1

    Dear Group,
    I am using Tomcat 4.1 and have the following directory structure:
    1.     C:\Tomcat 4.1\webapps\testapp
    ----It is my root directory and I have my html file called
    sample.html
    2.     C:\Tomcat 4.1\webapps\testapp\WEB-INF------web.xml is here
    3.     C:\Tomcat 4.1\webapps\testapp\classes\TestServlet.class
    -------here I have the servlet, no package---only one servlet
    My[b] web.xml has entry for:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
        <servlet>
            <servlet-name>TestServlet</servlet-name>
            <servlet-class>TestServlet</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>TestServlet</servlet-name>
            <url-pattern>/TestServlet</url-pattern>
        </servlet-mapping>
    </web-app>My[b] sample.html contains:
    <HTML>
    <BODY>
    <form method="post" action="http://localhost:8080/testapp/TestServlet">
    <input type=submit value="showServlet">
    <h2>
    <font color="green">First try on Serlvet</font>
    </h2>
    </form>
    </BODY>
    </HTML>Here is what I have done:
    1.     Started the Tomcat server
    2.     In the IE browser, I typed http://localhost:8080/testapp/sample.html
    -------- - the file shown correctly and I clicked the showServlet button.
    3.     I got the follow error �HTTP Status 404 - /testapp/TestServlet" the
    requested resource not availble
    4.     when I clicked the showServelt button the control goes to another page
    (as it should go to execute the servlet) .
    The URL is �http://localhost:8080/testapp/TestServlet�
    Please enlighten me where I went wrong?

    Hello all,
    Thank you for answering the question now the servlet gets executed.
    I here posts the steps i carried out to execute the
    servlet. If anyone have different idea pls post. Im
    pasting here the steps also attaching one.
    Steps to create your directory and work in Tomcat 4.1
    1.     Create your directory in Tomcat�s webapps Directory.
    -----If your tomcat is in d:\ the your directory may look
    ----- D:\tomcat\webapps\<your directory>
         ------E.g. �d:\tomcat\webapps\test�
    2.     In the test directory you can your html files directly or you can create a
    directory to hold html files.
         --------E.g. �d:\tomcat\webapps\test\first.html (OR)
    -------E.g. �d:\tomcat\webapps\test\html-files\first.html�
    3.     Create a folder called WEB-INF inside test
    -------E.g. �d:\tomcat\webapps\test\WEB-INF
    ------ Under the WEB-INF folder put your web.xml file
    4.     Create another folder named classes under the same test
    ----- E.g. �d:\tomcat\webapps\test\classes
    ----- Here you need to place your servlet classes
    ----- E.g. �d:\tomcat\webapps\test\classes\testServlet.class
    5.     Start any browser that are java enabled
    6.     Type �http://<machine name (or) IP add.>:8080/<your folder
    name>/<html file>�
    ----     E.g. http://localhost:8080/test/ html-files/first.html
    -----E.g.http://127.0.0.1:8080/test/html-files/first.html
    7.     Click the component (button, label�) to enable servlet
    8.     That�s all! Now you should get your servlet executed.
    Files:
    1.     web.xml
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems,
    Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
      <servlet>
        <servlet-name>testServlet</servlet-name>
        <servlet-class>testServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>testServlet</servlet-name>
        <url-pattern>/testServlet/*</url-pattern>
      </servlet-mapping>
    </web-app>
    2. first.html
    <html>
    <body>
    <form method="POST"
    action="http://localhost:8080/test/testServlet">
    <input type=submit value=click></input>
    </form>
    </body>
    </html>
    3. testServlet.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class testServlet extends HttpServlet
         public void doPost(HttpServletRequest req,
    HttpServletResponse res)throws      ServletException,
    IOException
              PrintWriter out = res.getWriter();
              out.println("<html>");
              out.println("<body>");
              out.println("<h1>Hello! </h1>");
              out.println("</body>"+"</html>");
    }I have put my first.html inside the folder
    �d:\tomcat\webapps\test\html-files\� and testServlet
    is under �d:\tomcat\webapps\test\WEB-INF\classes\� folder.

  • [TOMCAT] [SERVLET] : The requested resource () is not available.

    Hi!! I'm looking for an answer to my problem, and I'm going to explain what I mean.
    I've created a .jar named yuhuuTunnel.jar that has the following structure:
    yuhuuTunnel.jar:
    --> web (contains the servlets)
          --> *.class
          --> HelloWorldServlet.class
    --> META-INF
          --> MANIFEST.MF
    --> SimpleClient.classThe code of HelloWorldServlet.java is this:
        package web;
        import java.io.IOException;
        import java.io.PrintWriter;
        import javax.servlet.http.HttpServlet;
        import javax.servlet.http.HttpServletResponse;
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.ServletException;
        import javax.servlet.ServletConfig;
        public class HelloWorldServlet extends HttpServlet {
            public void init(ServletConfig config) throws ServletException {
                super.init(config);
            public void doGet( HttpServletRequest request, HttpServletResponse response )
                    throws ServletException, IOException {
                doPost(request, response);
            public void doPost( HttpServletRequest request, HttpServletResponse response)
                    throws ServletException, IOException {
                response.setContentType("text/html");
                PrintWriter out = response.getWriter();
                out.println("<html>");
                out.println("<body>");
                out.println("<body bgcolor=\"white\">");
                out.println("<h1>Yuhuu Servlet!</h1>");
                out.println("</body>");
                out.println("</html>");
        }then, using a .war file (created with ANT), I've created into /../tomcat/webapps/ a directory call yuhuuTunnel that has this structure:
        /webapps/
              --> yuhuuTunnel
                    --> WEB-INF
                            --> web.xml
                            --> lib
                                 --> yuhuuTunnel.jar
                    --> META-INF
                            --> MANIFEST.MF
                                 --> yuhuuTunnel.jar
                    --> index.htmlThe content of web.xml is the following:
        <?xml version="1.0" encoding="ISO-8859-1"?>
        <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
        <web-app>
            <!-- Action Servlet Configuration -->
            <servlet>
                 <servlet-name>HelloWorld</servlet-name>
                 <servlet-class>web.HelloWorldServlet</servlet-class>
                 <load-on-startup>0</load-on-startup>
            </servlet>
            <servlet-mapping>
                 <servlet-name>HelloWorld</servlet-name>
                 <url-pattern>HelloWorld</url-pattern>
            </servlet-mapping>
        </web-app>Tomcat works correctly ( http://localhost:8080 return me the page of tomcat ) but when I try to use the HelloWoldServlet typing http://localhost:8080/yuhuuTunnel/HelloWorld into a browser, this one returns me the HTTP Status 404 - The requested resource () is not available.
    What is wrong? The address that I type into the browser or there's an error into web.xml?
    Something interesting: If I type
    http://localhost:8080/yuhuuTunnel/HelloWorld
    the message given back is: "The requested resource () is not available."
    but if I type
    http://localhost:8080/HelloWorld the message is different:
    "The requested resource (/HelloWorld) is not available."

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
    <!-- Action Servlet Configuration -->
    <servlet>
             <servlet-name>HelloWorld</servlet-name>
             <servlet-class>web.HelloWorldServlet</servlet-class>
             <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping>
             <servlet-name>HelloWorld</servlet-name>
             <url-pattern>HelloWorld</url-pattern>
    </servlet-mapping>
    </web-app>Please change the servlet url pattern from
    <url-pattern>HelloWorld</url-pattern>to
    <url-pattern>/HelloWorld</url-pattern>in servlet mappings
    REGARDS,
    RaHuL

Maybe you are looking for

  • Moving to trash within Bridge

    hello. when in Bridge and i COMMAND + SHIFT to delete a file within the window, it doesn't dissapear. but if i move up a folder and back down, it's gone. i tried deleting preferences, caches, etc... and that didn't do anything. any help? thanks so mu

  • Entry list or value help?

    Hi Experts, i need a input box or a combo box for an entry field. For example this field should have an input assistance and should accept other values. For example i have a combo box for a licence number of a vehicle. So it must be possible to give

  • ICloud app starts explorer on windows 8, how can I default to Firefox?

    I do not use Explorer, I use Firefox, Windows 8 comes with pre-setted associations of what every app is opening.  Dowloading iCloud and installing it starts automatically Explorer. How can I change the settings? Thanks!

  • My Computer is completely frozen. What the **** do I do?

    So my wireless network was not working. So I restarted my computer, which also updated the software that needed to be updated. As it was restarting, it made a loud beep, on my last Mac that also happened when my computer was totally messed up. Now wh

  • WSRP - OperationFailedExceptionImpl

    We are using federation in weblogic portal 9.2. Essentially there are 2 web applications. One of the application's portlets are dropped as remote portlets on the first applciation. When we use navigation in application 1 which invokes remote portlet