Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ApplicationContext instance ClassPathXmlApplicationContext using Spring

nantucketJun 17 2014 — edited Jun 18 2014

I don't know where to put this.  The Spring forum is closed to new registrants.  Which is too bad for me because I'm just starting out with Spring.

I'm trying to instantiate an ApplicationContext in Eclipse.  I've got spring-context-3.2.0.RELEASE.jar, and spring-beans-3.2.0.RELEASE both on my classpath,

ApplicationContext context = new ClassPathXmlApplicationContext("classpath:test-config.xml");

There are two error messages the IDE is showing.  And I'm having trouble with both

1) "Resource leak: 'context' is never closed."

  But I don't see a "close" method for ApplicationContext, so how do I address that?

2) "Unhandled exception type BeansException."  So I surround the line with a try block

ApplicationContext context;

  try {

  context = new ClassPathXmlApplicationContext("classpath:test-config.xml");

  } catch (BeansException e) {

  // TODO Auto-generated catch block

  e.printStackTrace();

  }

But now the error is "the method printStackTrace is undefined for BeansException"?

Can anyone help?

The core issue is that I've got this ApplicationContext line working in another workspace, admittedly with a different build path, and I'm not using a try block with it, so I'm not sure what I need to do..  Any help would be appreciated.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 16 2014
Added on Jun 17 2014
1 comment
2,099 views