Reputation: 1954
I am trying to work on an architecture to consume RESTFul services from a JavaFX application. The requirement is to use spring's rest template(Not too pressed for this. If spring does not work then probably I can look at jersey or resteasy.
My setup is as below:
My main class has a dropdown listing values from a RESTFul service.
The architecture to hit the RESTFul services is as below:
I have a client class that gives me the instance of the service class that hits the rest services.
In the service class, I have various methods that I hit on the RESTFul service.
public MyService1()
{
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
MyConfig.class);
context.registerShutdownHook();
}
@Autowired
private RestOperations restTemplate;
private final Logger LOG = LoggerFactory.getLogger(MyService1.class);
public List<MyObject> getMyObjects() throws IOException
{
HttpEntity<MultiValueMap<String, HttpEntity<?>>> request = new HttpEntity<MultiValueMap<String, HttpEntity<?>>>(
createParts(), createMultiPartHeaders());
Map<String, String> vars = new HashMap<String, String>();
List<MyObject> myObjects = restTemplate.getForObject(
"http://localhost:8080/my-webservices/objects", List.class, vars);
return myObjects;
}
With the above setup, I get the exception:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.beans.factory.BeanCreationException
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)
Upvotes: 0
Views: 515
Reputation: 723
It seems like you have not added the dependency library containing "BeanCreationException" class. Please add the jar file of spring as dependency for that JavaFX Project.
Upvotes: 1