Deploying a JAR as shared library and accessing it from a Web Application.
I am on this project which requries me
1> Deploy a JAR file as a library
2> Deploy a .war application which references this library.
Simple right! wrong it actually took me 6-8 hours to figure out that it will not work.
So below are the general steps that you would do.
1> Creating a .jar library
create a folder for e.g. library and then create a sub folder
library/META-INF
and create files
library/META-INF/MANIFEST.MF
in the MANIFEST have the below attributes
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 19.1-b02 (Sun Microsystems Inc.)
Implementation-Vendor: Oracle
Implementation-Title: Test
Implementation-Version: 1.0
Product-Name: Test
Specification-Version: 1.0
Extension-Name: Test
In the above files some/most of them are optional
see link http://docs.oracle.com/cd/E17904_01/web.1111/e13706/libraries.htm#i1070938
then copy the class files or packages to the library directory
from the library directory execute the below (M adds the manifest already created so that it does not create a defaul manifest)
jar -cvfM Test.jar *
so this gives us a jar file Test.jar
Deploy this to through the Administration console (http://docs.oracle.com/cd/E17904_01/apirefs.1111/e13952/taskhelp/library/DeployLibrary.html) or use the below syntax for wldeploy
java weblogic.Deployer -adminurl t3://localhost:7001 -username weblogic -password @Kka110480 -deploy -library D:\\Application\\shared\\library\\Test.jar
The above will deploy the library to the AdminServer
To deploy it to another server or cluster use -target option and specify server name seperated by commas.
Additionaly use -libspecver 1.0 -libimplver 2.0
libspecver to specify specification version if not specified in manifest
libimplver to specify implementation version if not specified in manifest.
So my library is installed and I am ready to deploy the application.
In the application WAR file I have the weblogic.xml have the below configuration
<library-ref>
<library-name>Test</library-name>
<specification-version>1.0</specification-version>
<implementation-version>1.0</implementation-version>
</library-ref>
However while deploying I would always get this error
Caused By: weblogic.management.DeploymentException: Error: Unresolved Webapp Library references for "ServletContext@XXXXX[app:XXXX module:XXXX.war path:/XXXX spec-version:2.5]", defined in weblogic.xml [Extension-Name: Test, Specification-Version: 1, Implementation-Version: 1.0, exact-match: false]
at weblogic.servlet.internal.WebAppServletContext.processWebAppLibraries(WebAppServletContext.java:2754)
at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:415)
at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:493)
at weblogic.servlet.internal.HttpServer.loadWebApp(HttpServer.java:418)
at weblogic.servlet.internal.WebAppModule.registerWebApp(WebAppModule.java:972)
at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:382)
at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:517)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
And all the documents you would search on the interbet would tell you that the library is not deployed or not active.
But my library is deployed and active .(I tried re-starting a couple of times).
So I went back to basics reading the documentation.
And finally found what I was looking for EJB, Enterprise applications or JAR files deployed as shared libraries cannot be referenced from weblogic.xml they have to be referenced from weblogic-application.xml
So the above would mean that I can use a shared library in a WAR file.
So then why do we have this library-ref tag in weblogic.xml well that is becuase you can refernce WAR libraries from it. Huh!
So below are the options we have incase we want to use JAR's as shared libraries
1> Reference it from EAR file weblogic-application.xml
2> Use optional packages very clearly explained in the below link
http://middlewaremagic.com/weblogic/?p=231
I am on this project which requries me
1> Deploy a JAR file as a library
2> Deploy a .war application which references this library.
Simple right! wrong it actually took me 6-8 hours to figure out that it will not work.
So below are the general steps that you would do.
1> Creating a .jar library
create a folder for e.g. library and then create a sub folder
library/META-INF
and create files
library/META-INF/MANIFEST.MF
in the MANIFEST have the below attributes
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 19.1-b02 (Sun Microsystems Inc.)
Implementation-Vendor: Oracle
Implementation-Title: Test
Implementation-Version: 1.0
Product-Name: Test
Specification-Version: 1.0
Extension-Name: Test
In the above files some/most of them are optional
see link http://docs.oracle.com/cd/E17904_01/web.1111/e13706/libraries.htm#i1070938
then copy the class files or packages to the library directory
from the library directory execute the below (M adds the manifest already created so that it does not create a defaul manifest)
jar -cvfM Test.jar *
so this gives us a jar file Test.jar
Deploy this to through the Administration console (http://docs.oracle.com/cd/E17904_01/apirefs.1111/e13952/taskhelp/library/DeployLibrary.html) or use the below syntax for wldeploy
java weblogic.Deployer -adminurl t3://localhost:7001 -username weblogic -password @Kka110480 -deploy -library D:\\Application\\shared\\library\\Test.jar
The above will deploy the library to the AdminServer
To deploy it to another server or cluster use -target option and specify server name seperated by commas.
Additionaly use -libspecver 1.0 -libimplver 2.0
libspecver to specify specification version if not specified in manifest
libimplver to specify implementation version if not specified in manifest.
So my library is installed and I am ready to deploy the application.
In the application WAR file I have the weblogic.xml have the below configuration
<library-ref>
<library-name>Test</library-name>
<specification-version>1.0</specification-version>
<implementation-version>1.0</implementation-version>
</library-ref>
However while deploying I would always get this error
Caused By: weblogic.management.DeploymentException: Error: Unresolved Webapp Library references for "ServletContext@XXXXX[app:XXXX module:XXXX.war path:/XXXX spec-version:2.5]", defined in weblogic.xml [Extension-Name: Test, Specification-Version: 1, Implementation-Version: 1.0, exact-match: false]
at weblogic.servlet.internal.WebAppServletContext.processWebAppLibraries(WebAppServletContext.java:2754)
at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:415)
at weblogic.servlet.internal.WebAppServletContext.<init>(WebAppServletContext.java:493)
at weblogic.servlet.internal.HttpServer.loadWebApp(HttpServer.java:418)
at weblogic.servlet.internal.WebAppModule.registerWebApp(WebAppModule.java:972)
at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:382)
at weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:517)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
And all the documents you would search on the interbet would tell you that the library is not deployed or not active.
But my library is deployed and active .(I tried re-starting a couple of times).
So I went back to basics reading the documentation.
And finally found what I was looking for EJB, Enterprise applications or JAR files deployed as shared libraries cannot be referenced from weblogic.xml they have to be referenced from weblogic-application.xml
So the above would mean that I can use a shared library in a WAR file.
So then why do we have this library-ref tag in weblogic.xml well that is becuase you can refernce WAR libraries from it. Huh!
So below are the options we have incase we want to use JAR's as shared libraries
1> Reference it from EAR file weblogic-application.xml
2> Use optional packages very clearly explained in the below link
http://middlewaremagic.com/weblogic/?p=231