Walkthrough the spring source code - eclipse

I wanted to walkthrough the spring code. For that I cloned the code and built it using ./import-into-eclipse.sh command. There are some instructions given in README.md file for checking out source in eclipse.
After following above instructions I was able to see the spring code in my eclipse workspace. To refer the spring source from my project I added all of spring projects (like spring-beans, spring-aop etc) in my project's Java build path. I was able to use spring code in my project.
Now the issue is that whenever I run the test cases in my project, I get initialization error. I removed spring projects from my java build path and junit test started working.
I tried to dig into the issue. For that I tried to run some of the test cases of spring projects itself like BeanUtilsTests.
but I got:
Class not found org.springframework.beans.BeanUtilsTests
java.lang.ClassNotFoundException: org.springframework.beans.BeanUtilsTests
I verified that classpath is set:
Don't know what is the issue. Can someone please tell me that what I did wrong.
Is there any better way to view/edit spring code?

Usually the below error,
Class not found org.springframework.beans.BeanUtilsTests
java.lang.ClassNotFoundException: org.springframework.beans.BeanUtilsTests
occurs when the corresponding jar is missing in the classpath. Since you have already added the spring-beans jar manually, I suspect you are using an incompatible version of the spring-beans jar with your spring-boot.
You can check the Maven repo Spring Beans to check the compatible version. But I would suggest using a dependency management tool like Gradle or Maven to include the required dependency jars. Spring-Boot Gradle file

Related

Spring JAR files not present in new Eclipse Spring project

I installed Spring in Eclipse/EE simply from the Eclipse Marketplace.
However, either the Spring jar files aren't there, or am missing something within the project setup.
I looked to find them in the project library thru "Build path". I even tried searching the .jar files within the Windows directories.
I know I'm missing something big-- please bear with me.
Took me hours.
Note: I saw stackoverflow.com/questions/6288563/adding-external-jar-file-in-eclipse/11004869.
Update: found the jars in an earlier release-- 3.05. OK now i think.
Of course they are not there. There is not reason for them to be in eclipse. Select File > New > Spring Template project. This will create new maven project with spring dependencies included

source is missing when debugging maven build configuration

I have a maven build run configuration which I use to start tomcat server. Barely this is tomcat:run command which is executed by m2eclipse plugin.
That was all fine until I needed to jump into spring source code. I can not set source code lookup for debugger!!! All jars have their source code location setup, so I can open spring classes by Ctrl+click. But debugger seems does not understand this settings, I tried to add project to source code lookup, but that worked only for code that is in that project and not in its dependencies.
Try Igor's source lookup feature, it will help you get jar sources automatically during external process execution (maven plugin invocation, in your case).

Hibernate Setup in eclipse helios

How I can setup Hibernate for a Dynamic Web application by using Eclipse Helios? I am a newbe so please let me know if there is any example.
I tried for Java application and included all JARS and it worked fine. But don't understand how I can do it for Web application and test it.
I will use Struts2 so I will appreciate if I can get appropriate example or guidance.
Drop the jars in WEB-INF/lib. Those jars are automatically added by Eclipse to the project build path, and constitute (with the WEB-INF/classes directory and the container classpath) the classpath of the webapp.
http://hardik4u.wordpress.com/2008/09/02/struts-2-hibernate-3-integrationcomplete-using-eclipse/
https://stackoverflow.com/questions/4364923/struts2-and-hibernate-framework-create-in-eclipse
First, download Struts2, and import example WAR file into Eclipse. You can find it from the source folder: struts-2.3.1-all\struts-2.3.1\apps\struts2-blank.war
Second, you should install Eclipse Hibernate Plugin. Goto Window > Preferences > Install/Update > Available Software Sites and add following link and name it JBossTools or something.
http://download.jboss.org/jbosstools/updates/helios/
Depending on your needs you can install Hibernate Plugins for many project types. In this case, select web application plugin.
And after, you should include Hibernate Core libraries into your classpath. I would recomment Hibernate 3.6 and greater. Because it does not depend on asm (asm-3.3.jar, asm-commons-3.3.jar ...) anymore. If you use earlier versions you might encounter some problems, since Struts2 also depend on asm libraries.
Then create your database, and use following link to configure and generate model bean classes.
http://casteyo.wordpress.com/2007/06/06/conf_hibernate/
Now you don't need to write mapping files by yourselves. And with DAO factory pattern you have your way to finish your project.
Hope this helps, and Goodluck

What should I do in order to be able to work with maven + eclipse + wicket + hibernate + spring in Mac OS?

I want to create a web app that will use wicket, hibernate and spring frameworks. My IDE of choice is Eclipse, I am using maven for the .war generation and I am running Mac OS. What steps should I follow to correctly install and configure all the tools so as to have a project running that relies on these 3 frameworks. I was able to successfully set up wicket but I am having trouble for setting up hibernate and spring. I went through multiple tutorials but I still couldn't find the solution.
Thanks!
I will now try to explain a bit what is the problem I can't solve. I first began with a clean project:
mvn archetype:create -DgroupId=test.framework -DartifactId=microForum
Moved on to the project folder and mvn eclipse:eclipse
Imported the project from eclipse
Looked into the apache wicket homepage where there are multiple examples, so I read through the page and that was enough to learn what to add to the pom and had wicket and everything up and running nicely
My next step was trying to use hibernate and/or spring. I thought that "adding" hibernate and spring in the same way I added the wicket necessary configurations and dependencies to the pom (by hand) might not be that easy. So I tried using the maven archetype: appfuse-basic-spring. So:
mvn archetype:generate -> launchs the wizard that lets you choose among different archetypes
After choosing the archetype number 2 ( Hibernate + Spring + Spring MVC) it fails
After googling a bit I found out why it fails (something like I should add a -archetype after appfuse-basic-spring. So, instead of using the wizard, I put:
mvn archetype:generate -B -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-spring*-archetype* -DarchetypeVersion=2.1.0-M1 -DgroupId=test.framework -DartifactId=microForum2
This created my project (after multiple warnings). I paste a screenshot (Image 1) because some of the information might have some important meaning :
http://img97.imageshack.us/img97/6687/screenshot20100323at112.png
- Image 1
I then did mvn eclipse:eclipse and it started downloading millions of things, which seemed very odd so I Control+C it.
Following schmimd04 answer I tried to use the eclipse maven plugin but I couldn't create a maven project:
Unable to create project from archetype [org.appfuse.archetypes:appfuse-basic-spring:RELEASE]
The defined artifact is not an archetype
Thanks!
p.d: My Mac OS already had maven installed (version 2.2.0), I tried downloading the last one and repeating the same steps but I still had the same trouble.
Bert's recommendation LegUp, jweekend.com/dev/LegUp, have worked just fine for me. I used the wicket + Spring + JPA archetype. I will still look for the reason why maven's Hibernate+Spring+Spring MVC archetype didn't work for me. I'll edit this once I have the answer. For the time being, legup did the job!
Thanks
Install the Maven plugin for Eclipse from the update site: http://m2eclipse.sonatype.org/update.
This will allow you to create Maven projects (I would start with the quickstart archetype) and easily add dependencies, such as Hibernate, Spring, and Wicket.
As Pascal is saying, your question is to broad to answer. A few pointers that might help you:
use 'mvn eclipse:eclipse' to generate an Eclipse project out of your pom.xml. There might even be a working eclipse project that allows to open a pom.xml as eclipse project. I can't say, i left eclipse behind for good.
spring is 'just' a library that need to be in your classpath. the above command will ensure it is there (if it is defind as dependency in the pom.xml) You need to define a applicationContext.xml for Spring that resides in your classpath. See the Spring documentation for that.
hiberate is similar, it is just a library that needs to be in the classpath and that needs to find a config file. in there, the connection to the database is described. See the hibarnate docu (or one of the many blogs out there) for more info.
If you are stuck with a particular problem, please describe it so people can help here.
Bert
I don't know if it sounds odd. But it is because you have archtype data in your .metadata for respective workspace. If you delete the workspace. You can create new archtype. I know deleting worksapce is not a good idea. But still it works.

How do I tell JBehave META-INF to configure it for JPA using the Maven plugin?

I'm trying to get JBehave, JPA and Maven to play nicely together. I can run the test via eclipse and everything works just fine. I run it via maven, and JPA can't find the persistence.xml file. However a unit test I have finds the persistence.xml file just fine, but JBehave is not involved.
Clearly I need to tell JBehave to look in src/main/resources for the META-INF/persistence.xml file, or get it on the classpath at least. Is there a way to do that?
org.jbehave
jbehave-maven-plugin
2.3-rc1
run-scenarios-found
test
test
test/nsfw/bmp/partymodel/PartySearch.java
test/nsfw/bmp/partymodel/RealtionshihpFunctionality.java
run-scenarios
I checked out quickly the jbehave-maven-plugin sources and it may be classloader issue. But without more details (e.g. the plugin version you use, the phase you run, the pom.xml), the only suggestion I can do is to open an issue here: http://jira.codehaus.org/browse/JBEHAVE/component/12482.