Support Questions
Find answers, ask questions, and share your expertise

Clouder Manager Java API error - illegal repetition near index 12

Highlighted

Clouder Manager Java API error - illegal repetition near index 12

Explorer

Hi,

 

I am trying to call the Cloudera Manager REST API with the below java code.  But getting an error "illegal repetition near index 12 configFiles/{configFileName }".  Below the relavant part of my code

 

 

public static void main {

RootResourceV4 apiRoot = new ClouderaManagerClientBuilder().withHost("xx.xx.xx.xx") //cm api address goes here
.withPort(7180) //cm port
.withUsernamePassword("admin", "admin").build().getRootV4();

}

As seen, i calling the api from a main method, i guess that is not a problem.

 

The CDH version i'm using is 5.3.0.  I tried with the RootResourceV9 jar without any luck.

I am stuck with this issue, any help would be much appreciated.

 

thanks in advance

3 REPLIES 3
Highlighted

Re: Clouder Manager Java API error - illegal repetition near index 12

Super Collaborator

I've used your exact code with only minor changes (see below) did not experience any issue.

Is there anything else logged in the /var/log/cloudera-scm-server/cloudera-scm-server.log ?

 

Also, you can set CM API in debug mode* to view how CM server receives the REST call.

 

    public static void main(String[] args) {
	// write your code here
        RootResourceV4 apiRoot = new ClouderaManagerClientBuilder().withHost("xxx.xxx.xxx") //cm api address goes here
                .withPort(7180) //cm port
                .withUsernamePassword("admin", "admin").build().getRootV4();

        ApiClusterList clusters = apiRoot.getClustersResource()
                .readClusters(DataView.SUMMARY);

        System.out.println(clusters);

    }

 

*CM> Administration> Settings> search "Enable Debugging of API"

 
Highlighted

Re: Clouder Manager Java API error - illegal repetition near index 12

Explorer

Hi Michalis,

 

Many thanks for your reply.

 

As suggested, i checked the /var/log/cloudera-scm-server/cloudera-scm-server.log.  And below is the error stack i can see.

 

org.apache.avro.AvroRemoteException: java.net.ConnectException: Connection refused
	at org.apache.avro.ipc.specific.SpecificRequestor.invoke(SpecificRequestor.java:88)
	at com.sun.proxy.$Proxy133.queryEvents(Unknown Source)
	at com.cloudera.cmf.event.query.AvroEventStoreQueryProxy.doQuery(AvroEventStoreQueryProxy.java:160)
	at com.cloudera.server.web.cmf.events.EventDao.findEvents(EventDao.java:357)
	at com.cloudera.server.web.cmf.EventsController.query(EventsController.java:168)
	at sun.reflect.GeneratedMethodAccessor1299.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
	at org.mortbay.servlet.UserAgentFilter.doFilter(UserAgentFilter.java:78)
	at org.mortbay.servlet.GzipFilter.doFilter(GzipFilter.java:131)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
	at com.jamonapi.http.JAMonServletFilter.doFilter(JAMonServletFilter.java:48)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
	at com.cloudera.enterprise.JavaMelodyFacade$MonitoringFilter.doFilter(JavaMelodyFacade.java:109)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
	at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:146)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
	at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
	at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:767)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.handler.StatisticsHandler.handle(StatisticsHandler.java:53)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
	at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.net.ConnectException: Connection refused
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:579)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
	at sun.net.www.http.HttpClient.New(HttpClient.java:308)
	at sun.net.www.http.HttpClient.New(HttpClient.java:326)
	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:996)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:850)
	at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1091)
	at org.apache.avro.ipc.HttpTransceiver.writeBuffers(HttpTransceiver.java:71)
	at org.apache.avro.ipc.Transceiver.transceive(Transceiver.java:58)
	at org.apache.avro.ipc.Transceiver.transceive(Transceiver.java:72)
	at org.apache.avro.ipc.Requestor.request(Requestor.java:147)
	at org.apache.avro.ipc.Requestor.request(Requestor.java:101)
	at org.apache.avro.ipc.specific.SpecificRequestor.invoke(SpecificRequestor.java:72)
	... 73 more

 

I could not try it in the debug mode as mentioned in your reply, due to insufficient access to the cluster environment.

 

Copying below the complete error stack i'm getting while executing my main method.

 

Exception in thread "main" com.google.common.util.concurrent.UncheckedExecutionException: java.util.regex.PatternSyntaxException: Illegal repetition near index 12
/configFiles/{configFileName : \.\*}(/.*)?
            ^
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2234)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3965)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3969)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4829)
	at com.google.common.cache.LocalCache$LocalManualCache.getUnchecked(LocalCache.java:4834)
	at com.cloudera.api.ClouderaManagerClientBuilder.build(ClouderaManagerClientBuilder.java:259)
	at com.cloudera.api.ClouderaManagerClientBuilder.build(ClouderaManagerClientBuilder.java:245)
	at cloudera.ClouderaManager.main(ClouderaManager.java:43)
Caused by: java.util.regex.PatternSyntaxException: Illegal repetition near index 12
/configFiles/{configFileName : \.\*}(/.*)?
            ^
	at java.util.regex.Pattern.error(Pattern.java:1924)
	at java.util.regex.Pattern.closure(Pattern.java:3104)
	at java.util.regex.Pattern.sequence(Pattern.java:2101)
	at java.util.regex.Pattern.expr(Pattern.java:1964)
	at java.util.regex.Pattern.compile(Pattern.java:1665)
	at java.util.regex.Pattern.<init>(Pattern.java:1337)
	at java.util.regex.Pattern.compile(Pattern.java:1022)
	at org.apache.cxf.jaxrs.model.URITemplate.<init>(URITemplate.java:89)
	at org.apache.cxf.jaxrs.model.URITemplate.createTemplate(URITemplate.java:301)
	at org.apache.cxf.jaxrs.model.URITemplate.createTemplate(URITemplate.java:288)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.createOperationInfo(ResourceUtils.java:328)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:204)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:190)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:211)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:190)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:211)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:190)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:211)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:190)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:211)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:190)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.evaluateResourceClass(ResourceUtils.java:211)
	at org.apache.cxf.jaxrs.utils.ResourceUtils.createClassResourceInfo(ResourceUtils.java:190)
	at org.apache.cxf.jaxrs.JAXRSServiceFactoryBean.createResourceInfo(JAXRSServiceFactoryBean.java:181)
	at org.apache.cxf.jaxrs.JAXRSServiceFactoryBean.setResourceClass(JAXRSServiceFactoryBean.java:128)
	at org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.setServiceClass(JAXRSClientFactoryBean.java:91)
	at org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.setResourceClass(JAXRSClientFactoryBean.java:87)
	at com.cloudera.api.ClouderaManagerClientBuilder$1.load(ClouderaManagerClientBuilder.java:101)
	at com.cloudera.api.ClouderaManagerClientBuilder$1.load(ClouderaManagerClientBuilder.java:97)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3568)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2350)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2313)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2228)
	... 7 more

I guess the "/configFiles/{configFileName" part of one of the REST API - /clusters/{clusterName}/services/{serviceName}/roles/{roleName}/process/configFiles/{configFileName ....

 

Few of my assumptions & questions

1.  Why my call getting end up with the above REST API Path.  With the lines of code, i wrote in my main method, it does not make any sense.

 

2.  Do i need to call this api from a webcontainer.  As of now, i'm calling it from standalone java main method.

 

3.  I do not have admin privilage and the credentials given in withUsernamePassword() method is not of an admin.

Could that be a problem?

 

4.  I am executing this code(my main method) from a remote a machine which has access only to the 7180 port of the hadoop cluster.  Do i need to have access to any more ports ?

 

Finally, I am able to call the CM REST API from my machine using curl command from terminal(linux terminal) and from within Java program that use curl command and getting proper response.

 

Just to give some info about the context : I am a Java programmer trying to expose Cloudera Manager from java for a tool we are developing.   I am newbie in hadoop have only basic knowledge in Hadoop and very little knowledge in Hadoop Administration.

 

I'm stuck with this issue for many days and help would be much appreciated.

 

Thanks,

 

Re: Clouder Manager Java API error - illegal repetition near index 12

Super Collaborator

Few of my assumptions & questions

1.  Why my call getting end up with the above REST API Path.  With the lines of code, i wrote in my main method, it does not make any sense.

The error could be a red herring or symptom of a different issue. 

 

2.  Do i need to call this api from a webcontainer.  As of now, i'm calling it from standalone java main method.

My test was also from a standalone java main method - or refer to our test example [1]

 

3.  I do not have admin privilage and the credentials given in withUsernamePassword() method is not of an admin.

Could that be a problem?

It is recommended to have "Cluster Administrator" or "Full Administrator" role to use REST API [2] 

 

4.  I am executing this code(my main method) from a remote a machine which has access only to the 7180 port of the hadoop cluster.  Do i need to have access to any more ports ?

7180 is the correct port.

 

> Copying below the complete error stack i'm getting while executing my main method. 

Can you post you pom.xml just to confirm that you have all the dependencies.

From the log "/var/log/cloudera-scm-server/cloudera-scm-server.log", it doesn't seem that you code make it to CM server.

 

Recommendation, if you can build a new single VM host and perform your test [3]

 

 

[1] https://github.com/cloudera/cm_api/blob/master/java/src/test/java/com/cloudera/api/ClouderaManagerCl...

[2] http://www.cloudera.com/documentation/enterprise/latest/topics/cm_intro_api.html

[3] https://github.com/gdgt/cmapi