javaejb-3.0websphere-8ejb-jar.xml

Websphere 85 ejb 3 deploy issue


I am trying to deploy a bean that is ejb 3 on websphere 8. Bean implementation is in src/main/java and ejb-jar.xml is in src/main/resources/META-INF. This is packaged in a jar and the jar is included in ear that also has other ejb jar with ejb 2. So ear contains both ejb 2 and ejb 3 jars. During deployment of this ear in websphere, I am getting below error:

org.eclipse.emf.common.util.WrappedException: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ejb-jar'.

If I remove ejb-jar.xml from ejb 3 jar, deployment is successful. If I deploy an ear containing only ejb 3 jar, it is successful. If I deploy ejb 3 jar directly from ibm console, it gets deployed successfully.

But trying to deploy an ear containing both ejb 2 and ejb 3 jar is failing. Below is full stacktrace:

 [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>

I believe deployment is failing because ear has both ejb 2 and ejb 2 jars.

Any suggestions on how to fix this?


Solution

  • Your XML header is using incompatible xmlns and version attributes. Try this:

    <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">
    

    (Your EJB 2.x ejb-jar.xml might also have a mismatch, so showing that might also be useful.)