获取Flavor列表时出错:java.lang.NullPointerException:新创建的目标的URI模板不能为null

时间:2014-09-05 16:09:16

标签: jsf openstack

我正在使用JSF开发Web应用程序,并使用OpenStack4J与OpenStack一起工作, 在我的bean组件中,我有方法:

public List<SelectItem> 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;
    }

如果我创建一个主要测试来测试这个方法,一切都好,我可以从OpenStack获取flavor列表,但是当我尝试从JSF页面调用时,它似乎有问题。

在我的JSF页面中,我试图调用

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

错误如下所示。请帮我检查一下。

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)

非常感谢你

0 个答案:

没有答案