OSGi 컨테이너에 OSGi 번들을 설치하려고합니다. 내 폴더 중 하나에 jar 파일이 있습니다. 그 jar 파일을 ByteArray
으로 읽은 다음이 ByteArray
을 사용하여 Framework
번들을 OSGi 컨테이너에 설치합니다. 아래는 내가 항상ByteArray를 사용하여 OSGi 번들 설치
org.osgi.framework.BundleException: Bundle symbolic name and version are not unique: Framework:1.0.0
가
사람이 내가 뭐하는 거지 무슨 말해 줄 수 GET-, 아래
FrameworkFactory frameworkFactory = ServiceLoader.load(FrameworkFactory.class).iterator().next();
framework = frameworkFactory.newFramework(new HashMap<String, String>());
framework.start();
final String basePath = "C:\\LocalStorage";
final BundleContext bundleContext = framework.getBundleContext();
final List<Bundle> installedBundles = new LinkedList<Bundle>();
String filename = "Framework" + "-" + "1.0.0" + ".jar";
String localFilename = basePath+ File.separatorChar + filename;
File file = new File(localFilename);
byte [] fileData = new byte[(int)file.length()];
DataInputStream dis = new DataInputStream((new FileInputStream(file)));
dis.readFully(fileData);
dis.close();
// But below line gives me exception always-
installedBundles.add(bundleContext.installBundle(filename, new ByteArrayInputStream(fileData)));
for (Bundle bundle : installedBundles) {
bundle.start();
}
예외입니다 .. 코드입니다? 그리고 ..
업데이트를 나는 다른 클래스에 내 코드의 일부, 나는이 ByteArray 사용하고 있기 때문이 ByteArray를 사용해야합니다, 그래서 나는 그 방법 파일 항아리의이 ByteArray를 전달해야합니다 : -
하지만 이런 식으로 설치하는 경우 제대로 작동합니다. 나는이 ByteArray를 통해 설치하고 있다면 그것은 .. 작동하지 않습니다
final String basePath = "C:\\LocalStorage";
final BundleContext bundleContext = framework.getBundleContext();
final List<Bundle> installedBundles = new LinkedList<Bundle>();
String filename = "Framework" + "-" + "1.0.0" + ".jar";
String localFilename = Constants.FILE_PROTOCOL + basePath+ File.separatorChar + filename;
installedBundles.add(bundleContext.installBundle(localFilename));
for (Bundle bundle : installedBundles) {
bundle.start();
}
내가이 ByteArray 일이 뭔가 잘못을하고있는 중이 가능성이 될 수 있을까요? 어떤 생각?
이미 내'MANIFEST.MF의 file'에 이러한 항목이 - '번들-ManifestVersion : 2 번들-이름 : 프레임 워크 를 번들 - SymbolicName : 프레임 워크 번들 - 버전 : 혼란에 대한 1.0.0' – AKIWEB