Hi Miro,
Thank you very much for your contribution.
I incorporate it in our current version of JOnAS.
Kind regards.
Hélène.
"Halas, Miroslav" wrote:
>
> I have fixed the bug in GenIC so here is the fix:
>
> 370: src.println("if (rs.next() == false) {");
> 371: src.indentPlus();
> src.println("TraceEjb.error(\"Object not found in database ("+
> method.getName()+")\");");
> src.println("throw new ObjectNotFoundException(\"Object not found in
> database ("+
> method.getName()+")\");");
> src.indentMinus();
> src.println("}");
> src.indentMinus();
> // BEGIN MHALAS:
> src.println("} catch (ObjectNotFoundException oe) {");
> src.println("throw oe;");
> // END MHALAS
> src.println("} catch (Exception e) {");
> src.indentPlus();
>
> 600: } catch (Exception e) {
> 6001: throw new GenICException(e.getMessage());
> }
> src.indentMinus();
> src.println("} catch (Exception e) {");
> src.indentPlus();
> // BEGIN MHALAS:
> src.println("if (e instanceof ObjectNotFoundException)");
> src.println("{");
> src.indentPlus();
> src.println("throw (ObjectNotFoundException)e;");
> src.indentMinus();
> src.println("}");
> // END MHALAS
> src.println("TraceEjb.error(\"Failed to find bean from database ("+
> method.getName()+")\", e);");
> src.println("throw new FinderException(\"Failed to find bean from
> database ("+
> method.getName()+")\");");
>
> Attached is the fixed .java file as well as compiled .class files.
>
> If you are impacted by this bug, you can just patch your JEREMIE_jonas.jar
> and RMI_jonas.jar file using following commands.
>
> jar -uvf JEREMIE_jonas.jar
> org\objectweb\jonas_ejb\tools\GenICEntityCMbyJDBCBean.class
> jar -uvf RMI_jonas.jar
> org\objectweb\jonas_ejb\tools\GenICEntityCMbyJDBCBean.class
>
> Regards,
>
> Miro Halas
>
> -----Original Message-----
> From: Hélène JOANIN [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 17, 2001 1:36 AM
> To: Nolen, Randy
> Cc: [EMAIL PROTECTED]
> Subject: Re: Bug in generated code
>
> "Nolen, Randy" wrote:
> >
> > Hi,
> >
> > I've found what appears to be a bug in code generated with Jonas V2.2.4.
> In
> > the code snippet below, you'll see that when the requested key is not
> found
> > in the database, an ObjectNotFoundException is thrown. Then the exception
> > that was just thrown is caught and a new FinderException is thrown
> instead.
> > The result is that the caller will never be able to catch an
> > ObjectNotFoundException (and there will always be an error message on the
> > output for what may not actually be an error :-) ).
> >
> > public com.compuware.cgf.beans.core.InTypeID
> > ejbFindByPrimaryKey(com.compuware.cgf.beans.core.InTypeID p1) throws
> > javax.ejb.FinderException {
> >
> >
> TraceEjb.debugGenIC("JOnAScom_compuware_aqp_beans_dectree_DecisionTreeNodeHo
> > me.ejbFindByPrimaryKey(com.compuware.cgf.beans.core.InTypeID)");
> > Connection conn = null;
> > PreparedStatement pStmt = null;
> > try {
> > DataSource ds = (DataSource)(this.ejbHome.getDataSource());
> > conn = ds.getConnection();
> > pStmt = conn.prepareStatement("select SCOPE, ID, VERSION from
> > T_DECISION_TREE_NODE where SCOPE=? and ID=? and VERSION=?");
> > pStmt.setInt(1, p1.m_iScopeID);
> > pStmt.setInt(2, p1.m_iID);
> > pStmt.setInt(3, p1.m_iVersionNum);
> > ResultSet rs = pStmt.executeQuery();
> > if (rs.next() == false) {
> > TraceEjb.error("Object not found in database
> (findByPrimaryKey)");
> > throw new ObjectNotFoundException("Object not found in database
> > (findByPrimaryKey)");
> > }
> > } catch (Exception e) {
> > TraceEjb.error("Failed to find bean from database
> (findByPrimaryKey)",
> > e);
> > throw new FinderException("Failed to find bean from database
> > (findByPrimaryKey)");
> > } finally {
> > if (pStmt != null) {
> > try {
> > pStmt.close();
> > } catch (Exception ignore) {
> > TraceEjb.error("Failed to close the PreparedStatement
> > (findByPrimaryKey)" ,ignore);
> > }
> > }
> > if (conn != null) {
> > try {
> > conn.close();
> > } catch (Exception ignore) {
> > TraceEjb.error("Failed to close the Connection
> > (findByPrimaryKey)" ,ignore);
> > }
> > }
> > }
> > return(p1);
> > }
> >
> > Is this actually a bug or was it intended to operate this way?
> >
> > Thanks,
> > Randy Nolen
> >
>
> Hi Randy,
>
> It seems to be real bug... :-(
> Thanks for this relevent remark.
>
> Hélène.
--
-=- Hélène JOANIN -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
mailto:[EMAIL PROTECTED] http://www.evidian.com
Phone: 33.4.76.29.73.53 Fax: 33.4.76.29.76.00
Download our EJB Server JOnAS at http://www.objectweb.org
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".