Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Java EE (J2EE) и Spring > проблемы с bean


Автор: Bandit 14.4.2008, 23:51
Доброго дня.
Прошу помоч понять, что я сделал не так.

Ничего не меняя в applicationContext.xml у меня стало вылезать:

Код

javax.servlet.ServletException: BeanUtils.populate
    org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
    org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause 

java.lang.IllegalArgumentException: No bean specified
    org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:751)
    org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:937)
    org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
    org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
    org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
    org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)



Происходит это при нажатии на любую кнопку приложеня!
Ссылки работают как надо! 

applicationContext.xml
Код

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    <bean id="dataSource" 
     class="by.epam.testapp.database.managerDataBase.ManagerDataBase"
     singleton="true" 
     init-method="init">
        <property name="driverClassName">
            <value>oracle.jdbc.driver.OracleDriver</value>
        </property>
        <property name="url">
            <value>jdbc:oracle:thin:@localhost:1521:xe</value>
        </property>
        <property name="username">
         <value>bandit</value>
        </property>
        <property name="password">
         <value>bandit</value>
        </property>
        <property name="maxConn">
         <value>10</value>
        </property>
    </bean>
    
    <bean id="jdbcNewsDAO" class="by.epam.testapp.database.dao.JdbcNewsDAO" 
        singleton="true" 
        init-method="initDAO"> 
        <property name="managerDB">
            <ref local="dataSource"/>
        </property>
    </bean>
    
    <bean name="/news" 
        class="by.epam.testapp.presentation.action.NewsAction" 
        singleton="false"> 
        <property name="newsDAO">    
         <ref bean="jdbcNewsDAO"/>    
        </property> 
    </bean>
    
</beans>


Пример JSP

Код

<script ...>
Код

function add(){
            var retValue = true;
            if(valid() == false){
                alert('<bean:message key="valid.fildsEmpty"/>');
                retValue = false;
            }else{
                var x = document.getElementsByName('method')[0];
                x.value = "saveAdd";
                document.newsForm.submit();
            };
            return retValue;
        }

</script>

<html:form action="/news" method="POST"> <!-- ?method=saveAdd -->
                    <input type="hidden" name="method"  value=""/>
                    <div style="margin-top:40px; margin-left:20px; text-align:left">
                        <table>
                            <tr>
                                    <th style="width: 150px;"><bean:message key="title"/></th>
                                    <th>
                                        <html:text property="newsMessage.titleNews" indexed="newsMassage.titleNews" size="50" maxlength="100"/>
                                    </th>
                            </tr>
                            <tr>
                                    <th style="width: 150px;"><bean:message key="date"/></th>
                                    <th>
                                        <html:text property="newsMessage.dateNews" size="20" maxlength="10"/>
                                    </th>
                            </tr>
                            <tr>
                                    <th style="width: 150px;"><bean:message key="brief"/></th>
                                    <th>
                                        <html:textarea property="newsMessage.brief" cols="50" rows="6"/>
                                    </th>
                            </tr>
                            <tr>
                                    <th style="width: 150px;"><bean:message key="content"/></th>
                                    <th>
                                        <html:textarea property="newsMessage.content" cols="50" rows="10"/>
                                    </th>
                            </tr>
                        </table>
                    </div>
                    <div align="center">
                    <!-- 
                        <html:submit onclick="valid()">
                            <bean:message key="button.AddNews"/>
                        </html:submit>
                        &nbsp;
                        <html:submit onclick="this.form.action='news.do?method=list'">
                            <bean:message key="button.Cancel"/>
                        </html:submit>         
                    -->
                        <button onclick="add()">
                            <bean:message key="button.AddNews"/>
                        </button>
...................................................


Очень прошу о помощи

Автор: Llucas 15.4.2008, 10:26
http://forum.java.sun.com/thread.jspa?threadID=632599&messageID=3950391

Почитай тут, может найдешь...

Автор: Bandit 15.4.2008, 18:40
Llucas, благодарю за совет. Посмотрел, полистал... 
 Узнал, что то новое smile

Проблема оказалась в другом. Моя форма сама себя reset(-а) пока не переопределил reset().
Большое спасибо.


Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)