facebook

[Closed] contextConfigLocation loading problem

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #259545 Reply

    mimi_grebici
    Member

    Hi

    I use MyEclipse which generate DAO classes and mapping files
    but the configuration file where all mappings and DAO beans are defined is not executed !!! I dont know why!!

    Is it a hibernate version problem ?!!!

    this is my web.xml file :

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <web-app xmlns=”http://java.sun.com/xml/ns/j2ee&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; version=”2.4″ xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”&gt;

    <!– Spring Context Parameters –>
    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml,/WEB-INF/spring-services-beans.xml</param-value>
    </context-param>

    <context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>

    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>

    </context-param>

    <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>*.jsf</url-pattern>
    </servlet-mapping>

    <filter>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
    <init-param>
    <param-name>maxFileSize</param-name>
    <param-value>20m</param-value>

    </init-param>
    </filter>

    <filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <url-pattern>*.jsf</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <url-pattern>/faces/*</url-pattern>
    </filter-mapping>

    <!– Spring Servlet –>
    <!– !!! UTILISER ContextLoaderListener avec Servelt 2.4 API –>
    <servlet>
    <servlet-name>SpringContextServlet</servlet-name>
    <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <!– <init-param>
    <param-name>listings</param-name>
    <param-value>true</param-value>
    </init-param> –>
    </servlet>

    </web-app>


    And applicationContext.xml

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN//EN” “http://www.springframework.org/dtd/spring-beans.dtd”&gt;

    <beans>

    <bean id=”DataSource1″ class=”org.apache.commons.dbcp.BasicDataSource”>
    <property name=”driverClassName”>
    <value>org.postgresql.Driver</value>
    </property>
    <property name=”url”>
    <value>jdbc:postgresql://delta3177/Pims</value>
    </property>
    <property name=”username”>
    <value>pims</value>
    </property>
    <property name=”password”>
    <value>smip</value>
    </property>
    </bean>
    <bean id=”sessionFactory” class=”org.springframework.orm.hibernate3.LocalSessionFactoryBean”>
    <property name=”dataSource”>
    <ref bean=”DataSource1″></ref>
    </property>
    <property name=”hibernateProperties”>
    <props>
    <prop key=”hibernate.dialect”>org.hibernate.dialect.PostgreSQLDialect</prop>

    <prop key=”hibernate.show_sql”>true</prop>
    <prop key=”hibernate.cglib.use_reflection_optimizer”>true</prop>
    <prop key=”hibernate.cache.provider_class”>net.sf.hibernate3.cache.HashtableCacheProvider</prop>
    </props>
    </property>
    <property name=”mappingResources”>
    <list>

    <value>mapping/Program.hbm.xml</value>
    <value>mapping/Study.hbm.xml</value>

    </list>
    </property>

    </bean>

    <!– Spring Data Access Exception Translator Defintion –>
    <bean id=”jdbcExceptionTranslator” class=”org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator”>
    <property name=”dataSource”><ref bean=”DataSource1″/></property>
    </bean>

    <!– Hibernate Template Defintion –>
    <bean id=”hibernateTemplate” class=”org.springframework.orm.hibernate3.HibernateTemplate”>
    <property name=”sessionFactory”><ref bean=”sessionFactory”/></property>
    <property name=”jdbcExceptionTranslator”><ref bean=”jdbcExceptionTranslator”/></property>
    </bean>

    <bean id=”ProgramDAO” class=”main.ProgramDAO”>
    <property name=”sessionFactory”>
    <ref bean=”hibernateTemplate” />
    </property>
    </bean>

    <bean id=”StudyDAO” class=”main.StudyDAO” factory-method=”getInstance”>
    <property name=”sessionFactory”>
    <ref bean=”hibernateTemplate” />
    </property>
    </bean>

    <!– *********************************************************** –>
    <!– ************* Start of SERVICE DEFINITIONS *********** –>

    <!– Hibernate Transaction Manager Definition –>
    <bean id=”transactionManager” class=”org.springframework.orm.hibernate.HibernateTransactionManager”>
    <property name=”sessionFactory”><ref bean=”sessionFactory”/></property>
    </bean>

    <bean id=”studyServiceTarget” class=”service.StudyService” >
    <property name=”StudyDao”>
    <ref bean=”StudyDAO”></ref></property>
    </bean>

    <!– Transactional proxy Services –>

    <bean id=”studyService” class=”org.springframework.transaction.interceptor.TransactionProxyFactoryBean”>
    <property name=”transactionManager”><ref local=”transactionManager”/></property>
    <property name=”target”><ref local=”studyServiceTarget”/></property>
    <property name=”transactionAttributes”>
    <props>
    <prop key=”get*”>PROPAGATION_REQUIRED,readOnly</prop>
    <prop key=”save*”>PROPAGATION_REQUIRED</prop>
    <prop key=”update*”>PROPAGATION_REQUIRED</prop>
    <prop key=”delete*”>PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>

    </beans>

    #259574 Reply

    Riyad Kalla
    Member

    Do you mean this is a Spring problem not loading your beans? What exactly is the error or the problem that is happening? Are you getting an exception?

    #259646 Reply

    mimi_grebici
    Member

    No I have no exception. but the applicationContext.xml (the file wich configure the pamming files and the DAO classes ) is not executed !!!

    I have added a deliberate error in appilcationContext3.xml file but it did not give any exception about it !!!!!!

    #259674 Reply

    Riyad Kalla
    Member

    Mimi,
    If you are getting no errors and no exceptions, how do you know that your applicationContext file is not getting ready by Spring? I need you to explain what is broken, what is not working. I need more details and less exclamation points.

    #259763 Reply

    mimi_grebici
    Member

    I know that it does not work because the DAO objects and service class are not instanciated and because when I put a deliberate error in the applicationContext.xml file (which must induce an exception ) any exception appeared !!!!

    and at the server start there is no comment about applicationContext.xml execution !!!! I have only these comments :

    INFO: Installation d’une application pour le chemin de contexte /MyEclipseTest depuis l’URL file:C:\Tomcat\jakarta-tomcat-5.0.28\webapps\MyEclipseTest
    4 oct. 2006 12:27:44 org.apache.catalina.core.StandardContext start
    GRAVE: Error listenerStart
    4 oct. 2006 12:27:44 org.apache.catalina.core.StandardContext start
    GRAVE: Context startup failed due to previous errors

    I hope that my explanation is clear !!! I know …I have a bad english !!!!

    #259866 Reply

    Riyad Kalla
    Member

    It looks like a listener is failing to start, which will cause the app to fail to load (as you are seeing), unfortunately looking at your web.xml file, I see *no* listeners… are you sure you posted the right one?

    #259913 Reply

    mimi_grebici
    Member

    yes you are right

    I have rewited all the project ! and the web.xml is :

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <web-app xmlns=”http://java.sun.com/xml/ns/j2ee&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; version=”2.4″ xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”&gt;
    <context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>

    <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>

    <!– Faces Listener, that does all the startup work (configuration, init). –>
    <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>

    </web-app>

    and at server start I have just this comment

    2006-10-05 11:45:42,834 WARN Digester:120 – [ManagedBeanRule]{faces-config/managed-bean} Merge(studyBean)

    and anything about context !!

    I have put a deliberate error in applicationContext file , but there is no exception about it !!!

    I dont know if I must add other listener or not ?

    thanks

    #259917 Reply

    mimi_grebici
    Member

    I have resolved the pb !! thanks for all !!!!!!

    I added lister and filter and the web.xml is

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <web-app xmlns=”http://java.sun.com/xml/ns/j2ee&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; version=”2.4″ xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”&gt;
    <context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>

    <filter>
    <filter-name>sessionFilter</filter-name>
    <filter-class>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    </filter-class>
    </filter>
    <filter-mapping>
    <filter-name>sessionFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>
    <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>

    <!– Faces Listener, that does all the startup work (configuration, init). –>
    <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>

    </web-app>

    #259930 Reply

    Riyad Kalla
    Member

    That is great, I am glad the issue was resolved.

Viewing 9 posts - 1 through 9 (of 9 total)
Reply To: [Closed] contextConfigLocation loading problem

You must be logged in to post in the forum log in