The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

wnorman (7) [Avatar] Offline
#1
Development Environment
Fedora 16 x86_64
STS -- SpringSource Tool Suite Version: 2.8.1.RELEASE -use a clean workspace
Apache Tomcat version 7

Setting up IDE:

1. Add STS Gradle extension from the STS Dashboard Extension tab.
2.File>import>Gradle>GradleProject
-set path to Spittle project directory
-click Build Model (This may take a while ...)
-select spitter-web project and click Select Required (may take a while to load projects and dependencies)
-you should see a set of project modules in the STS(Eclipse) Project Explorer. These should be:
spitter-domain-jpa, spitter-jmx, spitter-persistence-common, spitter-persistance-jpa, spitter-service-annotation, spitter-service-common and spitter-web

3.right click on spitter-web project in the Project Explorer and select Run As...GradleBuild...
-in Edit Configuration Launch select :clean, build and war
-ensure the order is :spitter-web:clean, :spitter-web:build, :spitter-web:war
-click Run This should run a build of the project and produce a .war file that can be deployed to Apache Tomcat.
(the .war can be found in the spitter-web/build/lib folder from the STS Navigator)


There appears to be a few problems with the code that will prevent a successful build/deployment. The following modifications should get the project built and deployed:

Issues with code errors and deployment:

1.spitter-web project

a) in file ../WEB-INF/urlrewrite.xml

replace the !DOCTYPE tag with:

<!DOCTYPE urlrewrite >
PUBLIC "-//www.tuckey.org//DTD UrlRewrite 3.0//EN"
"http://www.tuckey.org/res/dtds/urlrewrite3.0.dtd">

--adding www. removes a page error

b) Right click on spitter-web project, select Properties>Deployment Assembly
-Add... Folder "/src/main/webapp", Deploy Path is /

c) create a new src/main/resource/index.jsp

a) add the following code to the new file:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%-- Redirected because we can't set the welcome page to a virtual URL. --%> <br /> <c:redirect url="/home.htm"/> <br /> <br /> b) edit the WEB-INF/web.xml file by adding the tags: <br /> <welcome-file-list> <br /> <welcome-file>index.jsp</welcome-file> <br /> </welcome-file-list> <br /> <br /> 2.spitter-jmx project <br /> <br /> a) edit file src/main/resources/annotation-driven-mbean-context.xml <br /> -comment out the following code ... <br /> <br /> <!--<start id="connectorServerFB_RMI"/> <br /> <bean class="org.springframework.jmx.support.ConnectorServerFactoryBean" <br /> p:serviceUrl= <br /> "service:jmx:rmi://localhost/jndi/rmi://localhost:1099/spitter" /> <br /> <end id="connectorServerFB_RMI"/>--> <br /> <!--<start id="rmiRegistryFB"/> <br /> <bean class="org.springframework.remoting.rmi.RmiRegistryFactoryBean" <br /> p:port="1099" /> <br /> <end id="rmiRegistryFB"/>--> <br /> <!--<start id="rmiRegistryFB"/> <br /> <bean class="org.springframework.remoting.rmi.RmiRegistryFactoryBean" <br /> p:port="1099" /> <br /> <end id="rmiRegistryFB"/>--> <br /> <br /> -and replace with the code below. This adds depends-on, which is needed to wait for rmiregistry start <br /> <bean class="org.springframework.jmx.support.ConnectorServerFactoryBean" depends-on="rmiRegistry"> <br /> <property name="serviceUrl" <br /> value="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/spitter" /> <br /> </bean> <br /> <br /> <bean id="rmiRegistry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"> <br /> <property name="port" value="1099" /> <br /> <property name="alwaysCreate" value="true"/></bean> <br /> <br /> 3. Tag Libraries <br /> <br /> a) Web Server jstl libraries <br /> a) download jstl-impl-1.2.jar and jstl-api-1.2.jar <br /> b) add these .jar(s) to $CATALINA_HOME/lib folder --this is the Tomcat lib folder (e.g. /usr/local/apache-tomcat-7.0.14/lib) <br /> <br /> b) change http://www.springframework.org/schema/beans/spring-beans-2.0.xsd to http://www.springframework.org/schema/beans/spring-beans-3.0.xsd in various .xml definition files where a suitable error condition arises <br /> <br /> <br /> To get the project to run/debug from the STS IDE do the following: <br /> <br /> 1. add Apache Tomcat as a project Server and Runtime <br /> <br /> 2. right click spitter-web project, select Poperties <br /> a) select Java Compiler and ensure 1.6 (or 1.7) Compiler compliance Level:, click Apply <br /> b) select Project Facets, select Dynamic Web Module 3.0 <br /> -select Apache Tomcat v7.0 as the designated Runtime <br /> c) select Java Build Path>Projects <br /> -ensure all sub-projects have been added to the build path <br /> <br /> 3. right click spitter-persistence-jpa project, select Properties <br /> a) select Deployment Assembly, Add... Java Build Path Entries, Gradle Dependencies (this is important because it adds necessary libraries to the class path) <br /> b) select the Order and Export tab and ensure that Gradle Dependencies is checked <br /> <br /> 4. right click on spitter-web project and select Run As>Run on Server <br /> a) select the Apache server <br /> <br /> <br /> -have fun!
bbaron (61) [Avatar] Offline
#2
Re: setting up Spitter Application
Wow, that's a lot of steps to get a sample app to work. Kudos for having the patience to work all that out and thanks a million for sharing!!
rubiirube (1) [Avatar] Offline
#3
Re: setting up Spitter Application
hey .. i am new to spring, i bought the book some days ago to get started

as i want to get the spitter-web started .. i am facing alot of problems

its such a pain .. that after 1 day of trials i am at a point of giving up..

its pretty sad that there is not any help regarding this ..

Message was edited by:
rubiirube
damon-pin (1) [Avatar] Offline
#4
Re: setting up Spitter Application
Setup
Ubuntu 11.04
jdk 1.6
apache 7
gradle 1.2

Didn't run from spring sts, just download and installed gradle 1.2 from gradle web site, then greeted with apache 500 server error after initial gradle build.

I followed wnorman's instruction and amend the xml files. run gradle build again, then copy the war to webapps, start the app, viola, everything works.

Thanks a lot to wnorman for taking the time to write up the instruction.
deshraj.kiran (9) [Avatar] Offline
#5
Re: setting up Spitter Application
I do not see any "Deployment Assembly" when I try b) Right click on spitter-web project, select Properties>Deployment Assembly from the instructions given above after selecting "Properties".

Message was edited by:
skipper
pavitx (5) [Avatar] Offline
#6
Re: setting up Spitter Application
You were lucky. What I did was to build with Gradle (1.4 in my case). I then deployed the war in Tomcat. It complained about the duplicate servlet-api jar. So I removed it from the war and re-deployed.
This time I only had the warning
SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
But the war is not deployed and hitting http://localhost:8080/Spitter gives a Not Found 404 error.
naresh.chaurasia (1) [Avatar] Offline
#7
Re: setting up Spitter Application
I followed the steps given by wnorman and build the application using gradle.

javax annotation problem : jdk5 replaced with jdk6

INFO: validateJarFile(D:TranscendingCodeapache-tomcat-7.0.39webappsspitter-web-1.0.0.SNAPSHOTWEB-INFlibservlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Fixsmilieelete the jar, since tomcat has its own jar.

SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details. Fix:delete slf4j-nop-1.5.8.jar and put slf4j-simple-1.6.2.jar in the lib folder after deploying the war file
samr251 (2) [Avatar] Offline
#8
Re: setting up Spitter Application
Thanks a lot wnorman, I have done as you described on your post and did not get any errors only get warning
Could you guide me which steps not properly done or missing something?

Regards,
Sam

Logs
**********************************************************
Description Resource Path Location Type
The value of the field SpittleControllerTest.controller is not used SpittleControllerTest.java /spitter-web/src/test/java/com/habuma/spitter/mvc line 7 Java Problem


Description Resource Path Location Type
Classpath entry org.springsource.ide.eclipse.gradle.classpathcontainer will not be exported or published. Runtime ClassNotFoundExceptions may result. spitter-web P/spitter-web Classpath Dependency Validator Message
Classpath entry /spitter-persistence-jpa will not be exported or published. Runtime ClassNotFoundExceptions may result. spitter-web P/spitter-web Classpath Dependency Validator Message



Description Resource Path Location Type
No grammar constraints (DTD or XML Schema) referenced in the document. TEST-com.habuma.spitter.mvc.FowardingControllerTest.xml /spitter-web/build/test-results line 1 XML Problem
No grammar constraints (DTD or XML Schema) referenced in the document. TEST-com.habuma.spitter.mvc.SpittleBackingBeanInterceptorTest.xml /spitter-web/build/test-results line 1 XML Problem
No grammar constraints (DTD or XML Schema) referenced in the document. TEST-com.habuma.spitter.mvc.SpitterControllerTest.xml /spitter-web/build/test-results line 1 XML Problem
No grammar constraints (DTD or XML Schema) referenced in the document. TEST-com.habuma.spitter.mvc.SpittleControllerTest.xml /spitter-web/build/test-results line 1 XML Problem
No grammar constraints (DTD or XML Schema) referenced in the document. TEST-com.habuma.spitter.mvc.HomeControllerTest.xml /spitter-web/build/test-results line 1 XML Problem
JohnF (2) [Avatar] Offline
#9
Re: setting up Spitter Application
Has anybody ever run into this little caveat. When deploying the spitter-web to my tomcat server defined in the Spring Tool Suite I get this:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean] for bean with name 'emf' defined in class path resource [persistence-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean

I took a look at the WEB-INF/lib directory under the wtpwebapps (that's where the spitter-web gets deployed when using the tomcat in the STS) and I see that the spring-orm is missing. For kicks I copied the spring-orm jar file to that directory but still get the same problem.

When I take the war file from the spring-web gradle build and put it in the regular tomcat webapps directory and start that server I see the spring-orm file deployed in the lib library.

Any ideas on why it gets deployed by the war but now when I deploy it to the STS tomcat server?

Here's the definition of the emf in the peristence-context (I didn't change anything)

<!--<start id="bean_jpa_emf"/>-->
<bean id="emf" class= <br /> "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
</bean>
<!--<end id="bean_jpa_emf"/>-->
zhuguowei (1) [Avatar] Offline
#10
Re: setting up Spitter Application
Thank Goodness! Finally I successfully imported these projects within Spiiter directory into eclipse(luna). And below is my operation methods.

First download gradle.I used gradle 2.1.
Second cd into Spiiter directory, execute gradle eclipse, naturally, there are many error(in build.gradle). Easy , if it hints some line has a error, just comment this line. For example:
//abbreviation = 'SOCIAL'
but as jar version, like this : //springVersion = '3.0.5.RELEASE'
except comment, also need replace rest lines has $springVersion or ${springVersion} with 3.0.5.RELEASE.
After doing these, finally can successsfully execute gradle eclipse.
If so , there are output like this :
BUILD SUCCESSFUL

Total time: 49 mins 32.755 secs

Then in eclipse, just import existing java projects, but remember to check Serach for nested projects, when you select the root directory of Spiiter.

If you think, God! This time it should be no problem left. I have to say, you are too naive.
Some projects still have some problem. You can see many Red exclamation mark aside project name.
Fortunately, this can resolve easily. Just find its .classpth file, comment or delete those duplicate part. For example:
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
<!-- <br /> <classpathentry kind="src" path="src/main/java"/> <br /> <classpathentry kind="src" path="src/main/resources"/> <br /> -->

Now! Everything is OK!