Monday, March 12, 2007

DWR-2.0.rc2 + Spring 2.0 integration

Steps to integrate DWR with Spring 2.0 using new Name Spaces that were introduced. The integration currently works with Spring 2.0 and DWR-2.0RC-2 versions only. This does not work with Spring 2.0.1 or 2.0.2 or 2.0.3 and DWR-2.0RC-2, in order to work with spring 2.0+ versions you need get the current version of DWR-2.0RC-2 from HEAD of the CVS.

Step 1: Download 2.0 version of Spring form http://www.springframework.org/
Step 2: Download DWR version 2.0-rc2 from http://getahead.org/dwr/download

Copy spring and dwr jar files to the webapplication classpath.

Step 3: Add the below lines into web.xml

<servlet>

<servlet-name>dwr-spring</servlet-name>

<servlet-class>

org.springframework.web.servlet.DispatcherServlet

</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>dwr-spring</servlet-name>

<url-pattern>*.do</url-pattern>

</servlet-mapping>

<servlet-mapping>

<servlet-name>dwr-spring</servlet-name>

<url-pattern>/dwr/*</url-pattern>

</servlet-mapping>

<welcome-file-list>

<!-- index page -->

<welcome-file>index.jsp</welcome-file>

<welcome-file>index.html</welcome-file>

</welcome-file-list>


Step 4: Create the default Spring MVC context file dwr-spring-servlet.xml under WEB-INF directory of the webapplication and configure the DWR

<?xml version="1.0"
encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-2.0.xsd

http://www.directwebremoting.org/schema/spring-dwr

http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">


<!-- DWR CONFIGURATION -->

<dwr:configuration>

<dwr:create
javascript="JDate" type="new"

class="java.util.Date" />
</dwr:configuration>




<dwr:controller id="dwrController" debug="true" />

<bean id="dwrHandlerMappings"

class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">

<property name="alwaysUseFullPath"
value="true" />

<property
name="mappings">

<props>

<prop key="/dwr/**/*">dwrController</prop>

</props>

</property>

</bean>

<!-- END OF DWR CONFIGURATION -->

</beans>

Step 5: Deploy the application in Tomcat 5.5 and point the browser to http://localhost:8080/dwr-spring/dwr/index.html

If the integartion is sucessfull it should display the page with JDate link on the page.

Blow links provides more information on how to integrate DWR and Srping

http://bram.jteam.nl/index.php/2007/01/

Saturday, January 6, 2007

Tomcat 5.5 with JDK 1.4

To setup tomcat 5.5 or grater version on JDK 1.4 you need to download JDK 1.4 Compatability Package along with windows installer form http://tomcat.apache.org/. When installing the tomcat 5.5 it will by default look for JDK 5 ver, but it will still install the tomcat but when you run the tomcat it will display a message "This release of Apache Tomcat was packaged to run on J2SE 5.0 or later". To make it run under jdk 1.4 unzip the JDK 1.4 Compatability Package and copy the .jar file bin directory to the TOMCAT_HOME\bin directory and copy the .jar files under the common\endorsed to the TOMCAT_HOME\common directory. Now you should be able to run the tomcat by type in the http://localhost:8080/ in your favorite browser.

Tomcat 5.5 with JDK 1.4

To setup tomcat 5.5 or grater version on JDK 1.4 you need to download JDK 1.4 Compatability Package along with windows installer form http://tomcat.apache.org/. When installing the tomcat 5.5 it will by default look for JDK 5 ver, but it will still install the tomcat but when you run the tomcat it will display a message "This release of Apache Tomcat was packaged to run on J2SE 5.0 or later". To make it run under jdk 1.4 unzip the JDK 1.4 Compatability Package and copy the .jar file bin directory to the TOMCAT_HOME\bin directory and copy the .jar files under the common\endorsed to the TOMCAT_HOME\common directory. Now you should be able to run the tomcat by type in the http://localhost:8080/ in your favorite browser.

PF