Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

EJB inaccessible???
Hi,

I'm having problems with an EJB in jonas 4.3.4. I coded a simple entity
bean that uses CMP2 and a servlet to test it, which handles a table in
PostgreSQL that has 3 fields. The servlet performs a listing using
findAll and I'm also calling ejbCreate to insert data taken from the
URL. Everything works fine (listing and insert) until I produce an
exception (on purpose), for example, a duplicate primary key constraint
violation. After this point, when I try to list again the EJB Home
seems to go out of scope or something, and it occurs randomly. If I
keep pressing F5 in my browser, sometimes it works AOK, and some others
I get this exception:

javax.naming.NameNotFoundException
at
org.objectweb.jonas.naming.CompNamingContext.lookupCtx(CompNamingContext.jav
a:740)
at
org.objectweb.jonas.naming.CompNamingContext.lookup(CompNamingContext.java:1
91)
at
org.objectweb.jonas.naming.CompNamingContext.lookup(CompNamingContext.java:1
92)
at
org.objectweb.jonas.naming.CompNamingContext.lookup(CompNamingContext.java:1
92)
at
org.objectweb.jonas.naming.java.javaURLContext.lookup(javaURLContext.java:17
6)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
.....

The code on my servlet is the following:

private void showPage(HttpServletRequest request, HttpServletResponse
response) throws IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("      <head>");
out.println("              <title>sample servlet generated by
nosotros</title>");
out.println("      </head>");
out.println("<body>");
out.println("This sample servlet displays a community
list<BR/>");
String sId      = (String)request.getParameter("id");
String name     = (String)request.getParameter("name");
String description =
(String)request.getParameter("description");

Context         initialContext  = null;
GroupLocalHome  groupLocalHome  = null;
GroupLocal      groupLocal      = null;
try {
initialContext = new InitialContext();
initialContext.lookup("javax.transaction.UserTransaction");
groupLocalHome =
(GroupLocalHome)initialContext.lookup("java:comp/env/ejb/GroupLocal");

// Creating
if (sId != null && sId != ""){
out.println("Inserting a community<BR/>");
if (name == null)
out.println("Warning name is
null<BR/>");
if (description == null)
out.println("Warning description is
null<BR/>");
groupLocal = groupLocalHome.create(new
Integer(sId), name,
description);
out.println("The name of the new community is:
" +
groupLocal.getName());
}

// Listing
Collection col = groupLocalHome.findAll();
out.println("There are " + col.size() + " rows in the
table<BR/>");
Iterator iter = col.iterator();
while(iter.hasNext()){
groupLocal = (GroupLocal)iter.next();
out.println(groupLocal.getName() + " || " +
groupLocal.getDescription() + "<BR/>");
}
} catch (NamingException e) {
e.printStackTrace();
out.println("<li>Cannot lookup
java:comp/env/ejb/GroupLocal: " + e + "</li>");
} catch (FinderException e) {
e.printStackTrace();
out.println("<li>Cannot findAll
java:comp/env/ejb/GroupLocal.findAll: " + e + "</li>");
} catch (NumberFormatException e) {
e.printStackTrace();
out.println("<li>Cannot convert to integer: " +
e + "</li>");
} catch (CreateException e) {
e.printStackTrace();
out.println("<li>Cannot create: " + e +
"</li>");
} catch (Exception e) {
e.printStackTrace();
out.println("<li>AHHHH FATAL ERROR ... KERNEL
PANIC!: " + e +
"</li>");
} finally {
out.println("</body>");
out.println("</html>");
}
}

This method (ShowPage) is being called in both DoGet and DoPost.

I'm new to EJB and jonas, so any help would be greatly appreciated.
- Enrique


Report this thread to moderator Post Follow-up to this message
Old Post
enrique.martinez@gmail.com
06-02-05 08:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Beans archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:47 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.