views:

20

answers:

1

Hi,

I've started a very basic Eclipse (Helios) RCP application with the "Hello RCP" template.

I enabled Maven dependency management and added Spring 3 to the POM.

After that I created a view and added the following code to my view.

@Override
public void createPartControl(Composite parent) {
 RestTemplate restTemplate = new RestTemplate();
    String result = restTemplate.getForObject("http://www.example.com:8080/rest/{page}/{id}" , String.class, "mypage", "someid");
 Text text = new Text(parent, SWT.BORDER);
 text.setText(result);
}

When I run the application, I get the following exception,

java.lang.ClassNotFoundException: org.springframework.web.client.RestTemplate
...

I can post the rest if need be.

I'm wondering how I can add the maven dependencies to my classpath or if something else may be the problem?

Thanks

A: 

Are you running your program from Maven ? If you do this, then the classpath should automatically be correct.

Briefly:

$ mvn exec:java -Dexec.mainClass="com.whatever.Main"

See this link for more details.

Brian Agnew
I've been opening the plugin.xml and running the program with "Launch an Eclipse application"
wsams
I managed to get this working. In Eclipse when right-clicking on the project root in "Project Explorer", under the section "PDE Tools" I selected "Update Classpath..."
wsams
Also in "META-INF/MANIFEST.MF" I had to add a couple lines,
wsams
Import-Package: org.springframework.web.client, org.springframework.xml.xpath
wsams