我只在Activator.start()函數寫了下面的代碼OSGI揭露的「ClassNotFoundException的:org.w3c.dom中***。」錯誤時釋放
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
Node node = new Node() {
@Override
public Object setUserData(String arg0, Object arg1, UserDataHandler arg2) {
// TODO Auto-generated method stub
return null;
}
@Override
public void setTextContent(String arg0) throws DOMException {
// TODO Auto-generated method stub
}
@Override
public void setPrefix(String arg0) throws DOMException {
// TODO Auto-generated method stub
}
@Override
public void setNodeValue(String arg0) throws DOMException {
// TODO Auto-generated method stub
}
@Override
public Node replaceChild(Node arg0, Node arg1) throws DOMException {
// TODO Auto-generated method stub
return null;
}
@Override
public Node removeChild(Node arg0) throws DOMException {
// TODO Auto-generated method stub
return null;
}
@Override
public void normalize() {
// TODO Auto-generated method stub
System.out.println("normalize 方法調用");
}
@Override
public String lookupPrefix(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public String lookupNamespaceURI(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isSupported(String arg0, String arg1) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isSameNode(Node arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isEqualNode(Node arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isDefaultNamespace(String arg0) {
// TODO Auto-generated method stub
return false;
}
@Override
public Node insertBefore(Node arg0, Node arg1) throws DOMException {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean hasChildNodes() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean hasAttributes() {
// TODO Auto-generated method stub
return false;
}
@Override
public Object getUserData(String arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public String getTextContent() throws DOMException {
// TODO Auto-generated method stub
return null;
}
@Override
public Node getPreviousSibling() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getPrefix() {
// TODO Auto-generated method stub
return null;
}
@Override
public Node getParentNode() {
// TODO Auto-generated method stub
return null;
}
@Override
public Document getOwnerDocument() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getNodeValue() throws DOMException {
// TODO Auto-generated method stub
return null;
}
@Override
public short getNodeType() {
// TODO Auto-generated method stub
return 0;
}
@Override
public String getNodeName() {
// TODO Auto-generated method stub
return null;
}
@Override
public Node getNextSibling() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getNamespaceURI() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getLocalName() {
// TODO Auto-generated method stub
return null;
}
@Override
public Node getLastChild() {
// TODO Auto-generated method stub
return null;
}
@Override
public Node getFirstChild() {
// TODO Auto-generated method stub
return null;
}
@Override
public Object getFeature(String arg0, String arg1) {
// TODO Auto-generated method stub
return null;
}
@Override
public NodeList getChildNodes() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getBaseURI() {
// TODO Auto-generated method stub
return null;
}
@Override
public NamedNodeMap getAttributes() {
// TODO Auto-generated method stub
return null;
}
@Override
public short compareDocumentPosition(Node arg0) throws DOMException {
// TODO Auto-generated method stub
return 0;
}
@Override
public Node cloneNode(boolean arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public Node appendChild(Node arg0) throws DOMException {
// TODO Auto-generated method stub
return null;
}
};
node.normalize();
}
一切順利的話在Eclipse環境中運行時,但是,當發行版的產品,在日誌中的錯誤時運行:
根異常: java.lang.NoClassDefFoundError:組織/ W3C/DOM /節點
產生的原因:拋出java.lang.ClassNotFoundException:組織。 w3c.dom.Node
任何人都可以給予一定的幫助?
但我在哪裏可以找到org.w3c.dom_version_x_x_x.jar?我無法在eclipse插件/ derectory中找到。 BTW:org.w3c.dom已經包含在jre類路徑中,爲什麼我們要這樣做? –
惟獨Java的*,必須明確導入,如OSGi的包裝 – thobens
org.w3c.dom中的可從JRE,但@thobens指出你需要使用「org.osgi.framework明確導出。 system.packages「或」org.osgi.framework.system.packages.extra「屬性(請參閱google瞭解更多信息)。這允許您使用與JRE中包含的版本不同的版本。 – earcam