on 04-13-2017 12:41 PM - last edited on 02-03-2024 9:00 PM by postmig_api_4
I want to access data which has been served by the Cloud Connector and which is successfully connected to my Cloud Platform account. Now I want to access this data within a Spring Boot application and display the data on a web page.
But I get an error when I try to access the connectivityConfiguration resource:
javax.naming.NamingException: Cannot create resource instance
In Spring Boot I have no web.xml, so I try to do it this way:
@Bean
public TomcatEmbeddedServletContainerFactory tomcatFactory() {
return new TomcatEmbeddedServletContainerFactory() {
@Override
protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(Tomcat tomcat) {
tomcat.enableNaming();
return super.getTomcatEmbeddedServletContainer(tomcat);
}
@Override
protected void postProcessContext(Context context) {
ContextResource resource = new ContextResource();
resource.setName("connectivityConfiguration");
resource.setType(com.sap.core.connectivity.api.configuration.ConnectivityConfiguration.class.getName());
context.getNamingResources().addResource(resource);
}
};
}
When I access the InitialContext, I see the connectivityConfiguration key in the list of resources, but when I try to access it like that:
Context context = new InitialContext();
Object conObj = context.lookup("java:comp/env/connectivityConfiguration");
ConnectivityConfiguration configuration = (ConnectivityConfiguration) conObj;
.. I get the exception I mentioned above.
Any idea?
I also have similar requirement but without springboot.
I have a web.xml filebut still I am facing same set of isues.
Regards
Shirjan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since you do not use the embedded Tomcat on SAP CP, you won't need the TomcatEmbeddedServletContainerFactory stuff.
I provided a context.xml including a <Resource> tag for the ConnectivityConfiguration and placed that file in "src/main/webapp/META-INF". Don't use "src/main/resources/..." also it is suggested for Spring Boot. Then you'll be able to lookup the JNDI resource...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.