ContainX / openstack4j

A Fluent OpenStack SDK / Client Library for Java
http://openstack4j.com
Other
290 stars 366 forks source link

Error during call OpenStack4J from JSF: URI template of the newly created target must not be null. #42

Closed anhdenday closed 10 years ago

anhdenday commented 10 years ago

Dear all, I am trying to call some function of openstack4J from web application (JSF) I write my function in my bean as following:

public List getFlavorList() {

     List<SelectItem> items = new ArrayList<SelectItem>();

     OSClient osClient = OSFactory.builder().endpoint("http://xxx.xxx.xxx.xxx:5000/v2.0")
        .credentials("admin", "nova").tenantName("admin").authenticate();

     List<? extends Flavor> flavors = osClient.compute().flavors().list();

     SelectItem item = null;
     for (Flavor flv: flavors){
          item = new SelectItem();
          item.setLabel(flv.getName());
          item.setValue(flv.getId());
          items.add(item);
     }

     return items;
}

If i create a main function to test this function directly so that it ok, i can get flavor list. But If i try to call from my JSF page, It appear an error.

/h:selectOneMenu The error is below, please check it for me, thanks you so much java.lang.NullPointerException: URI template of the newly created target must not be null. at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:179) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:69) at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:73) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:52) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:43) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131) at org.openstack4j.openstack.compute.internal.FlavorServiceImpl.list(FlavorServiceImpl.java:24) at com.vdco.icloud.openstack.web.service.impl.FlavorServiceImpl.getFlavorIDList(FlavorServiceImpl.java:39) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
gondor commented 10 years ago

What version of OpenStack4j are you using? The line #'s aren't matching up for me on the stack trace.

anhdenday commented 10 years ago

Dear Gondor, I am using openstack4j version 1.0.1 with maven

org.pacesys openstack4j 1.0.1

Thanks you

gondor commented 10 years ago

Would you mind trying 1.0.2-SNAPSHOT and seeing if you get past this? A lot has changed from the 1.0.1 version including the way URLs are handled. I must admit it is baffling that it works in your Main method but not in JSF. Regardless the SNAPSHOT will better align with the newer code lines to help me debug.

anhdenday commented 10 years ago

Dear Gondo, I replace openstack4j by the new one version 1.0.2 but it appear the same problem as before. Here is some code of my JSF page.

h:selectOneMenu value="#{dropletBean.droplet.flavorID}" f:selectItem itemLabel="Please select one size" / f:selectItems value="#{dropletBean.getFlavorList()}" / /h:selectOneMenu

h:commandButton value="Create Droplet" type="submit" action="#{dropletBean.createDroplet()}" /

(Sorry i have to remove "< " and " />" to show the JSF code.

public List getFlavorList() { List items = new ArrayList(); List<? extends Flavor> flavors = osClient.compute().flavors().list(); System.out.println(flavors.size()); SelectItem item = null; for (Flavor flv: flavors){ item = new SelectItem(); item.setLabel(flv.getName()); item.setValue(flv.getId()); System.out.println("Flavor name: " + flv.getName()); System.out.println("Flavor ID: " + flv.getId()); items.add(item); } return items; }

When i click on "Create Droplet" button so that the error is appear. I re-copy the full error for you to see more stack trace 8 Flavor name: m1.tiny Flavor ID: 1 Flavor name: m1.small Flavor ID: 2 Flavor name: m1.medium Flavor ID: 3 Flavor name: m1.large Flavor ID: 4 Flavor name: m1.nano Flavor ID: 42 Flavor name: m1.heat Flavor ID: 451 Flavor name: m1.xlarge Flavor ID: 5 Flavor name: m1.micro Flavor ID: 84 image list size: 7 java.lang.NullPointerException: URI template of the newly created target must not be null. at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:179) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:69) at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:74) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:53) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:44) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131) at org.openstack4j.openstack.compute.internal.FlavorServiceImpl.list(FlavorServiceImpl.java:24) at com.vdco.icloud.openstack.web.servlet.jsf2.DropletBean.getFlavorList(DropletBean.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at javax.el.BeanELResolver.invoke(BeanELResolver.java:484) at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:161) at org.apache.el.parser.AstValue.getValue(AstValue.java:173) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) at javax.faces.component.UISelectItems.getValue(UISelectItems.java:129) at javax.faces.component.SelectItemsIterator.initializeItems(SelectItemsIterator.java:198) at javax.faces.component.SelectItemsIterator.hasNext(SelectItemsIterator.java:131) at javax.faces.component.SelectUtils.matchValue(SelectUtils.java:85) at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:153) at javax.faces.component.UIInput.validate(UIInput.java:967) at javax.faces.component.UIInput.executeValidate(UIInput.java:1233) at javax.faces.component.UIInput.processValidators(UIInput.java:698) at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1220) at javax.faces.component.UIForm.processValidators(UIForm.java:253) at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1220) at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1220) at org.primefaces.component.layout.Layout.processValidators(Layout.java:233) at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1220) at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1164) at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Sep 06, 2014 2:08:47 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute WARNING: /create.xhtml @55,64 value="#{dropletBean.getFlavorList()}": java.lang.NullPointerException javax.el.ELException: /create.xhtml @55,64 value="#{dropletBean.getFlavorList()}": java.lang.NullPointerException at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) at javax.faces.component.UISelectItems.getValue(UISelectItems.java:129) at javax.faces.component.SelectItemsIterator.initializeItems(SelectItemsIterator.java:198) at javax.faces.component.SelectItemsIterator.hasNext(SelectItemsIterator.java:131) at javax.faces.component.SelectUtils.matchValue(SelectUtils.java:85) at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:153) at javax.faces.component.UIInput.validate(UIInput.java:967) at javax.faces.component.UIInput.executeValidate(UIInput.java:1233) at javax.faces.component.UIInput.processValidators(UIInput.java:698) at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1220) at javax.faces.component.UIForm.processValidators(UIForm.java:253) at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1220) at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1220) at org.primefaces.component.layout.Layout.processValidators(Layout.java:233) at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1220) at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1164) at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.NullPointerException at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131) at org.openstack4j.openstack.compute.internal.FlavorServiceImpl.list(FlavorServiceImpl.java:24) at com.vdco.icloud.openstack.web.servlet.jsf2.DropletBean.getFlavorList(DropletBean.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at javax.el.BeanELResolver.invoke(BeanELResolver.java:484) at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:161) at org.apache.el.parser.AstValue.getValue(AstValue.java:173) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) ... 67 more

java.lang.NullPointerException: URI template of the newly created target must not be null. at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:179) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:69) at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:74) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:53) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:44) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131) at org.openstack4j.openstack.compute.internal.FlavorServiceImpl.list(FlavorServiceImpl.java:24) at com.vdco.icloud.openstack.web.servlet.jsf2.DropletBean.getFlavorList(DropletBean.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at javax.el.BeanELResolver.invoke(BeanELResolver.java:484) at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:161) at org.apache.el.parser.AstValue.getValue(AstValue.java:173) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) at javax.faces.component.UISelectItems.getValue(UISelectItems.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.sun.faces.facelets.util.DevTools.writeAttributes(DevTools.java:380) at com.sun.faces.facelets.util.DevTools.writeStart(DevTools.java:433) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:250) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.debugHtml(DevTools.java:131) at com.sun.faces.renderkit.RenderKitUtils.renderHtmlErrorPage(RenderKitUtils.java:1206) at com.sun.faces.context.ExceptionHandlerImpl.throwIt(ExceptionHandlerImpl.java:269) at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:139) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) java.lang.NullPointerException: URI template of the newly created target must not be null. at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:179) at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:69) at org.openstack4j.core.transport.internal.HttpExecutor.invoke(HttpExecutor.java:74) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:53) at org.openstack4j.core.transport.internal.HttpExecutor.execute(HttpExecutor.java:44) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:136) at org.openstack4j.openstack.internal.BaseOpenStackService$Invocation.execute(BaseOpenStackService.java:131) at org.openstack4j.openstack.image.internal.ImageServiceImpl.list(ImageServiceImpl.java:36) at com.vdco.icloud.openstack.web.servlet.jsf2.DropletBean.getImageList(DropletBean.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at javax.el.BeanELResolver.invoke(BeanELResolver.java:484) at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:161) at org.apache.el.parser.AstValue.getValue(AstValue.java:173) at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) at javax.faces.component.UISelectItems.getValue(UISelectItems.java:129) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.sun.faces.facelets.util.DevTools.writeAttributes(DevTools.java:380) at com.sun.faces.facelets.util.DevTools.writeStart(DevTools.java:433) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:250) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:269) at com.sun.faces.facelets.util.DevTools.debugHtml(DevTools.java:131) at com.sun.faces.renderkit.RenderKitUtils.renderHtmlErrorPage(RenderKitUtils.java:1206) at com.sun.faces.context.ExceptionHandlerImpl.throwIt(ExceptionHandlerImpl.java:269) at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:139) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)

anhdenday commented 10 years ago

Dear Gondo, I've solved the problem, the problem is because in my DropletBean class I declared osClient variable as a global variable, but when I move this variable into getFlavorList() so that it's ok, I dont know why! OSClient osClient = OSFactory.builder().endpoint("http://123.30.50.93:5000/v2.0") .credentials("admin", "nova").tenantName("admin").authenticate();

The code below is ok now

public List getListFlavorItem() { OSClient osClient = OSFactory.builder().endpoint("http://xxx.xxx.xxx.xxx:5000/v2.0") .credentials("admin", "nova").tenantName("admin").authenticate();

     List<? extends Flavor> flavors = osClient.compute().flavors().list();

     System.out.println(flavors.size());

     SelectItem item = null;

     for (Flavor flv: flavors){
          item = new SelectItem();
          item.setLabel(flv.getName());
          item.setValue(flv.getId());
          System.out.println("Flavor name: " + flv.getName());
          System.out.println("Flavor ID: " + flv.getId());
          listFlavorItem.add(item);
     }
     return listFlavorItem;
}
gondor commented 10 years ago

Ok, this makes sense. OS4J uses a ThreadLocal to track the authenticated session. In JSF due to it's life cycles you would be called on various threads so the initial session was lost.

What you can if you want to authenticate once and re-use it is..

OSClient osclient = OSFactory.clientFromAccess(access);
anhdenday commented 10 years ago

Thanks you so much, it's work!

gondor commented 10 years ago

Awesome!