Skip to Content

Access Cloud Connector data from Spring Boot

Apr 13, 2017 at 11:41 AM


avatar image
Former Member

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:

public TomcatEmbeddedServletContainerFactory tomcatFactory() {
    return new TomcatEmbeddedServletContainerFactory() {
        protected TomcatEmbeddedServletContainer getTomcatEmbeddedServletContainer(Tomcat tomcat) {
            return super.getTomcatEmbeddedServletContainer(tomcat);
        protected void postProcessContext(Context context) {
            ContextResource resource = new ContextResource();

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?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member
May 08, 2017 at 08:43 AM

I also have similar requirement but without springboot.

I have a web.xml filebut still I am facing same set of isues.



Show 2 Share
10 |10000 characters needed characters left characters exceeded

I have the same issue (also without spring-boot, just spring framework). Any news on that?


I have two applications deployed and I missed the resource-ref entry in the web.xml of one of the web applications, but I needed it in both. So it wasn't related to spring at all.

Hope that helps someone.

Tobias Trapp Jun 02, 2017 at 07:53 PM

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...

10 |10000 characters needed characters left characters exceeded