7 Replies Latest reply on Jul 2, 2008 4:17 AM by Samuel Mendenhall

    Seam installation

    guy bashan Apprentice

      Hi,
      
      I have just configured Seam to work with Facelets, Hibernate and MyFaces on tomcat. It seems like I am having some weird issues. In the log file I am getting this message:
       The listener "org.jboss.seam.servlet.SeamListener" is already configured for this context. The duplicate definition has been ignored.
      
      I double checked and there is no duplicate call to SeamListener (maybe the listener is registered from one of my jars?).
      
      I built a small login page using "identity". It seems like my "authenticate" method is being called twice when pressing the "login" button (it seems to be happening in some other test page I also built...). Is it related to the fact the listener is duplicated?
      
      In addition, I am also getting the following exception when server starts:
      23:42:03,492 WARN  [SessionFactoryObjectFactory] Could not bind factory to JNDI
      javax.naming.NamingException: Context is read only
              at org.apache.naming.NamingContext.checkWritable(NamingContext.java:903)
              at org.apache.naming.NamingContext.bind(NamingContext.java:831)
              at org.apache.naming.NamingContext.rebind(NamingContext.java:208)
              at org.hibernate.util.NamingHelper.bind(NamingHelper.java:74)
              at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:90)
              at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:306)
              at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
              at org.jboss.seam.persistence.HibernateSessionFactory.createSessionFactory(HibernateSessionFactory.java:165)
              at org.jboss.seam.persistence.HibernateSessionFactory.startup(HibernateSessionFactory.java:79)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
              at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
              at org.jboss.seam.Component.callComponentMethod(Component.java:2092)
              at org.jboss.seam.Component.callCreateMethod(Component.java:2015)
              at org.jboss.seam.Component.newInstance(Component.java:1976)
              at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
              at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
              at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:95)
              at org.jboss.seam.init.Initialization.init(Initialization.java:596)
              at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
              at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
              at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
              at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
              at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
              at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
              at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
              at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
              at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
              at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
              at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
              at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
              at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
              at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
              at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
              at org.apache.catalina.core.StandardService.start(StandardService.java:516)
              at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
              at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
              at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      


      Has anyone encountered such problems?


      Thanks,
      Guy.

        • 1. Re: Seam installation
          Daniel Hinojosa Master

          Are you using seam-gen, or your own setup?

          • 2. Re: Seam installation
            guy bashan Apprentice

            My own setup, I just assembled some of the seam examples (hibernate), added the jars and the needed configurations.

            • 3. Re: Seam installation
              System Administrator Expert

              I highly recommend running a seam-gen and comparing the components.xml, faces-config.xml, yourProject-ds.xml, web.xml and other configuration files against those in your project.


              You may also want to download JBoss 4.x or 5.0 beta and deploy your app there.  You will not be able to use EJB3 components with Tomcat only.  Typically, we use SFSB's as backing action components for JSF's.


              The JSF 1.2 implementation that is part of the JBoss distro is the Sun RI.


              • 4. Re: Seam installation
                Daniel Hinojosa Master

                Helping you debug your setup will be difficult without you sending the entire project to us.  So I was going to suggest what Arbi suggested, and compare seam-gen's war with yours.

                • 5. Re: Seam installation
                  guy bashan Apprentice

                  Thanks for your help.
                  I tried using seam-gen, and it is working very nice.
                  The problem is I am using Tomcat right now and I don't want to replace it at this point (I know I won't be able to use EJB3). It seems like the seam-gen needs JBoss to be around (I downloaded it just for seam-gen to work).
                  Anyway I gave a look at the project seam-gen created, and it seems like a very big project in terms of used jars. Is there a way of producing a bit smaller (more specific) project? I am using Hibernate, MyFaces, Facelets and Seam and currently I want all just to work together in order to start exploring Seam (the rest I know pretty well...).


                  Thanks,
                  Guy.

                  • 6. Re: Seam installation
                    guy bashan Apprentice

                    The thing that is really annoying me currently is just the fact that it seems like actions are being called twice.


                    I have this simple bean:


                    @Name("authenticator")
                    public class AuthenticatorAction
                    {
                      @In
                      Session nikoniansDatabase;
                    
                      @Out(required = false, scope = SESSION)
                      private User user;
                    
                      @Logger
                      private Log log;
                    
                      
                      public boolean authenticate()
                      {
                        System.out.println("xxxxxx");
                        log.info("Authenticating user: #{identity.username}");
                        List results = nikoniansDatabase.createQuery("select u from User u where " +
                            "u.username=#{identity.username} and u.password=#{identity.password}").list();
                        if (results.size() == 0)
                        {
                          log.info("User: #{identity.username} was not found");
                          return false;
                        }
                        else
                        {
                          user = (User)results.get(0);
                          log.info("User: #{user.email} (user.userId) was authenticated");
                          return true;
                        }
                      }
                    }




                    The authenticate action is being called twice. I can't figure out why is it happening. I have a feeling that every action on every page that I will write will be called twice (I also saw it on some more complex screen). I tried adding @Create annotation to the method authenticate after reading on some post that it solves some duplicate method call, but for my surprise the method was called 3 times...

                    • 7. Re: Seam installation
                      Samuel Mendenhall Apprentice

                      From the docs:



                      14.4.2.2. Special Considerations

                      When writing an authenticator method, it is important that it is kept minimal and free from any side-effects. This is because there is no guarantee as to how many times the authenticator method will be called by the security API, and as such it may be invoked multiple times during a single request. Because of this, any special code that should execute upon a successful or failed authentication should be written by implementing an event observer. See the section on Security Events further down in this chapter for more information about which events are raised by Seam Security.