I recently had a big problem working with
Oracle Application Server 10.1.3 at work. We are developing a web application based on spring and hibernate. The application was only an Eclipse project, and I thought that it was a mistake because we were mixing in a single project business layer, controller, view, and data acces. So, I thought splitting the project in some little ones, would be a great deal:
- Model: a project containing domain code, in our case, hibernate entities.
- DAO: Data acces objects.
- DTO: Data transfer objects.
- Util: util classes.
- Service: Business code.
- Web: Web app, controllers and configuration files (application context, hibernate maps, etc...)
To do this, I created a modular project with maven
. But when I tried to deploy to oc4j I got a
ClassNotFoundException from Spring application context.
I didn't understood why, because my jars where present in my app lib folder. So, I went to OC4J console to test if my jars were loaded by the classloader. Them were not present.
Why isn't oc4j loading my jars? Third party libraries, like spring and hibernate, were loaded, so I asked myself: Which is the difference between that ones and my own jars? So I opened a spring jar, and I found that it had a complete manifest.mf file. I thought this could be the problem, and reading oc4j documentation, I confirmed that. We have to create a
MANIFEST.MF for each jar. So I created a manifest file in
src/main/META-INF/MANIFEST.MF in each project home:
Extension-Name: com.yourcompany.yourpackage
Specification-Title:
Specification-Version:
Specification-Vendor:
Implementation-Version:
Implementation-Vendor-Id: com.yourcompany.yourpackage
Implementation-Vendor:
Implementation-Title:
Obviously, you have to fill-in the file with the appropiate values. The second step is including our manifest.mf file in maven's build:
Now, the next time you run
mvn package your
manifest.mf will be included in your jar
and oc4j classloader will load your own jars.
No hay comentarios:
Publicar un comentario