I have been trying for quite some time to deploy a session bean that will
handle database transactions. I am getting the following error
****************************************************************************
*****************************************
There was an exception thrown here. javax.naming.NamingException: Failed to
unmarshal proxy. Root exception is java.lang.ClassNotFoundException:
TransactionHomeObject_Stub at java.io.ObjectInputStream.inputObject(Unknown
Source) at java.lang.Exception.(Unknown Source) at
java.lang.ClassNotFoundException.(Unknown Source) at
java.io.ObjectInputStream.inputObject(Unknown Source) at
java.io.ObjectInputStream.readObject(Unknown Source) at
java.io.ObjectInputStream.readObject(Unknown Source) at
java.rmi.MarshalledObject.get(Unknown Source) at
allaire.ejipt._NamingContext$_Proxy._resolve(_NamingContext.java:362) at
allaire.ejipt._NamingContext.lookup(_NamingContext.java:68) at
allaire.ejipt._ClientContext.lookup(_ClientContext.java:113) at
javax.naming.InitialContext.lookup(InitialContext.java:349) at
testbean.doGet(testbean.java:33) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:865) at
allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013) at
allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code) at
allaire.jrun.servlet.JRunNamedDispatcher.forward(JRunNamedDispatcher.java:34
) at allaire.jrun.servlet.Invoker.service(Invoker.java:84) at
allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013) at
allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java, Compiled Code) at
allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.jav
a:88) at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1131) at
allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:330) at
allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java:382) at
allaire.jrun.ThreadPool.run(ThreadPool.java, Compiled Code) at
allaire.jrun.WorkerThread.run(WorkerThread.java, Compiled Code)
javax.naming.NamingException: Failed to unmarshal proxy [Root exception is
java.lang.ClassNotFoundException: TransactionHomeObject_Stub]
****************************************************************************
******************************************
Here is my code
import java.util.*;
import java.sql.*;
import java.rmi.*;
import javax.rmi.*;
import javax.ejb.*;
import javax.naming.*;
import allaire.ejipt.*;
public interface TransactionHome extends EJBHome {
public Transaction create()
throws RemoteException, CreateException;
}
****************************************************************************
**********************************
import java.util.*;
import java.text.*;
import java.sql.*;
import java.rmi.*;
import javax.rmi.*;
import javax.ejb.*;
import javax.naming.*;
import allaire.ejipt.*;
public class TransactionBean implements SessionBean {
public SessionContext context;
public void ejbCreate() {
}
public boolean insert(String cid, int jn, int comp, int e, int ttype,
String sid, int count) {
Connection con = null;
PreparedStatement ps = null;
java.sql.Date today = new java.sql.Date(new
java.util.Date().getTime());
DateFormat cur_date = DateFormat.getDateInstance(DateFormat.MEDIUM);
try {
con = getConnection();
ps = con.prepareStatement("INSERT INTO trans(client_id, job_number,
comp_id,"+
" event_id, trans_type, cur_date, session_id, cur_count) VALUES
(?,?,?,?,?,?,?,?)");
ps.setString(1, cid);
ps.setInt(2, jn);
ps.setInt(3, comp);
ps.setInt(4, e);
ps.setInt(5, ttype);
ps.setDate(6, today);
ps.setString(7, sid);
ps.setInt(8, count);
int retVal = ps.executeUpdate();
if(retVal!=1) {
System.err.println("Error inserting into the database. The values
were \ncid="+cid+"\njn="+
Integer.toString(jn)+"\ncomp="+Integer.toString(comp)+"\nevent="+Integer.toS
tring(event)+
"\nttype="+Integer.toString(ttype)+"\ncur_date="+cur_date.toString()+"\nsid=
"+sid+"\ncount="+Integer.toString(count));
}
} catch(SQLException sql) {
System.err.println("There was a SQLException thrown in the
Transaction Bean insert method.");
return false;
} finally {
try {
if(ps != null) ps.close();
if(con != null) con.close();
} catch(SQLException se) {
se.printStackTrace();
}
}
return true;
}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
public void setSessionContext(SessionContext ctx) {
context = ctx;
}
private Connection getConnection() throws SQLException {
Connection con = null;
try {
con = ResourceManager.getConnection("source1");
} catch(Exception e) {
System.err.println("Error getting connection in
TransactionBean::getConnection()");
}
return con;
}
}
****************************************************************************
**************************************
import java.util.*;
import java.sql.*;
import java.rmi.*;
import javax.rmi.*;
import javax.ejb.*;
import javax.naming.*;
import allaire.ejipt.*;
public interface Transaction extends EJBObject {
public boolean insert(String cid, int jn, int comp, int e, int ttype,
String sid, int count)
throws RemoteException;
}
****************************************************************************
**************************************
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<description>
A Session Bean which handles TMX Rich Media Transactions
</description>
<ejb-name>TransactionBean</ejb-name>
<home>TransactionHome</home>
<remote>Transaction</remote>
<ejb-class>TransactionBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<security-role>
<description>
Everyone can join the party
</description>
<role-name>all</role-name>
</security-role>
<method-permission>
<role-name>all</role-name>
<method>
<ejb-name>TransactionBean</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>
<container-transaction>
<method>
<ejb-name>TransactionBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
****************************************************************************
****************************************
import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
import javax.ejb.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.*;
import allaire.ejipt.*;
public class testbean extends HttpServlet {
private static final String CONTENT_TYPE = "text/html";
/**Initialize global variables*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/**Process the HTTP Get request*/
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
System.setSecurityManager(new RMISecurityManager());
out.println("<html>");
out.println("<head><title>testbean</title></head>");
out.println("<body>");
try {
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"allaire.ejipt.ContextFactory");
properties.setProperty(Context.PROVIDER_URL,
"ejipt://127.0.0.1:2323");
Context ctx = new InitialContext(properties);
// Object ref = ctx.lookup("TransactionBean");
// TransactionHome t_home = (TransactionHome)
PortableRemoteObject.narrow(ref, TransactionHome.class);
TransactionHome t_home = (TransactionHome)
ctx.lookup("TransactionBean");
Transaction trans = t_home.create();
if(trans.insert("914", 98765, 999, 1, 5, "8123716", 1)) {
out.println("A record should have been added to the database");
}
else {
out.println("Something went wrong.");
}
} catch(Exception e) {
out.println("There was an exception thrown here.");
e.printStackTrace(out);
out.println(e.toString());
}
out.println("<p>The servlet has received a GET. This is the
reply.</p>");
out.println("</body></html>");
}
/**Clean up resources*/
public void destroy() {
}
}
****************************************************************************
************************************
#
#Wed Aug 08 17:37:21 EDT 2001
ejipt.jdbcSources=source1
source1.ejipt.sourceDriverClassName=com.inet.tds.TdsDriver
source1.ejipt.sourceURL=jdbc\:inetdae7\:192.168.1.21\:1433
source1.ejipt.sourceUser=user
source1.ejipt.sourcePassword=password
ejipt.storeName=default
ejipt.loginSessionHomeName=default.LoginSessionHome
ejipt.userHomeName=default.UserHome
ejipt.classServer.host=localhost
ejipt.roleHomeName=default.RoleHome
ejipt.ejbJars=transaction1.jar,bob_ejb.jar,
ejb.allowedIdentities=all
****************************************************************************
*********************************
This has been driving me crazy for the longest time. Any help would be most
appreciated.
Thanks,
Bob
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists