aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Error while running entity bean on weblogic6.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Error while running entity bean on weblogic6.0" Watch "Error while running entity bean on weblogic6.0" New topic
Author

Error while running entity bean on weblogic6.0

amit ang
Ranch Hand

Joined: Sep 28, 2001
Posts: 38
Hi everybody,
Following is the error i get when i run the following comand,
It prepares the std_ejb_jar file and when executing the ejbc command following error ocurs :
D:\bea\wlserver6.0\samples\ejb\com\entity\cabin>java -classpath d:\bea\wlserver6.0/lib/weblogic_sp.jar;d:\bea\wlserver6.0/lib/weblogic.jar weblogic.ejbc -verbose -compiler javac build\std_ejb_cabin.jar \ejb_cabin.jar
ERROR: Error from ejbc: [9.7.12] In EJB cabinmethod, the findByPrimaryKey method must return the Entity bean's remote interface type, and it's parameter must be the primary key type or java.lang.Object: findByPrimaryKey(ejb.com.entity.cabin.CabinPK) ERROR: ejbc found errors Process Exit...
I have a table called cabin_table with id has not null.
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1859
Please send your findByPrimaryKey method code as well as the Primary key type.

------------------

Mahindrakar
IBM Application Server & Developer Forum Moderator

Consultant - Zensar Technologies ,Pune India.
SCJP2, SCJD2 & SCJEA (Part I)
amit ang
Ranch Hand

Joined: Sep 28, 2001
Posts: 38
Originally posted by Rahul Mahindrakar:
Please send your findByPrimaryKey method code as well as the Primary key type.
Hi Rahul, Sorry for delay, I will send u the complete details
by mail.
Bye
Thanks

Ranjith R
Greenhorn

Joined: Sep 18, 2001
Posts: 22
hi there amit,

consider this example:


  • ejb Home interface name:CustomerHome

  • ejb Remote interface name:Customer

  • ejb Bean name: CustomerBean



  • from the err message that you have posted, I feel you need to check the following:
    The findByPrimaryKey(..) method in your Home interface should
    have a signature like this:


    public Customer findByPrimaryKey(String primaryKey)
    throws FinderException, RemoteException;

    As per the above assumptions

    the return type should be of the Remote type

    also, make sure that the argument primaryKey is not a primitive data type(int,char..).
    hope it was simple
    RC! :-)


Take care<BR>r@njith
amit ang
Ranch Hand

Joined: Sep 28, 2001
Posts: 38
Hi Rahul,
Bellow is the code that u had sent me right,
I tried to execute it but facing exception( ATTACHED AT THE END) related to connection. Can u pls tell me the solution of error?
import java.io.*;
import java.sql.*;
import javax.naming.InitialContext;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.sql.DataSource;
public class DataSourceServlet extends HttpServlet
{
public DataSourceServlet()
{
}
public void doGet(HttpServletRequest
httpservletrequest, HttpServletResponse
httpservletresponse)
throws ServletException, IOException
{
httpservletresponse.setHeader("Cache-Control",
"No-Cache");

httpservletresponse.setContentType("text/html");
out = httpservletresponse.getWriter();
out.print("Hellow");
try
{
out.println("inside init");
InitialContext initialcontext = new
InitialContext();// Intialization done by callin the appropiate method
out.print("after initial context");
out.println("
");
out.println("Hi before generating exception1");
out.println("
");
System.out.println("hi1");
DataSource datasource =(DataSource)initialcontext.lookup("JNDIcabin_entity");
out.print("after Datasource"+ datasource);
out.println("
");
Connection connection = datasource.getConnection();
System.out.println("After Connection");
out.print("after connection");
Statement statement = connection.createStatement();
for(ResultSet resultset =
statement.executeQuery("select * from cabin_table");
resultset.next(); out.print(""))
{

out.print(resultset.getString("SHIP"));
out.print(resultset.getInt("ID"));
}
out.println("



over");
statement.close();
connection.close();
}
catch(Exception exception)
{
out.println("exception in init " + exception);
exception.printStackTrace();
}
}
public void doPost(HttpServletRequest
httpservletrequest, HttpServletResponse
httpservletresponse)
throws ServletException, IOException
{
doGet(httpservletrequest,
httpservletresponse);
}
public void init(ServletConfig servletconfig)
throws ServletException
{
super.init(servletconfig);
}
Connection con;
PrintWriter out;
}
*******************************************
OUTPUT OF ABOVE PROGRAM.
Hellowinside init after initial context
Hi before generating exception1
after Datasourceweblogic.jdbc.common.internal.RmiDataSource@352a28
exception in init java.sql.SQLException: weblogic.common.ResourceException: No resources available

Thanks.
Amit

[This message has been edited by amit ang (edited October 08, 2001).]
Toyin Sogeke
Greenhorn

Joined: Oct 08, 2001
Posts: 14
Hello sir,
There might be a mis-match between your Home Interface
and the primary key class.
Please check your entity bean's home interface,
it should look something like this:
Note
1. CabinEB - should be your Entity bean Remote interface
2. CabinEBHome - should be your Entity bean Home interface
3. <DATATYPE> - valid data type
4. <METHOD> - method name
5. <VARIABLE> - variable name
public interface CabinEBHome extends EJBHome {
public CabinEB create()
throws CreateException, RemoteException;
public CabinEB findByPrimaryKey(CabinPK primaryKey)
throws FinderException, RemoteException;
public <DATATYPE> findBy<METHOD>(<DATATYPE> <VARIABLE>)
throws FinderException, RemoteException;
}
Hope this helps.
Cheers
Originally posted by amit ang:
Hi everybody,
Following is the error i get when i run the following comand,
It prepares the std_ejb_jar file and when executing the ejbc command following error ocurs :
D:\bea\wlserver6.0\samples\ejb\com\entity\cabin>java -classpath d:\bea\wlserver6.0/lib/weblogic_sp.jar;d:\bea\wlserver6.0/lib/weblogic.jar weblogic.ejbc -verbose -compiler javac build\std_ejb_cabin.jar \ejb_cabin.jar
ERROR: Error from ejbc: [9.7.12] In EJB cabinmethod, the findByPrimaryKey method must return the Entity bean's remote interface type, and it's parameter must be the primary key type or java.lang.Object: findByPrimaryKey(ejb.com.entity.cabin.CabinPK) ERROR: ejbc found errors Process Exit...
I have a table called cabin_table with id has not null.


homeboy
amit ang
Ranch Hand

Joined: Sep 28, 2001
Posts: 38
Hi Everybody,
Iam amit again here :
I have installed weblogic6.1 and all my earlier problems where solved
I have checked for my datasouce with the external program that works properly.
According to the latest development, Iam getting the following error when i deploy my ejbc jar.
cabinmethd is the ejb name
Unable to deploy EJB: cabinmethod from ejb_cabin.jar:
Unable to bind EJB Home Interface to the JNDI name: CabinEntityJndi. The error w
as:
javax.naming.NameAlreadyBoundException: Can't rebind anything but a replica-awar
e stub to a name that is currently bound to a replica-aware stub; remaining name
''
<<no stack trace available>>

>
<Oct 9, 2001 10:48:00 AM IST> <Error> <Management> <Error deploying application<br /> .\config\mydomain\applications\ejb_cabin.jar: java.lang.reflect.UndeclaredThrowa<br /> bleException>
Thanks for ur help
Amit
 
Consider Paul's rocket mass heater.
 
subject: Error while running entity bean on weblogic6.0