Ola a todos
Por favor estou tentando usar o DWR(version: 1.0) integrado com o Spring (Spring-Version: 1.2.4) , mas não estou tendo sucesso.
O DWR e o Spring isolados funcionam corretamente, sem nenhum problema, tenho uma aplicação basica de exemplo que esta funcionanando corretamente no spring. O DWR também funciona corretamente, o exemplo da class Date.
Agora quando tento integrar o DWR ao Spring, não funciona, no cliente quando eu faço as chamadas via javascript é mostrado o seguinte erro “Syntax Error”.
por favor se alguem puder me ajudar a resolver eu agradeço
João David
Olá,
cola o seu dwr.xml aqui para podermos ajudar.
Você tem certeza que está usando o creator=“spring” ?
OK
aproveitando segue todos os arquivos de configuração:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 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">
<display-name>ExemploSpring</display-name>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>faculdade</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>faculdade</servlet-name>
<url-pattern>*.serpro</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>filter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/faculdade-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
dwr.xml
Abaixo “javascript” esta escrito com “z” “javazscript”, somente para o forum aceitar o post.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE dwr PUBLIC
"-//GetAhead Limited//DTD Direct Web Remoting 1.0//EN"
"http://www.getahead.ltd.uk/dwr/dwr10.dtd">
<dwr>
<allow>
<convert converter="bean" match="br.gov.serpro.modelo.pojo.Aluno"/>
<create creator="spring" javazcript="teste">
<param name="beanName" value="alunoServicoImpl" />
</create>
</allow>
</dwr>
faculdade-servlet.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="simpleUrlHandlerMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/alunoListagem.serpro">alunoListagem</prop>
<prop key="/alunoListagemPorCurso.serpro*">alunoListagem</prop>
<prop key="/alunoFormulario.serpro*">alunoFormulario</prop>
<prop key="/cursoListagem.serpro">cursoListagem</prop>
<prop key="/cursoFormulario.serpro*">cursoFormulario</prop>
</props>
</property>
</bean>
<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
<property name="prefix">
<value>/WEB-INF/visao/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<!-- ########## i18n ########## -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename">
<value>/msg/mensagens</value>
</property>
</bean>
<!-- ########## CONTROLE - ALUNO ########## -->
<bean id="alunoFormulario" class="br.gov.serpro.controle.aluno.AlunoFormulario">
<property name="alunoServico">
<ref bean="alunoServicoImpl" />
</property>
<property name="cursoServico">
<ref bean="cursoServicoImpl" />
</property>
<property name="validator">
<ref bean="alunoValidacao" />
</property>
<property name="commandName">
<value>aluno</value>
</property>
<property name="commandClass">
<value>br.gov.serpro.modelo.pojo.Aluno</value>
</property>
<property name="sessionForm">
<value>true</value>
</property>
<property name="formView">
<value>alunoFormulario</value>
</property>
<property name="successView">
<value>redirect:alunoListagem.serpro</value>
</property>
</bean>
<bean id="alunoValidacao" class="br.gov.serpro.controle.aluno.AlunoValidacao" />
<bean id="alunoListagem" class="br.gov.serpro.controle.aluno.AlunoListagem">
<property name="alunoServico">
<ref bean="alunoServicoImpl" />
</property>
<property name="cursoServico">
<ref bean="cursoServicoImpl" />
</property>
<property name="methodNameResolver">
<ref bean="alunoListagemMethodNameResolver" />
</property>
</bean>
<bean id="alunoListagemMethodNameResolver"
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/alunoListagem.serpro">
handleAlunoListagem
</prop>
<prop key="/alunoListagemPorCurso.serpro*">
handleAlunoListagemPorCurso
</prop>
</props>
</property>
</bean>
<!-- ########## CONTROLE - CURSO ########## -->
<bean id="cursoFormulario" class="br.gov.serpro.controle.curso.CursoFormulario">
<property name="cursoServico">
<ref bean="cursoServicoImpl" />
</property>
<property name="validator">
<ref bean="cursoValidacao" />
</property>
<property name="commandName">
<value>curso</value>
</property>
<property name="commandClass">
<value>br.gov.serpro.modelo.pojo.Curso</value>
</property>
<property name="sessionForm">
<value>true</value>
</property>
<property name="formView">
<value>cursoFormulario</value>
</property>
<property name="successView">
<value>redirect:cursoListagem.serpro</value>
</property>
</bean>
<bean id="cursoValidacao" class="br.gov.serpro.controle.curso.CursoValidacao" />
<bean id="cursoListagem" class="br.gov.serpro.controle.curso.CursoListagem">
<property name="cursoServico">
<ref bean="cursoServicoImpl" />
</property>
<property name="methodNameResolver">
<ref bean="cursoListagemMethodNameResolver" />
</property>
</bean>
<bean id="cursoListagemMethodNameResolver"
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/cursoListagem.serpro">
handleCursoListagem
</prop>
</props>
</property>
</bean>
<!-- ########## MODELO - SERVICO ########## -->
<bean id="cursoServicoImpl"
class="br.gov.serpro.modelo.servico.CursoServicoImpl">
<property name="cursoDao">
<ref bean="cursoDaoHibernate" />
</property>
</bean>
<bean id="alunoServicoImpl"
class="br.gov.serpro.modelo.servico.AlunoServicoImpl">
<property name="alunoDao">
<ref bean="alunoDaoHibernate" />
</property>
</bean>
<!--########## MODELO - DAO ########## -->
<bean id="alunoDaoHibernate" class="br.gov.serpro.modelo.dao.AlunoDaoHibernate">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="cursoDaoHibernate" class="br.gov.serpro.modelo.dao.CursoDaoHibernate">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
</props>
</property>
<property name="mappingLocations">
<list>
<value>/WEB-INF/hbm/Aluno.hbm.xml</value>
<value>/WEB-INF/hbm/Curso.hbm.xml</value>
</list>
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost/faculdade?autoReconnect=true" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
</beans>