|
From: <tri...@tr...> - 2003-08-23 23:15:34
|
Lars,
I have looked into this a little bit more. What happens is that
ServletContextListener.contextInitialized() method is called _after_ the
HttpServlet.init() method is called on servlets specified with <load-on-
startup>. This causes the xxx-servlet.xml to be loaded before the
applicationContext.xml is loaded, so that is why you can't reference
the 'cwxDao' bean. This behavior is the opposite of what I see for Tomcat,
and I'm sure the same is true for Orion and Resin that Juergen is using. I
looked in the Servlet 2.3 specification, but I did not see anything specifying
which order these methods should be called in. Maybe Juergen or Rod can shed
some more light on this issue.
You should be able to use the ContextLoaderServlet for now.
Thomas
> Lars,
>
> This might be a WebLogic specific issue - I just saw similar error when I
> deployed my app in WebLogic 8.1.
>
> I will try to research this in more detail later on today or tomorrow. In
> the
> meantime try this in your web.xml
>
> <servlet>
> <servlet-name>cwxRootContext</servlet-name>
> <servlet-class>com.interface21.web.context.ContextLoaderServlet</servlet-
class>
> <load-on-startup>1</load-on-startup>
> </servlet>
>
> <servlet>
> <servlet-name>cwx</servlet-name>
> <servlet-class>com.interface21.web.servlet.DispatcherServlet</servlet-class>
> <load-on-startup>2</load-on-startup>
> </servlet>
>
> Thomas
>
>
>
> > Thomas,
> >
> > attached is the web.xml.
> >
> > Without the ContextLoaderListener nothing would happen, not even
> > the Hibernate stuff in applicationContext.xml.
> >
> > Thanks
> > Lars
> >
> > > Lars,
> > >
> > > You did not include your web.xml, but my guess is you need to add a
> > > ContextLoaderListener. The application context has to be loaded first,
> > > and the
> > > error messages indicates that the bean 'cwxDao' can't be found, so it
> > > looks like
> > > that did not happen.
> > >
> > > web.xml:
> > >
> > > <web-app>
> > >
> > > <!--
> > > - Loads the root application context of this web app at startup,
> > > - by default from "/WEB-INF/applicationContext.xml".
> > > -->
> > > <listener>
> > > <listener-class>
> > > com.interface21.web.context.ContextLoaderListener
> > > </listener-class>
> > > </listener>
> > >
> > > <!-- more definitions -->
> > >
> > > </web-app>
> > >
> > >
> > > Hope this helps.
> > >
> > > Thomas
> > >
> > >
> > >
> > > > Hi all Spring experts,
> > > >
> > > > can anyone provide me the example classes mentioned in several
> skeletons
> > >
> > > > (e.g. exampleController, exampleBusinessObject,
> exampleDataAccessObject)
> > > ?
> > > >
> > > > The two provided sample applications don't reflect the skeletons very
> > > well.
> > > > There should be one 'big' application showing all the stuff and many
> > > small
> > > > ones to show single options (like in WebWork 1).
> > > >
> > > > I've defined the following in applicationContext.xml (and it works):
> > > >
> > > > <bean id="cwxDao" class="example.dao.CwxDaoHibernate">
> > > > <property name="sessionFactory"><ref
> > > bean="cwxSessionFactory"/></property>
> > > > </bean>
> > > >
> > > > When defining
> > > >
> > > > (cwx-servlet.xml)
> > > >
> > > > <!-- Controller for the initial "Hello" page -->
> > > > <bean id="cwxController" class="example.web.CwxController">
> > > > <property name="cwxDao"><ref external="cwxDao"/></property>
> > > > </bean>
> > > >
> > > > (CwxController)
> > > >
> > > > private CwxDao cwxDao;
> > > >
> > > > public void setCwxDao(CwxDao cwxDao) {
> > > > this.cwxDao = cwxDao;
> > > > }
> > > >
> > > >
> > > > I always get
> > > >
> > > > ERROR [com.interface21.web.servlet.DispatcherServlet] - <Servlet with
> > > name
> > > > 'cwx' : initialization error>
> > > > com.interface21.beans.factory.NoSuchBeanDefinitionException: No bean
> > > named
> > > > [cwxDao] is defined {class
> > > com.interface21.beans.factory.xml.XmlBeanFactory:
> > > > defined beans [messageSource,viewResolver,urlMapping,cwxController]}
> > > >
> > > > This is the second time I get almost useless error messages. This is
> one
> > > > point where EJBs are far ahead (
> > > > there is almost always an error message telling you what excactly is
> > > > wrong).
> > > >
> > > > Another (dumb) question:
> > > >
> > > > What is the difference between a DAO *implementation* and a business
> > > object
> > > > and where does
> > > > e. g. Petclinic reflect this ? I'm asking this because of the
> diiference
> > > > between the skeletons and the
> > > > sample applications. The skeletons provide a DAO and a Business Object
> > > using
> > > > the DAO definition,
> > > > Petclinic does not. The samples should be as close as possible to the
> > > > skeletons or the skeletons should
> > > > at least provide the java classes (shouldn't be too hard).
> > > >
> > > > Thanks in advance
> > > > Lars
> > > >
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > This SF.net email is sponsored by: VM Ware
> > > > With VMware you can run multiple operating systems on a single
> machine.
> > > > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
> > > > at the same time. Free trial click
> > > here:http://www.vmware.com/wl/offer/358/0
> > > > _______________________________________________
> > > > Springframework-developer mailing list
> > > > Spr...@li...
> > > > https://lists.sourceforge.net/lists/listinfo/springframework-developer
> > > >
> > >
> > >
> > >
>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: VM Ware
> With VMware you can run multiple operating systems on a single machine.
> WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines
> at the same time. Free trial click here:http://www.vmware.com/wl/offer/358/0
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
|