Search This Blog

Thursday, 31 January 2008

Add edited file back into an archive WAR/EAR

Note for myself (Windows Example)

1. Extract WAR file

jar xf myapplication.war

2. Edit the file you wish to change
3. Place new updated file back into archive

jar uf myapplication.war WEB-INF\web.xml

Now the WAR file will have the updated web.xml with the changes I made at step 2. It's vital the updated file is in the same directory structure that the archive is expecting otherwise you will end up with another file with the same name in a different path which is not what I need.

Friday, 25 January 2008

Command Line Administration in OAS 10.1.3.x is very powerful

Today a customer asked me how they could stop an application on a remote OAS server which was part of cluster, but only using opmnctl command. I know it can be done wit admin_client.jar but they insisted they only wanted to use opmnctl. I wasn't sure if it was possible but found it was in the end.

Setup:

2 OAS 10.1.3.x installs, but only had access to one of them from the command line

eg:


Processes in Instance: 10132linux_pink.papicell-au2.au.oracle.com
---------------------------------+--------------------+---------+---------
ias-component | process-type | pid | status
---------------------------------+--------------------+---------+---------
ASG | ASG | N/A | Down
OC4JGroup:pas_group | OC4J:pas_oc4j | 28416 | Alive
OC4JGroup:default_group | OC4J:OC4J_WebCent~ | N/A | Down
OC4JGroup:default_group | OC4J:home | 16758 | Alive
HTTP_Server | HTTP_Server | 19568 | Alive

Processes in Instance: 10132linux_green.papicell-au2.au.oracle.com
---------------------------------+--------------------+---------+---------
ias-component | process-type | pid | status
---------------------------------+--------------------+---------+---------
ASG | ASG | N/A | Down
OC4JGroup:default_group | OC4J:OC4J_WebCent~ | N/A | Down
OC4JGroup:default_group | OC4J:home | 30049 | Alive


In this case we only have access to the oracle_home "10132linux_green". The requirement was to shutdown ascontrol remotely on the instance "10132linux_pink". With opmnctl this is easily done as long as the instances are clustered together it's a command as simple as this, where we specify exactly which instance to execute the command on.

- opmnctl @instance:10132linux_pink.papicell-au2.au.oracle.com stopproc process-type=home application=ascontrol

To then restart it when it needs to be running again remotely we use a command as follows

- opmnctl @instance:10132linux_pink.papicell-au2.au.oracle.com startproc process-type=home application=ascontrol

The process-type switch ensures we only stop/start the application on a specific OC4J instance which for ascontrol is vital as we only need it running on one node within the cluster.

Thursday, 24 January 2008

Precompiling JSP's within an EAR file using OJSPC

You can precompile JSP files to avoid the hassle of compiling the JSP on it's first request into a servlet class file at runtime prior to deployment using "ojspc". The key is how to check that it has indeed done that. His an example:

Step 1: verify EAR file
- jar -tvf jspcompile.ear
       487 Thu Jan 24 11:26:22 EST 2008 META-INF/application.xml
226 Thu Jan 24 11:26:12 EST 2008 META-INF/orion-application.xml
2066 Thu Jan 24 11:26:22 EST 2008 jspcompile.war
Step 2: Compile using ojspc
- ojspc jspcompile.ear
    Detected archive, now processing contents of jspcompile.ear...
Setting up temp area...
Expanding archive in temp area...
Detected archive, now processing contents of /tmp/tmp56123/jspcompile.war...
Setting up temp area...
Expanding archive in temp area...
Creating /tmp/tmp56123/jspcompile.war ...
Removing temp area...
Creating /u01/pas/tars/sr/jspcompile.ear ...

Removing temp area...
Step 3: Verify compiled JSP JAR file is present within WEB-INF\lib

Extract EAR file
jar -xvf jspcompile.ear
     inflated: META-INF/application.xml
inflated: META-INF/orion-application.xml
inflated: jspcompile.war
Extract WAR File
jar -xvf jspcompile.war
     inflated: Page1.jsp
inflated: Page2.jsp
inflated: WEB-INF/classes/META-INF/orion-application.xml
inflated: WEB-INF/web.xml
inflated: WEB-INF/lib/__oracle_jsp_jspcompile.jar

As you can see OJSPC has created a file called "__oracle_jsp_jspcompile.jar" with the precompiled JSP source files ready to be run. More info on this is in the online documentation for OAS 10.1.3.x

http://download.oracle.com/docs/cd/B31017_01/web.1013/b28961/ojspc.htm#sthref209
Precompiling JSPs within a WAR File

Thursday, 3 January 2008

ORA-1403 not being returned through SQLException when thrown by database

Today I observed that when an ORA-1403 was thrown from the database as a result of calling a stored procedure from JDBC it was not returned as a SQLException and was ignored by the JDBC driver. His what happened and how I got around it.

Create a table as follows:


create table t1 (c1 number(6));

insert into t1 values (1);

commit;


Create a stored procedure as follows:


create or replace procedure p(v IN INTEGER) as
r integer;
begin
select c1 into r from t1 where c1 = v;
dbms_output.put_line('r = '||r);

-- Some stuff that would normally happen afterward...
insert into t1 (c1) values (r+1);
end;
/


Now in a SQLPlus do the following to see that a ORA-1403 is thrown when the value 2 is passed to the procedure.

TARS@lnx102> exec p(2);
BEGIN p(2); END;

*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "TARS.P", line 4
ORA-06512: at line 1

TARS@lnx102>

From that your would expect the exact same call in a JDBC program to thrown the same exception but when called as follows it failed and silently ignored the ORA-1403.
String sql = "call p(?)";

However the problem can easily be avoided by using the following SQL from the JDBC program. Both these SQL calls will give the ORA-1403 as expected. You need to ensure the curly braces are added when using CALL, of course thats not required when using oracle style sytnax as shown below.

      String sql = "{call p(?)}";

OR

String sql = "begin p(?); end;";