...
Use this recipe to build a skeleton web application named M2Rice which has the Rice KEW and Rice KSB Services embedded in it. This recipe uses the Maven to build the project.
Development Environment
Operating System | Windows XP |
JDK | 1.5.0_12 |
Maven | 2.0.9 |
M2_HOME | C:\apache-maven-2.0.9 |
M2_OPTS | -Xms256m -Xmx512m |
M2_REPO | C:\JavaLib\mvnrepository |
Application Server | localhost |
Application Container | Tomcat 5.5.23 |
CATALINA_HOME | C:\Tomcat 5.5 |
IDE | Eclipse Ganymede 3.4.0 |
Workspace | C:\Development\KualiRice.workspace |
Rice Source Directory | C:\Development\KualiRice.workspace\KualiRice0.9.3 |
Build Sheet
- Create Maven
...
2.0.9
...
M2_HOME
...
C:\apache-maven-2.0.9
...
M2_OPTS
...
-Xms256m -Xmx512m
...
M2_REPO
...
C:\JavaLib\mvnrepository
Build Sheet
- Create Maven Project
Start Eclipse
Go to File -> New -> Project -> Maven Project
Check the Use default Workspace location box and click Next
Select Internal as the catalog
From the list of archetypes, select the maven-archetype-webapp Arctifact Id and click Next
For Group Id, enter edu.ucdavis.iet
For Artifact Id, enter M2Rice
Click Finish
Embed the Kuali Service Bus and Kuali Enterprise Workflow Identify Rice dependencies
Add the following to your pom.xmlCode Block <repository> <id>kuali</id> <name>Kuali Repository</name> Projecttitle pom.xml
Open a command prompt
Navigate to C:\Development\KualiRice.workspace
Create a web application project using the maven-archetype-webapp archetype (aka project template)
This creates a directory named M2Rice (after the artifactId) in C:\Development\KualiRice.workspaceCode Block C:\Development\KualiRice.workspace\M2Rice> mvn archetype:create -DgroupId=edu.ucdavis.iet -DartifactId=M2Rice -DarchetypeArtifactId=maven-archetype-webapp
- Add Kuali dependencies
In Windows Explorer, navigate to C:\Development\KualiRice.workspace\M2Rice and find pom.xml
Add the following code to pom.xml:
<dependency>Code Block title /M2Rice/pom.xml <dependencies> ... <dependency> <groupId>org.kuali.rice</groupId> <artifactId>rice-ksb</artifactId> <version>0.9.3</version> </dependency> </dependencies> <repositories> <repository> <id>kuali</id> <name>Kuali Repository</name> <url>https://test.kuali.org/maven/</url> </repository>
<groupId>org.kuali.rice</groupId> <artifactId>rice-ksb</artifactId> <version>0.9.3</version>
dependency></
repositories>
- Configure KSB the Kuali Service Bus Dispatcher Servlet
Navigate to \M2Rice\src\main\webapp\WEB-INF and find web.xml
Add the following code to web.xmlCode Block title /M2Rice/src/main/webapp/WEB-INF/web.xml <web-app> <display-name>M2Rice</display-name> <servlet> <servlet-name>remoting</servlet-name> <servlet-class>edu.iu.uis.eden.messaging.servlet.KSBDispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>remoting</servlet-name> <url-pattern>/remoting/*</url-pattern> </servlet-mapping> </web-app>
- Create Rice runtime configuration file
In the project structure, right-click on src/main/webapp/WEB-INF, then New -> File
Name the file Runtime Configuration File
In \M2Rice\src\main\resources, create a new file called M2Rice-config.xml
webapp/WEB-INFCode Block title /M2Rice/src/main/
>/usr/local/rice/riceresources/M2Rice-config.xml <config> <!-- Core --> <param name="application.url">http://localhost:8080/M2Rice</param> <!-- Database --> <param name="datasource.url">jdbc:mysql://localhost:3306/kricedev</param> <param name="datasource.username">KRICEDEV</param> <param name="datasource.password">*** password ***</param> <param name="datasource.ojb.platform">MySQL</param> <param name="datasource.platform">org.kuali.rice.database.platform.MySQLPlatform</param> <param name="datasource.driver.name">com.mysql.jdbc.Driver</param> <param name="datasource.pool.validationQuery">select 1 from dual</param> <param name="datasource.pool.maxWait">30000</param> <param name="datasource.pool.minSize">2</param> <param name="datasource.pool.maxSize">5</param> <!-- KSB --> <param name="serviceServletUrl">${application.url}/remoting/</param> <param name="keystore.file"
Configure Spring Beans>classpath:rice.keystore</param> <param name="keystore.alias">*** key alias ***</param> <param name="keystore.password">*** password ***</param> <!-- KEW --> <param name="workflow.url">${application.url}/en</param> <param name="client.protocol">embedded</param> <param name="plugin.dir">/usr/local/rice/plugins</param> <param name="attachment.dir.location">/usr/local/rice/kew_attachments</param> </config>
- Generate an Eclipse Project
At the command prompt, navigate to C:\Development\KualiRice.workspace\M2Rice
Generate the Eclipse project:Code Block C:\Development\KualiRice.workspace\M2Rice> mvn eclipse:eclipse
- Import M2Rice as an Eclipse project
Start Eclipse
Select C:\Development\KualiRice.workspace as your workspace
Go to File -> Import -> Existing projects into Workspace
Select C:\Development\KualiRice.workspace\M2Rice as the root directory and click Finish
- Embed the Kuali Service Bus and Kuali Enterprise Workflow
In the project structure, right-click on src/main/resources, then New -> File
Name the file M2Rice-RiceSpringBeans.xml
Configure the Spring Beans as follows:
WEB-INF/Code Block title /M2Rice/src/main/resources/M2Rice-RiceSpringBeans.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="config" class="org.kuali.rice.config.spring.ConfigFactoryBean"> <property name="configLocations"> <list> <value>classpath:
M2Rice-config.xml</value> </list> </property> </bean> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="properties" ref="configProperties" /> </bean> <bean id="configProperties" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"> <property name="targetObject" ref="config" /> <property name="targetMethod" value="getProperties" /> </bean> <bean id="rice" class="org.kuali.rice.config.RiceConfigurer"> <property name="dataSource" ref="riceDataSource" /> <property name="transactionManager" ref="jotm" /> <property name="userTransaction" ref="jotm" /> <property name="properties"> <props> <prop key="message.entity">M2Rice</prop> <prop key="message.persistence">true</prop> <prop key="message.delivery">asynchronous</prop> <prop key="Routing.ImmediateExceptionRouting">false</prop> <prop key="RouteQueue.timeIncrement">1000</prop> <prop key="RouteQueue.maxRetryAttempts">3</prop> <prop key="useQuartzDatabase">true</prop> <prop key="ksb.org.quartz.scheduler.instanceId">AUTO</prop> <prop key="ksb.org.quartz.scheduler.instanceName">KSBScheduler</prop> <prop key="ksb.org.quartz.jobStore.isClustered">true</prop> <prop key="ksb.org.quartz.jobStore.tablePrefix">KR_QRTZ_</prop> </props> </property> <property name="modules"> <list> <bean class="edu.iu.uis.eden.messaging.config.KSBConfigurer"> <property name="serviceServletUrl" value="${serviceServletUrl}" /> </bean> <bean class="org.kuali.workflow.config.KEWConfigurer"> <property name="dataSource" ref="riceDataSource"/> </bean> </list> </property> </bean> <bean id="ksbConfigurer" class="edu.iu.uis.eden.config.spring.KSBSpringConfigurer"> <property name="clientProtocol" value="embedded" /> <property name="messageEntity" value="M2Rice" /> <property name="dataSource" ref="riceDataSource" /> <property name="transactionManager"> <ref bean="jotm" /> </property> <property name="userTransaction"> <ref bean="jotm" /> </property> </bean> <bean id="riceDataSource" class="org.kuali.rice.database.XAPoolDataSource"> <property name="transactionManager" ref="jotm" /> <property name="driverClassName" value="${datasource.driver.name}" /> <property name="url" value="${datasource.url}" /> <property name="maxSize" value="${datasource.pool.maxSize}" /> <property name="minSize" value="${datasource.pool.minSize}" /> <property name="maxWait" value="${datasource.pool.maxWait}" /> <property name="validationQuery" value="${datasource.pool.validationQuery}" /> <property name="username" value="${datasource.username}" /> <property name="password" value="${datasource.password}" /> </bean> <bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean" /> </beans>
- Build WAR File
Back at the command prompt, navigate to C:\Development\KualiRice.workspace\M2Rice
Generate the WAR file:Code Block C:\Development\KualiRice.workspace\M2Rice> mvn package
- Deploy M2Rice Application
Copy \M2Rice\target\M2Rice.war to %CATALINA_HOME%\webapps
Start Tomcat
Open the URL: http://localhost:8080/M2Rice/index.jsp
Reference
Building Web Applications with Maven 2: http://today.java.net/pub/a/today/2007/03/01/building-web-applications-with-maven-2.html
Rice XML Configuration Subsystem: https://test.kuali.org/confluence/display/KULRICE/Rice+XML+Configuration+Subsystem
Advanced Configuration: https://test.kuali.org/confluence/display/KULRICE/Advanced+Installation+and+Configuration
KSB Module Configuration: https://test.kuali.org/confluence/display/KULRICE/KSB+Module+Configuration
Configuring your application to use KSB: https://test.kuali.org/confluence/display/KULRICE/Configuring+your+application+to+use+KSB
KEW Module Configuration: https://test.kuali.org/confluence/display/KULRICE/KEW+Module+Configuration#KEWModuleConfiguration-Embedded