WebSphere EAR Classloading from Secondary JAR in MANIFEST Classpath - classpath

My WebSphere 8.5 application has an EAR project containing an MDB project that builds to produce a JAR. That JAR has a class that references classes within a secondary JAR in the EAR that come from a third project.
the manifest for the MDB containing jar (ASyncEJB.jar) is
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Class-Path: ASync.jar
lib\aopalliance\aopalliance-1.0.jar
lib\asm\asm-3.1.jar
etc (more lib references)
the manifest for the containing Enterprise project within EAR looks like
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: abc
Built-By: xyz
Built-Date: September 18 2014
Implementation-Version: Value_not_provided
It looks like the classpath in the ASyncEJB.jar's manifest should enable it to load the class from the secondary ASync.jar.
The structure of the EAR is
lib
META-INF
ASync.jar
ASyncEJB.jar
The application.xml also withing the META-INF folder with the MANIFEST.MF looks like
<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_ID" version="6" 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/application_6.xsd">
<display-name>AsyncEnterprise</display-name>
<module id="Module_1381933529290">
<ejb>ASyncEJB.jar</ejb>
</module>
</application>
Why would I get java.lang.ClassNotFoundException on a class in ASync.jar called by a class in ASyncEJB.jar ?
The error is:
[22/09/14 15:10:04:285 EDT] 00000065 SharedEJBRunt I WSVR0057I: EJB jar started: ASyncEJB.jar
[22/09/14 15:10:04:386 EDT] 00000065 BusinessExcep E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "initialize" on bean "BeanId(AsyncEnterprise#ASyncEJB.jar#ejbContext, null)". Exception data: java.lang.NoClassDefFoundError: corporg.core.context.listener.WebContextListener
at corporg.async.beans.ContextInitilizer.initialize(ContextInitilizer.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:232)
at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:559)
at com.ibm.ejs.container.interceptors.InvocationContextImpl.doLifeCycle(InvocationContextImpl.java:273)
at com.ibm.ejs.container.SingletonBeanO.callTransactionalLifecycleInterceptors(SingletonBeanO.java:273)
at com.ibm.ejs.container.SingletonBeanO.initialize(SingletonBeanO.java:404)
at com.ibm.ejs.container.BeanOFactory.create(BeanOFactory.java:130)
at com.ibm.ejs.container.EJSHome.createNewBeanO(EJSHome.java:869)
at com.ibm.ejs.container.EJSHome.createSingletonBeanO(EJSHome.java:3981)
at com.ibm.ejs.csi.EJBApplicationMetaData.createStartupBeans(EJBApplicationMetaData.java:991)
at com.ibm.ejs.csi.EJBApplicationMetaData.startedModule(EJBApplicationMetaData.java:715)
at com.ibm.ws.runtime.component.EJBContainerImpl.stateChanged(EJBContainerImpl.java:4866)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.stateChanged(ApplicationMgrImpl.java:1120)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectEvent(DeployedApplicationImpl.java:1353)
at com.ibm.ws.runtime.component.DeployedModuleImpl.setState(DeployedModuleImpl.java:248)
at com.ibm.ws.runtime.component.DeployedModuleImpl.setState(DeployedModuleImpl.java:244)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:642)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:968)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:774)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2182)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:445)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:388)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$500(CompositionUnitMgrImpl.java:116)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:994)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:502)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1862)
Caused by: java.lang.ClassNotFoundException: corporg.core.context.listener.WebContextListener
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:204)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:688)
at java.lang.ClassLoader.loadClass(ClassLoader.java:667)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:119)
at java.lang.ClassLoader.loadClass(ClassLoader.java:650)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:584)
at java.lang.ClassLoader.loadClass(ClassLoader.java:650)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:584)
at java.lang.ClassLoader.loadClass(ClassLoader.java:650)
... 31 more

Related

Copy files to new project and now cannot create JDBC driver of class '' for connect URL 'null'

Caused by: java.sql.SQLException: No suitable driver
A Maven project in eclipse, I lost the .project file for this application. I have to copy the files into another project. So it was running before.
I am using a DataSource in Tomcat. The projects META-INF/context.xml file hasn't changed. It's deployed into /META-INF directory. web.xml and pom.xml is the same. I don't know what has changed. mysql-connector-5.1.38.jar is in $Catalina/lib.
I would look at the Build Path and Deployment Assembly but let me know.
build path.
deployment assly.
context.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource
name="jdbc/widget"
auth="Container"
type="javax.sql.DataSource"
maxActive="10"
maxIdle="3"
maxWait="10000"
username="appuser"
password="appuserpass"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/widget"/>
</Context>
web.xml
<resource-ref>
<description>MySQL Datasource</description>
<res-ref-name>jdbc/widget</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Coming back to this, I saw a similar project and matched the deployment assembly. This seemed to fix the issue. Current configuration :
/src/main/java -> WEB-INF/classes
/src/main/resources -> WEB-INF/classes
/src/main/resources/META-INF -> META-INF
/src/main/webapp -> /
/src/test/java -> WEB-INF/classes
Maven Dependencies -> WEB-INF/lib

EAR application works on Websphere8.5 but refuses to work on Websphere liberty 16.0.0.4

I get in inheritance EAR application which I need to continue to develop. The problem that I can't cause it work on Websphere Liberty 16.0.0.4 while on Websphere Application Server Full Profile 8.5 it works fine. Unfortunately or (fortunately :) ) my working station is Macbook Pro, and WAS Full Profile can't be installed on OSX (can't find links right now, but have done some search and find enough evidences for it) so I need to use VirtualBox with Linux or try to run this app on Liberty.
The latest solution doesn't work so well for me, I get the following error:
[ERROR ] CWWJP0012E: The persistence unit name is not specified and
a unique persistence unit is not found in the BigEnterpriseAppEAR
application and BigEnterpriseAppEJB.jar module. [ERROR ] CWWJP0029E:
The server cannot find the persistence unit in the
BigEnterpriseAppEJB.jar module and the BigEnterpriseAppEAR
application. [ERROR ] CWNEN0035E: The java:comp/env/BigEnterpriseApp
reference of type javax.persistence.EntityManager for the DataProvider
component in the BigEnterpriseAppEJB.jar module of the
BigEnterpriseAppEAR application cannot be resolved. [ERROR ]
CNTR0020E: EJB threw an unexpected (non-declared) exception during
invocation of method "getDataByOwner" on bean
"BeanId(BigEnterpriseAppEAR#BigEnterpriseAppWEB.war#DataAPI, null)".
Exception data: javax.ejb.EJBTransactionRolledbackException: nested
exception is: javax.ejb.EJBException: The
java:comp/env/BigEnterpriseApp reference of type
javax.persistence.EntityManager for the DataProvider component in the
BigEnterpriseAppEJB.jar module of the BigEnterpriseAppEAR application
cannot be resolved.
The app is pretty simple EAR = JPA + EJB + WAR
I don't know which configuration files would be helpful, so just write in a comments what to post and I will do it.
Thank you in advance.
UPDATE 1:
server.xml file:
<server description="new server">
<!-- Enable features -->
<featureManager>
<feature>localConnector-1.0</feature>
<feature>servlet-3.1</feature>
<feature>ejbLite-3.1</feature>
<feature>jndi-1.0</feature>
<feature>jaxrs-1.1</feature>
<feature>ssl-1.0</feature>
<feature>jpa-2.0</feature>
<feature>cdi-1.0</feature>
</featureManager>
<basicRegistry id="basic" realm="BasicRealm">
<!-- <user name="yourUserName" password="" /> -->
</basicRegistry>
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/>
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true"/>
<applicationMonitor updateTrigger="mbean"/>
<library id="DB2JCC4Lib">
<fileset dir="/Users/anatoly/developer/sql_drivers" includes="*.jar"/>
</library>
<dataSource id="db2_slc" jndiName="jdbc/BEADB" type="javax.sql.DataSource">
<jdbcDriver libraryRef="DB2JCC4Lib"/>
<properties.db2.jcc databaseName="beadb" password="********" portNumber="50000" serverName="db2server" user="db2username"/>
</dataSource>
<keyStore id="defaultKeyStore" password="******"/>
<enterpriseApplication id="BigEnterpriseAppEAR" location="BigEnterpriseAppEAR.ear" name="BigEnterpriseAppEAR"/>
</server>
persistence.xml file, located in BigEnterpriseAppJPA > src > META-INF > persistence.xml
in packaged EAR persistence.xml located in BigEnterpriseAppEAR -> BigEnterpriseAppJPA.jar -> META-INF -> persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="BigEnterpriseApp">
<jta-data-source>jdbc/BEADB</jta-data-source>
<class>com.bea.entities.System</class>
<class>com.bea.entities.Data</class>
<class>com.bea.entities.User</class>
<class>com.bea.entities.Group</class>
<properties>
<property name="openjpa.jdbc.Schema" value="BEADB" />
<property name="openjpa.ConnectionRetainMode" value="transaction" />
</properties>
</persistence-unit>
</persistence>
[ERROR ] CWWJP0012E: The persistence unit name is not specified and a unique persistence unit is not found in the BigEnterpriseAppEAR application and BigEnterpriseAppEJB.jar module.
This would imply your persistence.xml roots are not at the legal locations defined by the JPA spec, section 8.2:
In Java EE environments, the root of a persistence unit must be one of the following:
an EJB-JAR file
the WEB-INF/classes directory of a WAR file[87]
a jar file in the WEB-INF/lib directory of a WAR file
a jar file in the EAR library directory
an application client jar file
NOTE: Java Persistence 1.0 supported use of a jar file in the root of the EAR as the root of a
persistence unit. This use is no longer supported. Portable applications should use the EAR
library directory for this case instead
Your setup seems to be trying to use #4?
BigEnterpriseAppEAR -> BigEnterpriseAppJPA.jar -> META-INF -> persistence.xml
BigEnterpriseAppJPA.jar should be placed inside your EAR library directory. I believe this will be BigEnterpriseAppEAR/lib by default, but you can configure this with your /META-INF/application.xml in the EAR
Also note, that the persistence-unit name must be unique. Make sure that all persistence-unit names are not using the same name.

Wildfly 8.2 fails to load jbossws-cxf-client module

I am working on a web application that contains a Soap client and that needs to have access to the cxf Client implmentation, because we have to use different certificates for different calls to the remote endpoint.
Wildfly comes with a module jbossws-cxf-client which has dependencies to all the different cxf modules required. There is a maven version of this module as well.
In the maven module pom file we have a dependency like so:
<dependency>
<groupId>org.jboss.ws.cxf</groupId>
<artifactId>jbossws-cxf-client</artifactId>
<version>4.3.2.Final</version>
<scope>provided</scope>
</dependency>
Note that the version has been matched with the version that is mentioned in the wildfly 8.2 release notes:http://wildfly.org/news/2014/11/20/WildFly82-Final-Released/
When deploying our application we get the following message from the log:
14:22:12,492 INFO [org.jboss.weld.Bootstrap] (weld-worker-1) WELD-000119: Not generating any bean definitions from nl.topicuszorg.lsp.service.MultipleCertificatePingStubServiceImpl because of underlying class loading error: Type org.apache.cxf.transport.Conduit from [Module "deployment.kdplus-lsphub-server-1.1-SNAPSHOT.war:main" from Service Module Loader] not found. If this is unexpected, enable DEBUG logging to see the full error.
14:22:12,689 INFO [org.apache.deltaspike.core.util.ProjectStageProducer] (MSC service thread 1-2) Computed the following DeltaSpike ProjectStage: Production
14:22:13,628 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.deployment.unit."kdplus-lsphub-server-1.1-SNAPSHOT.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."kdplus-lsphub-server-1.1-SNAPSHOT.war".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_25]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_25]
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type PingStubService with qualifiers #Default
at injection point [BackedAnnotatedField] #Inject nl.topicuszorg.lsp.service.PingPongServiceImpl.pingStubService
at nl.topicuszorg.lsp.service.PingPongServiceImpl.pingStubService(PingPongServiceImpl.java:0)
The real problem is logged as INFO, strangely enough. org.apache.cxf.transport.Conduit can not be loaded. This is part of the org.apache.cxf module, and should be loaded transitively by loading the jbossws-cxf-client module.
It should not be necessary, but we also implicitely declare the module dependencies in the jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<excludes>
</excludes>
<dependencies>
<module name="org.slf4j"/>
<module name="org.apache.cxf"/>
<module name="jbossws-cxf-client"/>
<module name="org.apache.cxf.impl"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
It seems the module is not loaded, I don't know why. I can not find a way to check which modules have been loaded.
What is going wrong here?
As it turned out I had to move my jboss-deployment-structure.xml from the META-INF to the WEB-INF directory.
Bummer...

WebLogic 12.1.3 error WELD-001408 Unsatisfied dependencies

WebLogic 12.1.3 fails when deploying a web application with a simple CDI injection. The following exception is thrown:
weblogic.application.ModuleException: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Interface2] with qualifiers [#Default] at injection point [[field] #Inject public pruebas1.Clase1.clase2]
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace
Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001408 Unsatisfied dependencies for type [Interface2] with qualifiers [#Default] at injection point [[field] #Inject public pruebas1.Clase1.clase2]
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:315)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:284)
at org.jboss.weld.bootstrap.Validator.validateInjectionTarget(Validator.java:342)
at org.jboss.weld.manager.InjectionTargetValidator.addInjectionTarget(InjectionTargetValidator.java:29)
at org.jboss.weld.manager.BeanManagerImpl.createInjectionTarget(BeanManagerImpl.java:943)
Truncated. see log file for complete stacktrace
>
When i deploy the war in WebLogic 12.1.3 (Zip Distribution and Installers for Developers) inside OEPE 12.1.3.2 i get the error described. But, whith WebLogic 12.1.1 (Zip Distribution and Installers for Developers) inside the same OEPE 12.1.3.2 there is no problem. Neither there isn't problem if i export thye war file and deploy with the web console without OEPE integration. Additionally, when i deploy the war in WebLogic 12.1.3. standalone ("full" release) there is no problem.
I encountered too, that the MANIFEST.MF file (inside wlserver/server/lib/api.jar) references "javax.inject_1.jar" that doesn't exist in wlserver/modules folder. Instead there is the file "javax.inject-1.jar". To make my project working (import the class javax.inject.Inject class) i copied a file named javax.inject_1.jar from the javax.inject-1.jar file in the same folder.
The war java source structure is:
src
pruebas1
Clase1.java
pruebas2
Clase2.java
Interface2.java
The war WebContent structure is:
WebContent
WEB-INF
beans.xml
weblogix.xml
Classes and interface:
#WebService
public class Clase1 {
#Inject
public Interface2 clase2;
#WebMethod
public String aMayusculas(#WebParam(name = "palabra") String palabra) {
long tm = System.currentTimeMillis();
System.out.println(tm + " - clase2: " + (clase2 == null ? "null" : clase2.toString()));
return palabra == null ? "null" : tm + " - " + palabra.toUpperCase();
}
}
public interface Interface2 {
void doIt(String a);
}
public class Clase2 implements Interface2 {
#Override
public void doIt(String a) {
System.out.println(a);
}
}
XML files:
beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans 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/beans_1_0.xsd">
</beans>
weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" 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/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:weblogic-version>12.1.3</wls:weblogic-version>
<wls:context-root>prueba05weblogic</wls:context-root>
</wls:weblogic-web-app>
Thanks in advance.
Efren V.
The problem was resolved.
I created a SR in Oracle support site. Oracle built an internal patch.
Efren.
After three days searching, we found that the project only worked if deployed through the weblogic console, if we deployed through oracle plugin in eclipse it wont work.
So, if you are using eclipse, in the "servers" view, right click weblogic server, click "Properties -> Weblogic -> Publishing", change the radio "Pubish as a virtual application" to "Publish as exploded archive"
you can replace #Inject annotation with #Produces as workaround

Glassfish v3: Web application not finding JAR in the same EAR

I created a EAR application in Eclipse to run in Glassfish 3.1. The used projects are: BibliotecaEAR2 (the main EAR. 'Biblioteca' means 'Library'), BibliotecaEJB (with EJBs), BibliotecaModel (with entities and DAOs) and BibliotecaWeb (The Web application). The application.xml has this structure:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" id="Application_ID" version="6">
<display-name>BibliotecaEAR2</display-name>
<module>
<web>
<web-uri>BibliotecaWeb.war</web-uri>
<context-root>biblioteca</context-root>
</web>
</module>
<module>
<ejb>BibliotecaEJB.jar</ejb>
</module>
</application>
In BibliotecaWeb, the META-INF/MANIFEST.MF is written this:
Manifest-Version: 1.0
Class-Path: lib/google/guava-18.0.jar
// other JARs in BibliotecaEAR2 project
BibliotecaEJB.jar
When I start the glassfish I get this warning message:
2014-10-20T14:34:31.691-0200|WARNING: PWC6351: In TLD scanning, the supplied resource file:/C:/dev/glassfish3/glassfish/domains/biblioteca-glass3/eclipseApps/BibliotecaEAR2/BibliotecaEJB.jar does not exist
java.io.FileNotFoundException: C:\dev\glassfish3\glassfish\domains\biblioteca-glass3\eclipseApps\BibliotecaEAR2\BibliotecaEJB.jar (O sistema nao pode encontrar o arquivo especificado)
Although it does not stop me from running the application, I would like to eliminate it.
Googling for PWC6351 warning, I perceived that it happens when a used JAR is not found in the Manifest File. However the request JAR is not simply a external library, but a sub-project in same EAR. Is there any additional configuration that should I do?
Thanks,
Rafael Afonso
From Packaging libraries with EARs:
When packaging applications in an EAR file, the library JARs need to
be placed in the archive lib directory (jars at the archive root level
are not added to the classpath and thus available from other EAR
artifacts.)
The library jars placed in the "/lib" directory of the EAR (the
directory name can be overridden in application.xml) will be visible
to all sub-modules (JARs, WARs, and RARs) with no further
configuration. No need to add Class-Path entries in the EAR manifest.
In fact you don't need to reference the jars in the lib folder, and it looks like it will not work if you reference a jar on the EAR root level, like your BibliotecaEJB.jar.
If you don't have a real dependency from your WAR module classes to your EJB module classes you can just remove all the entries from the MANIFEST.MF and it should work.
If you instead have a real dependency from WAR to EJB, you may have to think about your project structure and if you really need an EAR. You can also package all the stuff into a single WAR.
The right way to use an EAR with WAR and EJB modules requires a little bit of work if your current WAR classes directly depend on classes from the EJB module:
1. Step
You have to create interfaces for all your "service" classes which should be available to classes in the web application (WAR).
Here is a simple example:
public interface FileService {
public void showFileInformation(File file);
}
and
#Stateless
#Local(FileService.class)
#Remote(FileService.class)
public class FileServiceImpl implements FileService {
#Override
public void showFileInformation(File file) {
// here
// is
// the
// real
// stuff
}
}
2. Step
The next step is to package all your new interfaces into a new jar. Your model jar looks similar to this approach. If this can't be used for this purpose, create a simple java application project which gets packaged as jar and put all the interfaces into this project. This jar has to be in the lib folder of the EAR.
BibliotecaEAR2
-- BibliotecaEJB
-- BibliotecaWeb
-- /lib/interfaces.jar
Then you have to add a dependency to this new jar in your WAR and EJB modules, so that they can find the interface classes.
3. Step
The services can be injected into the managed classes of your web applications (and into other service classes) like this:
#RequestScoped
public class FileHandler {
// make sure to use the interface
#EJB
FileService fileService;
}
Maybe you already have something similar to this, but then it should work without any entries in the MANIFEST.MF.
See also:
Maven2: Best practice for Enterprise Project (EAR file)
Java EE - EAR vs separate EJB+WAR
Packaging EJB in JavaEE 6 WAR vs EAR
I had a similar issue and solved by customizing module location, like this
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" id="Application_ID" version="6">
<display-name>BibliotecaEAR2</display-name>
<module>
<web>
<web-uri>BibliotecaWeb.war</web-uri>
<context-root>biblioteca</context-root>
</web>
</module>
<module>
<ejb>BibliotecaEJB.jar</ejb>
<bundleDir>/lib</bundleDir> <!-- ADD THIS OPTION TO THE MODULE -->
</module>
</application>
This solution is taken from the Maven EAR plugin documentation, which uses Maven 3 syntax, but I think you can use it too (or you can migrate to Maven 3).
Hope that helps.