Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Referring shared Java EE library for EAR application in weblogic

Tags:

java

weblogic

I have created a shared library with some jar files in weblogic server, now I have an EAR application and I want to use the class files from shared library in my web applications present in EAR application. So I have created weblogic-application.xml file inside my ear-app/META-INF/ directory and gave reference to shared library using below tags:

<library-ref>
    <library-name>ebs_endeca_artifacts</library-name>
</library-ref>

But when I am trying to access the class files in my application, I am getting exception java.lang.ClassNotFoundException

Also it is required for me to refer to the shared library at ear level instead of declaring in weblogic.xml file of individual war files.

If I directly place the same jar files in my ear-app/APP-INF/lib directory instead of using shared library then my application is working fine without any issues.

Please help me how can I use the shared library in my ear application. I am using weblogic server 10.3.6

My shared library structure will be like this:

shared-web-app/WEB-INF/web.xml
shared-web-app/WEB-INF/lib/*.jar
like image 258
chaitanya Avatar asked May 21 '13 13:05

chaitanya


1 Answers

You need the jars from the shared library in your classpath, because before you deploy the EAR, the application needs to be built. JDeveloper wouldn't know where are those classes stored, so that it need those at compile-time.

When preparing the application for deployment, you can create filters for the files that can be added within the WAR/EAR/<whatever>. Go to Application Properties -> Deployment and select your deployment profile. Click on the Edit button and a screen will be prompted, from where you can filter the files/libraries that can be included when the application is built.

If you don't include the shared library in the archive and have the fragment from the weblogic-application.xml you've posted, the WebLogic server will then use the classes from the shared library.

Hope that helps. Ask anything you don't understand as a comment. :)

like image 148
Konstantin Yovkov Avatar answered Oct 21 '22 11:10

Konstantin Yovkov