Tuesday, 9 July 2013

Deploying JAR as a shared library

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

Thursday, 4 July 2013

My Tryst with SOA

For a long time I have been trying to learn SOA but to no avail.

I go through several documents but they are more of a bouncer.

So I thought lets do it the regular way starting with Installation.

So this post covers my issues with SOA.

Prerequisite

1> Download Oracle Weblogic Server ( :) I already had it installed)

2> A database (I already have an Oracle XE database installed)

XE database is not supported but then I am sure it will work for a development environment for testing purpose

3> RCU.

All available for download from OTN (Oracle technology Network).

The document is going to cover several issues that I faced on the install.

Starting with creating an RCU on oracle XE database.
While Installing the RCU on Oracle XE Database.

The first problem that I faced is creating a SYSDBA user I tried using SYS but it would just not connect.

I know many of you folks out there are experienced DBA’s and you might laugh out on my knowledge but then I am from the middle ware team.
So, out of several things that I tried was using the apex GUI but could not get around it.

So I was back to the usual SQL Plus using SQL J.




So now I have a user named user1 which is a SYSDBA.

I though I could go ahead with it but turns out I was wrong.

I got two of the below errors.

ERROR rcu: oracle.sysman.assistants.rcu.backend.action.AbstractAction::handleNonIgnorableError: Received Non-Ignorable Error: Error creating PL/SQL Object WRITE_LINE:PROCEDURE

ERROR rcu: oracle.sysman.assistants.rcu.backend.action.AbstractAction::handleNonIgnorableError: Received Non-Ignorable Error: Error creating PL/SQL Object DEBUG_PURGE:PROCEDURE

This was resolved after assistance from the blogpost


And the solution is to
1>     grant execute on sys.dbms_lock to user1 with grant option

2>     set the Environment variable
RCU_JDBC_TRIM_BLOCKS to TRUE

For Windows set it through
a>     right click on My Computer -> Properties -> Click On Advanced
b>    Click on Environment Variables towards the bottom
c>     Then in System Variables add in new
There is an easier way of doing it.
Instead of double clicking the rcu.bat open a command prompt and then run the below
set RCU_JDBC_TRIM_BLOCKS = TRUE

After this cd to the RCU directory and execute rcu.bat

After this installing RCU was pretty much a cake walk just with certain messages like below







And yes, you will have to remove certain components but then that is ok because all we want is SOA.



 So remove Oracle Identity Manager, Oracl Adaptive Access Manager, Spaces and Service, portal

For the custom variables screen this oracle document was very important




Then Click Next, Next Next and then finally you get the success screen