在Virgo中部署VI-JAVA。lang.NoClassDefFoundError
对于vSphere Web Client插件,我创建了一个java服务,我尝试使用VI java在ESX主机中创建一个数据存储。我包括
import com.vmware.vim25.*;
import com.vmware.vim25.mo.*;
服务实现中的文件,包括STS环境的外部JAR,并创建了一个列出所有主机的函数:
public List<String> listVcHosts() throws Exception{
ManagedEntity[] hosts = new InventoryNavigator(rootFolder).searchManagedEntities("HostSystem");
List<String> listHosts = new ArrayList<String>();
for( ManagedEntity me : hosts ) {
HostSystem host = (HostSystem) me;
//Adding the list of hosts in List
listHosts.add(host.getName().toString());
}
return listHosts;
}
当我从STS作为JAVA应用程序执行时,它工作正常,没有任何警告
我将jar复制到server/pickup文件夹,并尝试在VIRGO中部署服务
它将引发以下异常:
An Import-Package could not be resolved. Caused by missing constraint in bundle <com.xx.xxx.xxxx_1.0.0>
constraint: <Import-Package: com.vmware.vim25.mo; version="0.0.0">
# 1 楼答案
你好像忘了把com包包括在内。vmware。vim25。在你的舱单上。MF文件。 检查这个文件,清单。MF应具有导入此包的行