我正在尝试在 websphere 8 上部署一个 ejb 3 的 bean。Bean 实现在 src/main/java 中,ejb-jar.xml 在 src/main/resources/META-INF 中。它被包装在一个罐子里,这个罐子包含在耳朵里,耳朵里还有其他带有 ejb 2 的 ejb 罐子。所以耳朵包含 ejb 2 和 ejb 3 罐子。在网络圈中部署此耳朵期间,我收到以下错误:
org.eclipse.emf.common.util.WrappedException: org.xml.sax.SAXParseException: cvc-elt.1: 找不到元素 'ejb-jar' 的声明。
如果我从 ejb 3 jar 中删除 ejb-jar.xml,部署成功。如果我部署一个只包含 ejb 3 jar 的耳朵,它是成功的。如果我直接从 IBM 控制台部署 ejb 3 jar,它将成功部署。
但是尝试部署同时包含 ejb 2 和 ejb 3 jar 的耳朵是失败的。以下是完整的堆栈跟踪:
[echo] Error executing deployment: org.eclipse.emf.common.util.WrappedException. Error is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ejb-jar'..
[echo] org.eclipse.emf.common.util.WrappedException: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ejb-jar'.
[echo] at org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer.loadDocument(EMF2DOMRenderer.java:81)
[echo] at org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer.doLoad(EMF2DOMRenderer.java:62)
[echo] at org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl.basicDoLoad(TranslatorResourceImpl.java:153)
[echo] at org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResourceImpl.doLoad(CompatibilityXMIResourceImpl.java:182)
[echo] at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1494)
[echo] at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1282)
[echo] at org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResourceImpl.load(CompatibilityXMIResourceImpl.java:272)
[echo] at org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl.load(TranslatorResourceImpl.java:423)
[echo] at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:255)
[echo] at org.eclipse.jem.internal.util.emf.workbench.ProjectResourceSetImpl.demandLoad(ProjectResourceSetImpl.java:815)
[echo] at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:270)
[echo] at org.eclipse.jem.internal.util.emf.workbench.ProjectResourceSetImpl.getResource(ProjectResourceSetImpl.java:1068)
[echo] at org.eclipse.wst.common.internal.emfworkbench.WorkbenchResourceHelper.getOrCreateResource(WorkbenchResourceHelper.java:380)
[echo] at org.eclipse.wst.common.internal.emfworkbench.integration.EditModel.getResource(EditModel.java:685)
[echo] at org.eclipse.wst.common.componentcore.internal.ArtifactEditModel.getResource(ArtifactEditModel.java:199)
[echo] at org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit.getDeploymentDescriptorResource(EJBArtifactEdit.java:296)
[echo] at org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit.getDeploymentDescriptorRoot(EJBArtifactEdit.java:322)
[echo] at org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit.getEJBJar(EJBArtifactEdit.java:306)
[echo] at org.eclipse.jst.j2ee.ejb.componentcore.util.EJBArtifactEdit.getEJBClientJarModule(EJBArtifactEdit.java:252)
[echo] at org.eclipse.jst.j2ee.ejb.internal.plugin.EjbModuleExtensionImpl.getDefinedEJBClientJARProject(EjbModuleExtensionImpl.java:91)
[echo] at com.ibm.etools.ejbdeploy.batch.plugin.BatchExtension.runEarDeploy(BatchExtension.java:482)
[echo] at com.ibm.etools.ejbdeploy.batch.plugin.BatchExtension$RunDeploy.run(BatchExtension.java:356)
[echo] at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
[echo] at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1957)
[echo] at com.ibm.etools.ejbdeploy.batch.plugin.BatchExtension$RunDeploy.execute(BatchExtension.java:321)
[echo] at com.ibm.etools.ejbdeploy.batch.plugin.BatchExtension.run(BatchExtension.java:284)
[echo] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[echo] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
[echo] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
[echo] at java.lang.reflect.Method.invoke(Method.java:611)
[echo] at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
[echo] at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
[echo] at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
[echo] at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
[echo] at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
[echo] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[echo] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
[echo] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
[echo] at java.lang.reflect.Method.invoke(Method.java:611)
[echo] at com.ibm.etools.ejbdeploy.batch.impl.BootLoaderLoader.run(BootLoaderLoader.java:494)
[echo] at com.ibm.etools.ejbdeploy.batch.impl.BatchDeploy.execute(BatchDeploy.java:114)
[echo] at com.ibm.etools.ejbdeploy.EJBDeploy.execute(EJBDeploy.java:106)
[echo] at com.ibm.etools.ejbdeploy.EJBDeploy.deploy(EJBDeploy.java:348)
[echo] at com.ibm.etools.ejbdeploy.EJBDeploy.main(EJBDeploy.java:309)
[echo] Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ejb-jar'.
[echo] at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
[echo] at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
[echo] at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
[echo] at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
[echo] at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
[echo] at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
[echo] at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
[echo] at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
[echo] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
[echo] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
[echo] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
[echo] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
[echo] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
[echo] at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
[echo] at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
[echo] at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
[echo] at org.eclipse.wst.common.internal.emf.utilities.DOMUtilities.loadDocument(DOMUtilities.java:554)
[echo] at org.eclipse.wst.common.internal.emf.resource.EMF2DOMRenderer.loadDocument(EMF2DOMRenderer.java:74)
[echo] ... 43 more
[echo] EJBDeploy level: @build@
EJB-jar.xml <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
<description><![CDATA[]]></description>
<display-name></display-name>
<enterprise-beans>
<session id="">
<description><![CDATA[]]></description>
<ejb-name></ejb-name>
<env-entry>
<env-entry-name></env-entry-name>
<env-entry-type></env-entry-type>
<env-entry-value><![CDATA[]]></env-entry-value>
</env-entry>
我相信部署失败了,因为耳朵同时有 ejb 2 和 ejb 2 jar。
关于如何解决此问题的任何建议?
您的 XML 标头使用了不兼容的xmlns
和version
属性。 试试这个:
<ejb-jar version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
(您的 EJB 2.x ejb-jar.xml 也可能不匹配,因此显示它也可能很有用。