|
Home > Archive > EAserver > November 2005 > Unchecked Exceptions question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Unchecked Exceptions question
|
|
| Marty Jones 2005-11-22, 1:24 pm |
| Is there a way to create an exception that extends
org.omg.CORBA.SystemException that can be thrown from a POJO component and
actually caught on the client side as this exception instead of a
CORBA.Unknown?
Here is what I have attempted.
1. created a new class called DataException, it extends
org.omg.CORBA.SystemException. I placed this class within the java/classes
folder and also put the class in a jar file for use by the client.
2. created a test POJO java component that raises the DataException
exception.
3. created a Java client that calls the test component.
I see in the Jaguar log that my DataException is being raised but the client
never sees it, it only sees it as an CORBA.UnknownException.
Am I missing something or is this not possible?
Any help would be greatly appreciated.
Marty
| |
| a friend 2005-11-23, 7:24 am |
| You are trying to implement an Abstract clases, you can't do
that, check this documentation:
http://java.sun.com/j2se/1.4.2/docs...mException.html
Use any of the implemented clases.
> Is there a way to create an exception that extends
> org.omg.CORBA.SystemException that can be thrown from a
> POJO component and actually caught on the client side as
> this exception instead of a CORBA.Unknown?
>
> Here is what I have attempted.
>
> 1. created a new class called DataException, it extends
> org.omg.CORBA.SystemException. I placed this class within
> the java/classes folder and also put the class in a jar
> file for use by the client.
>
> 2. created a test POJO java component that raises the
> DataException exception.
>
> 3. created a Java client that calls the test component.
>
> I see in the Jaguar log that my DataException is being
> raised but the client never sees it, it only sees it as
> an CORBA.UnknownException.
>
>
> Am I missing something or is this not possible?
>
> Any help would be greatly appreciated.
>
> Marty
>
>
| |
| Marty Jones 2005-11-23, 9:31 am |
| I totally agree that I can instantiate an abstract class. That was not my
question though. I was trying to implement my own class that extended the
SystemException class. I have since found out that this is not possible
currently.
<a friend> wrote in message news:4384078e.5aeb.1681692777@sybase.com...[color=darkred]
> You are trying to implement an Abstract clases, you can't do
> that, check this documentation:
>
> http://java.sun.com/j2se/1.4.2/docs...mException.html
>
> Use any of the implemented clases.
>
| |
| A Friend 2005-11-23, 1:34 pm |
| Ok Marty, I prepared an example for you, because your
explanation is not easy.
First, there are a problem with the IDL Compiler embedded in
EAServer, so you have to change a line in the IDL
Repository.
Well, Now I know that you know how create the class, but I
will put a sample code here:
This is MyError Class, extends
org.omg.CORBA.SystemException, as you want:
----------------------------------------------------------------------------------------------------
package org.omg.CORBA;
public final class MyError
extends org.omg.CORBA.SystemException
{
public MyError()
{
super( "", 0,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
}
public MyError(String reason)
{
super( reason, 0,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
}
public MyError(int minor, org.omg.CORBA.CompletionStatus
completed)
{
super( "", minor, completed);
}
public MyError(String reason, int minor,
org.omg.CORBA.CompletionStatus completed)
{
super( reason, minor, completed);
}
}
----------------------------------------------------------------------------------------------------
Now we will create our component throwing our MyException
Class:
----------------------------------------------------------------------------------------------------
package code.testException;
import org.omg.CORBA.*;
import java.util.*;
import java.lang.Object;
public class testNewsImpl
{
public void myMethod() throws org.omg.CORBA.MyError
{
throw new
org.omg.CORBA.MyError("TestException/testNews myMethod");
}
}
----------------------------------------------------------------------------------------------------
We are going to deploy this Component in a Packge, I named
TestException. Just to be sure, do right click in the
TestException Package, =93New Component=85=94 =93Import
from Java File=94 , I put this values, you can changed,
Component Name: testNews, Class name (Depend on the package
and the class name): code.testException.testNewsImpl
Deploy and wait for the messages =93All Methods Imported=94,
very important.
Now come your probably problem, if you check my code, I=92m
just using an String just to build my MyError messages.
Go to JagMgr (is easier than use props files), Go to IDL
edit org.omg.CORBA.MyError (each time than you deploy your
component, this definition will be reinitialized again ) You
can see something like this:
----------------------------------------------------------------------------------------------------
exception MyError
{
long minor;
::CORBA::CompletionS
tatus completed;
org.omg.CORBA.MyError value;
};
----------------------------------------------------------------------------------------------------
Change it by this
----------------------------------------------------------------------------------------------------
exception MyError
{
string message;
};
----------------------------------------------------------------------------------------------------
Now you can generated your Stubbs and Skeletons with NO
error messages.
I put here an JSP Code in wich you can see How I capture my
MyError exception:
----------------------------------------------------------------------------------------------------
<%@ page contentType=3d"text/html; charset=3dUTF-8"
pageEncoding=3d"UTF-8" %>
<%@ page import=3d"java.io.*,java.util.*" %>
<%@ page import=3d"code.testException.*" %>
<%!
public code.testException.testNews lookup()
{
try {
java.util.Properties p =3d new java.util.Properties();
p.put("org.omg.CORBA.ORBClass","com.sybase.CORBA.ORB");
org.omg.CORBA.ORB orb =3d
org.omg.CORBA.ORB.init((String[])null,p);
SessionManager.Manager manager =3d
SessionManager.ManagerHelper.narrow(orb.string_to_object("iiop://alexander:9000"));
SessionManager.Session session =3d
manager.createSession("jagadmin","");
javax.naming.InitialContext initialContext =3d new
javax.naming.InitialContext(p);
code.testException.testNews _object =3d
code.testException.testNewsHelper.narrow(session.create("TestException/testNews"));
return _object;
} catch (Exception e)
{
System.out.println(e.toString());
return null;
}
}
%>
<%
try {
code.testException.testNews search_criteriaObjec
t =3d
lookup();
search_criteriaObjec
t.myMethod();
} catch (org.omg.CORBA.MyError me) {
System.out.println("MyException Message:" +
me.getMessage());
}
catch (Exception e) {
System.out.println("General Exception Message:" +
e.getMessage());
System.out.println(e.toString());
}
%>
----------------------------------------------------------------------------------------------------
You can see this messages in my Log:
Nov 23 11:21:17 2005: [Thread-11] MyException
Message:TestExceptio
n/testNews myMethod
Enjoy your code
It was a pleasure help you
Regards
A friend
> I totally agree that I can instantiate an abstract class.
> That was not my question though. I was trying to
> implement my own class that extended the SystemException
> class. I have since found out that this is not possible
> currently.
>
>
> <a friend> wrote in message
> that, check this documentation: >
>
http://java.sun.com/j2se/1.4.2/docs...mException.html
> as >> this exception instead of a CORBA.Unknown?
> within >> the java/classes folder and also put the class
> in a jar >> file for use by the client.
> as >> an CORBA.UnknownException.
>
>
| |
| Marty Jones 2005-11-28, 7:25 am |
| I have an example that is very similar to yours. The issue I have is that
since I created the exception that extends org.omg.CORBA.SystemException, it
is an unchecked exception and I don't declare it in my IDL definition of the
compoent that calls it like you do. That is the whole point of an unchecked
exception. I may be misunderstanding your example but it looks like you
defined in your testNewsImpl component to throw org.omg.CORBA.MyError. I
shouldn't have to do that since it is a runtime exception and is unchecked.
I could easily just create a IDL exception definition and throw it but it is
then a checked exception and that is not what I am looking for. What I was
looking for is to be able to extend the current set of runtime exceptions
that are currently offered in Jaguar. I got word back from Evan Ireland
that this is currently not possible.
Thanks for all the help though, :)
Marty
<A Friend> wrote in message news:4384aaff.70a6.1681692777@sybase.com...
Ok Marty, I prepared an example for you, because your
explanation is not easy.
First, there are a problem with the IDL Compiler embedded in
EAServer, so you have to change a line in the IDL
Repository.
Well, Now I know that you know how create the class, but I
will put a sample code here:
This is MyError Class, extends
org.omg.CORBA.SystemException, as you want:
----------------------------------------------------------------------------------------------------
package org.omg.CORBA;
public final class MyError
extends org.omg.CORBA.SystemException
{
public MyError()
{
super( "", 0,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
}
public MyError(String reason)
{
super( reason, 0,
org.omg.CORBA.CompletionStatus.COMPLETED_NO);
}
public MyError(int minor, org.omg.CORBA.CompletionStatus
completed)
{
super( "", minor, completed);
}
public MyError(String reason, int minor,
org.omg.CORBA.CompletionStatus completed)
{
super( reason, minor, completed);
}
}
----------------------------------------------------------------------------------------------------
Now we will create our component throwing our MyException
Class:
----------------------------------------------------------------------------------------------------
package code.testException;
import org.omg.CORBA.*;
import java.util.*;
import java.lang.Object;
public class testNewsImpl
{
public void myMethod() throws org.omg.CORBA.MyError
{
throw new
org.omg.CORBA.MyError("TestException/testNews myMethod");
}
}
----------------------------------------------------------------------------------------------------
We are going to deploy this Component in a Packge, I named
TestException. Just to be sure, do right click in the
TestException Package, "New Component." "Import
from Java File" , I put this values, you can changed,
Component Name: testNews, Class name (Depend on the package
and the class name): code.testException.testNewsImpl
Deploy and wait for the messages "All Methods Imported",
very important.
Now come your probably problem, if you check my code, I'm
just using an String just to build my MyError messages.
Go to JagMgr (is easier than use props files), Go to IDL
edit org.omg.CORBA.MyError (each time than you deploy your
component, this definition will be reinitialized again ) You
can see something like this:
----------------------------------------------------------------------------------------------------
exception MyError
{
long minor;
::CORBA::CompletionS
tatus completed;
org.omg.CORBA.MyError value;
};
----------------------------------------------------------------------------------------------------
Change it by this
----------------------------------------------------------------------------------------------------
exception MyError
{
string message;
};
----------------------------------------------------------------------------------------------------
Now you can generated your Stubbs and Skeletons with NO
error messages.
I put here an JSP Code in wich you can see How I capture my
MyError exception:
----------------------------------------------------------------------------------------------------
<%@ page contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ page import="java.io.*,java.util.*" %>
<%@ page import="code.testException.*" %>
<%!
public code.testException.testNews lookup()
{
try {
java.util.Properties p = new java.util.Properties();
p.put("org.omg.CORBA.ORBClass","com.sybase.CORBA.ORB");
org.omg.CORBA.ORB orb =
org.omg.CORBA.ORB.init((String[])null,p);
SessionManager.Manager manager =
SessionManager.ManagerHelper.narrow(orb.string_to_object("iiop://alexander:9000"));
SessionManager.Session session =
manager.createSession("jagadmin","");
javax.naming.InitialContext initialContext = new
javax.naming.InitialContext(p);
code.testException.testNews _object =
code.testException.testNewsHelper.narrow(session.create("TestException/testNews"));
return _object;
} catch (Exception e)
{
System.out.println(e.toString());
return null;
}
}
%>
<%
try {
code.testException.testNews search_criteriaObjec
t =
lookup();
search_criteriaObjec
t.myMethod();
} catch (org.omg.CORBA.MyError me) {
System.out.println("MyException Message:" +
me.getMessage());
}
catch (Exception e) {
System.out.println("General Exception Message:" +
e.getMessage());
System.out.println(e.toString());
}
%>
----------------------------------------------------------------------------------------------------
You can see this messages in my Log:
Nov 23 11:21:17 2005: [Thread-11] MyException
Message:TestExceptio
n/testNews myMethod
Enjoy your code
It was a pleasure help you
Regards
A friend
> I totally agree that I can instantiate an abstract class.
> That was not my question though. I was trying to
> implement my own class that extended the SystemException
> class. I have since found out that this is not possible
> currently.
>
>
> <a friend> wrote in message
> that, check this documentation: >
>
http://java.sun.com/j2se/1.4.2/docs...mException.html
> as >> this exception instead of a CORBA.Unknown?
> within >> the java/classes folder and also put the class
> in a jar >> file for use by the client.
> as >> an CORBA.UnknownException.
>
>
| |
| A Friend 2005-11-29, 3:24 am |
| I'm not creating an IDL definition, I just fixed the
problem. When you deploy whatever component is mandatory
have an IDL definition with all the information of the
component. That information is putted in the EAServer by the
IDL compiler.
I extends from org.omg.CORBA.SystemException exactly like
your need. If you are not using a JavaComponent doesn't
care, the EJB technologies uses the same IDL definition.
If you want send me a part of your problem I will solve it,
just give me a time because I'm a bit busy these days.
I'm sure that is just a problem in the IDL compiler, and it
has an easy solution (modify the IDL definition generated by
the IDL compiler)
And excuse me but I don't know many names in the aerea, but
still is a pleasure help you in whatever thing that you
need.
Best Regards
A friend
> I have an example that is very similar to yours. The
> issue I have is that since I created the exception that
> extends org.omg.CORBA.SystemException, it is an unchecked
> exception and I don't declare it in my IDL definition of
> the compoent that calls it like you do. That is the
> whole point of an unchecked exception. I may be
> misunderstanding your example but it looks like you
> defined in your testNewsImpl component to throw
> org.omg.CORBA.MyError. I shouldn't have to do that since
> it is a runtime exception and is unchecked. I could
> easily just create a IDL exception definition and throw it
> but it is then a checked exception and that is not what I
> am looking for. What I was looking for is to be able to
> extend the current set of runtime exceptions that are
> currently offered in Jaguar. I got word back from Evan
> Ireland that this is currently not possible.
>
> Thanks for all the help though, :)
>
> Marty
>
>
>
>
> <A Friend> wrote in message
> news:4384aaff.70a6.1681692777@sybase.com... Ok Marty, I
> prepared an example for you, because your explanation is
> not easy.
>
> First, there are a problem with the IDL Compiler embedded
> in EAServer, so you have to change a line in the IDL
> Repository.
>
> Well, Now I know that you know how create the class, but I
> will put a sample code here:
>
> This is MyError Class, extends
> org.omg.CORBA.SystemException, as you want:
> ----------------------------------------------------------
> ------------------------------------------ package
> org.omg.CORBA; public final class MyError
> extends org.omg.CORBA.SystemException
> {
> public MyError()
> {
> super( "", 0,
> org.omg.CORBA.CompletionStatus.COMPLETED_NO);
> }
>
> public MyError(String reason)
> {
> super( reason, 0,
> org.omg.CORBA.CompletionStatus.COMPLETED_NO);
> }
>
> public MyError(int minor, org.omg.CORBA.CompletionStatus
> completed)
> {
> super( "", minor, completed);
> }
>
> public MyError(String reason, int minor,
> org.omg.CORBA.CompletionStatus completed)
> {
> super( reason, minor, completed);
> }
>
> }
> ----------------------------------------------------------
> ------------------------------------------
>
> Now we will create our component throwing our MyException
> Class:
>
> ----------------------------------------------------------
> ------------------------------------------ package
> code.testException;
>
> import org.omg.CORBA.*;
> import java.util.*;
> import java.lang.Object;
>
> public class testNewsImpl
> {
> public void myMethod() throws org.omg.CORBA.MyError
> {
> throw new
> org.omg.CORBA.MyError("TestException/testNews myMethod");
> }
> }
> ----------------------------------------------------------
> ------------------------------------------
>
> We are going to deploy this Component in a Packge, I named
> TestException. Just to be sure, do right click in the
> TestException Package, "New Component." "Import
> from Java File" , I put this values, you can changed,
> Component Name: testNews, Class name (Depend on the
> package and the class name):
> code.testException.testNewsImpl
>
> Deploy and wait for the messages "All Methods Imported",
> very important.
>
> Now come your probably problem, if you check my code, I'm
> just using an String just to build my MyError messages.
>
> Go to JagMgr (is easier than use props files), Go to IDL
> edit org.omg.CORBA.MyError (each time than you deploy your
> component, this definition will be reinitialized again )
> You can see something like this:
>
> ----------------------------------------------------------
> ------------------------------------------ exception
> MyError {
> long minor;
> ::CORBA::CompletionS
tatus completed;
> org.omg.CORBA.MyError value;
> };
> ----------------------------------------------------------
> ------------------------------------------
>
>
> Change it by this
> ----------------------------------------------------------
> ------------------------------------------ exception
> MyError {
> string message;
> };
> ----------------------------------------------------------
> ------------------------------------------
>
> Now you can generated your Stubbs and Skeletons with NO
> error messages.
>
> I put here an JSP Code in wich you can see How I capture
> my MyError exception:
> ----------------------------------------------------------
> ------------------------------------------ <%@ page
> contentType="text/html; charset=UTF-8"
> pageEncoding="UTF-8" %> <%@ page import="java.io.*
> ,java.util.*" %> <%@ page import="code.testException.*"
> %> <%!
> public code.testException.testNews lookup()
> {
> try {
> java.util.Properties p = new java.util.Properties();
> p.put("org.omg.CORBA.ORBClass","com.sybase.CORBA.ORB");
> org.omg.CORBA.ORB orb =
> org.omg.CORBA.ORB.init((String[])null,p);
> SessionManager.Manager manager =
> SessionManager.ManagerHelper.narrow(orb.string_to_object("
> iiop://alexander:9000")); SessionManager.Session session =
> manager.createSession("jagadmin","");
> javax.naming.InitialContext initialContext = new
> javax.naming.InitialContext(p);
>
> code.testException.testNews _object =
> code.testException.testNewsHelper.narrow(session.create("T
> estException/testNews"));
>
> return _object;
> } catch (Exception e)
> {
> System.out.println(e.toString());
> return null;
> }
> }
> %>
>
> <%
> try {
> code.testException.testNews search_criteriaObjec
t =
> lookup();
> search_criteriaObjec
t.myMethod();
> } catch (org.omg.CORBA.MyError me) {
> System.out.println("MyException Message:" +
> me.getMessage());
> }
> catch (Exception e) {
> System.out.println("General Exception Message:" +
> e.getMessage());
> System.out.println(e.toString());
> }
> %>
> ----------------------------------------------------------
> ------------------------------------------
>
>
> You can see this messages in my Log:
> Nov 23 11:21:17 2005: [Thread-11] MyException
> Message:TestExceptio
n/testNews myMethod
>
> Enjoy your code
> It was a pleasure help you
> Regards
> A friend
>
>
>
http://java.sun.com/j2se/1.4.2/docs...mException.html
>
>
|
|
|
|
|