I am developing a j2ee application using session facade concept . i get error as follows 00:36:09,484 INFO [EjbModule] Deploying Customer
00:36:09,484 INFO [EjbModule] Deploying UserManager
00:36:09,484 INFO [EjbModule] Deploying UserValidator
00:36:09,515 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'Customer' to jndi 'CustomerLocal'
00:36:09,515 INFO [ProxyFactory] Bound EJB Home 'Customer' to jndi 'Customer'
00:36:09,546 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'UserManager' to jndi 'UserManagerLocal'
00:36:09,546 INFO [ProxyFactory] Bound EJB Home 'UserManager' to jndi 'UserManager'
00:36:09,562 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'UserValidator' to jndi 'UserValidatorLocal'
00:36:09,562 INFO [ProxyFactory] Bound EJB Home 'UserValidator' to jndi 'UserValidator'
00:36:09,562 INFO [EJBDeployer] Deployed: file:/C:/Program Files/jboss-4.0.3SP1/server/default/deploy/myEJBProj.jar
00:36:22,000 ERROR [LogInterceptor] Unexpected Error in method: public abstract java.lang.String com.user.UserValidator.foo(java.lang.String) throws java.rmi.RemoteException
java.lang.NoClassDefFoundError: $Proxy283
at sun.reflect.GeneratedSerializationConstructorAccessor140.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Constructor.java:521)
at java.io.ObjectStreamClass.newInstance(ObjectStreamClass.java:951)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1723)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1324)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:362)
at java.rmi.MarshalledObject.get(MarshalledObject.java:163)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:57)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:637)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:363)
at com.user.UserValidatorBean.foo(UserValidatorBean.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:154)
at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:54)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:153)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:873)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
at org.jboss.invocation.InvokerInterceptor.invokeMarshalled(InvokerInterceptor.java:201)
at org.jboss.invocation.MarshallingInvokerInterceptor.invoke(MarshallingInvokerInterceptor.java:35)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:97)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
at $Proxy282.foo(Unknown Source)
at LoginServlet.doGet(LoginServlet.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
at java.lang.Thread.run(Thread.java:803)
00:36:22,000 INFO [STDOUT] In LoginServlet java.rmi.ServerError: Unexpected Error; nested exception is:
java.lang.NoClassDefFoundError: $Proxy283
I have a session bean UserValidator
/**
*
*/
package com.user;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
/**
*
* <!-- begin-user-doc -->
* A generated session bean
* <!-- end-user-doc -->
* *
* <!-- begin-xdoclet-definition -->
* @ejb.bean name="UserValidator"
* description="An EJB named UserValidator"
* display-name="UserValidator"
* jndi-name="UserValidator"
* type="Stateless"
* transaction-type="Container"
*
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract class UserValidatorBean implements javax.ejb.SessionBean {
/**
* <!-- begin-xdoclet-definition -->
* <!-- end-xdoclet-definition -->
* @generated
*/
private static final long serialVersionUID = 1L;
/**
*
* <!-- begin-xdoclet-definition -->
* @ejb.create-method view-type="remote"
* <!-- end-xdoclet-definition -->
* @generated
*
* //TODO: Must provide implementation for bean create stub
*/
public void ejbCreate() {
}
/**
*
* <!-- begin-xdoclet-definition -->
* @ejb.interface-method view-type="remote"
* <!-- end-xdoclet-definition -->
* @generated
*
* //TODO: Must provide implementation for bean method stub
*/
public String foo(String param) {
String ret="hello";
try{
Context ctx = new InitialContext();
CustomerHome customerHome = (CustomerHome)PortableRemoteObject.narrow(
ctx.lookup("Customer"), CustomerHome.class);
//Customer customer=customerHome.findByPrimaryKey(param);
//CustomerLocalHome home=CustomerUtil.getLocalHome();
//Customer customer=home.create();
//CustomerLocal customer =home.findByPrimaryKey(param);
//if(customer==null)
//System.out.println("****NULL CUSTOMER***");
//else
//ret=customer.getPassword();
return ret;
}
catch(Exception e)
{
System.out.println("In UserValidatorBean "+e);
return null;
}
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbActivate()
*/
public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbPassivate()
*/
public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#ejbRemove()
*/
public void ejbRemove() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
*/
public void setSessionContext(SessionContext arg0) throws EJBException,
RemoteException {
// TODO Auto-generated method stub
}
/**
*
*/
public UserValidatorBean() {
// TODO Auto-generated constructor stub
}
}
/*
* Generated by XDoclet - Do not edit!
*/
package com.user;
/**
* Remote interface for UserValidator.
* @generated
* @wtp generated
*/
public interface UserValidator
extends javax.ejb.EJBObject
{
/**
* <!-- begin-xdoclet-definition -->
* @generated //TODO: Must provide implementation for bean method stub */
public java.lang.String foo( java.lang.String param )
throws java.rmi.RemoteException;
}
/*
* Generated by XDoclet - Do not edit!
*/
package com.user;
/**
* Home interface for UserValidator.
* @generated
* @wtp generated
*/
public interface UserValidatorHome
extends javax.ejb.EJBHome
{
public static final String COMP_NAME="java:comp/env/ejb/UserValidator";
public static final String JNDI_NAME="UserValidator";
public com.user.UserValidator create()
throws javax.ejb.CreateException,java.rmi.RemoteException;
}
An entity bean Customer connected to db2 database configured through eclipse Ganymede
/*
* Generated by XDoclet - Do not edit!
*/
package com.user;
/**
* Remote interface for Customer.
* @generated
* @wtp generated
*/
public interface Customer
extends javax.ejb.EJBObject
{
/**
* <!-- begin-user-doc --> CMP Field name Returns the name
* @return the name <!-- end-user-doc --> <!-- begin-xdoclet-definition -->
* @generated */
public java.lang.String getName( )
throws java.rmi.RemoteException;
/**
* <!-- begin-user-doc --> Sets the name
* @param java.lang.String the new name value <!-- end-user-doc --> <!-- begin-xdoclet-definition -->
* @generated */
public void setName( java.lang.String name )
throws java.rmi.RemoteException;
/**
* <!-- begin-user-doc --> CMP Field password Returns the password
* @return the password <!-- end-user-doc --> <!-- begin-xdoclet-definition -->
* @generated */
public java.lang.String getPassword( )
throws java.rmi.RemoteException;
/**
* <!-- begin-user-doc --> Sets the password
* @param java.lang.String the new password value <!-- end-user-doc --> <!-- begin-xdoclet-definition -->
* @generated */
public void setPassword( java.lang.String password )
throws java.rmi.RemoteException;
}
package com.user;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;
/**
* <!-- begin-xdoclet-definition -->
* @ejb.bean name="Customer"
* jndi-name="Customer"
* type="CMP"
* primkey-field="name"
* schema="CustomerSCHEMA"
* cmp-version="2.x"
*
* @ejb.persistence
* table-name="SHOBHA.CUSTOMER"
*
* @ejb.finder
* query="SELECT OBJECT(a) FROM CustomerSCHEMA as a"
* signature="java.util.Collection findAll()"
*
* @ejb.pk class="java.lang.String"
*
*
* @jboss.persistence datasource="java:/DefaultDS" datasource-mapping="Hypersonic SQL" table-name="SHOBHA.CUSTOMER" create-table="false" remove-table="false" alter-table="false"
* <!-- end-xdoclet-definition -->
* @generated
**/
public abstract class CustomerBean implements javax.ejb.EntityBean {
/**
*
* <!-- begin-user-doc -->
* The ejbCreate method.
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
* @ejb.create-method
* <!-- end-xdoclet-definition -->
* @generated
*/
public java.lang.String ejbCreate() throws javax.ejb.CreateException {
// EJB 2.0 spec says return null for CMP ejbCreate methods.
// TODO: YOU MUST INITIALIZE THE FIELDS FOR THE BEAN HERE.
// setMyField("Something");
// begin-user-code
return null;
// end-user-code
}
/**
* <!-- begin-user-doc -->
* The container invokes this method immediately after it calls ejbCreate.
* <!-- end-user-doc -->
*
* @generated
*/
public void ejbPostCreate() throws javax.ejb.CreateException {
// begin-user-code
// end-user-code
}
/**
*
*
* <!-- begin-user-doc -->
* CMP Field name
*
* Returns the name
* @return the name
*
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="NAME"
* jdbc-type="VARCHAR"
* sql-type="VARCHAR(50)"
* read-only="false"
* @ejb.pk-field
*
* @ejb.interface-method
*
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract java.lang.String getName();
/**
* <!-- begin-user-doc -->
* Sets the name
*
* @param java.lang.String the new name value
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
* @ejb.interface-method
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract void setName(java.lang.String name);
/**
*
*
* <!-- begin-user-doc -->
* CMP Field password
*
* Returns the password
* @return the password
*
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="PASSWORD"
* jdbc-type="VARCHAR"
* sql-type="VARCHAR(50)"
* read-only="false"
*
*
* @ejb.interface-method
*
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract java.lang.String getPassword();
/**
* <!-- begin-user-doc -->
* Sets the password
*
* @param java.lang.String the new password value
* <!-- end-user-doc -->
*
* <!-- begin-xdoclet-definition -->
* @ejb.interface-method
* <!-- end-xdoclet-definition -->
* @generated
*/
public abstract void setPassword(java.lang.String password);
/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbActivate()
*/
public void ejbActivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbLoad()
*/
public void ejbLoad() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbPassivate()
*/
public void ejbPassivate() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbRemove()
*/
public void ejbRemove() throws RemoveException, EJBException,
RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.EntityBean#ejbStore()
*/
public void ejbStore() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
*/
public void setEntityContext(EntityContext arg0) throws EJBException,
RemoteException {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.ejb.EntityBean#unsetEntityContext()
*/
public void unsetEntityContext() throws EJBException, RemoteException {
// TODO Auto-generated method stub
}
/**
*
*/
public CustomerBean() {
// TODO Auto-generated constructor stub
}
}
/*
* Generated by XDoclet - Do not edit!
*/
package com.user;
/**
* Home interface for Customer.
* @generated
* @wtp generated
*/
public interface CustomerHome
extends javax.ejb.EJBHome
{
public static final String COMP_NAME="java:comp/env/ejb/Customer";
public static final String JNDI_NAME="Customer";
public com.user.Customer create()
throws javax.ejb.CreateException,java.rmi.RemoteException;
public java.util.Collection findAll()
throws javax.ejb.FinderException,java.rmi.RemoteException;
public com.user.Customer findByPrimaryKey(java.lang.String pk)
throws javax.ejb.FinderException,java.rmi.RemoteException;
}
A servlet LoginServlet is as follows
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class LoginServlet
*/
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public LoginServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter pw=response.getWriter();
pw.println("Login");
try{
String username=request.getParameter("username");
String password=request.getParameter("password");
com.user.UserValidatorHome home=com.user.UserValidatorUtil.getHome();
com.user.UserValidator user=null;
user=home.create();
String pwd=user.foo(username);
if(pwd.equals(password))
pw.println("Welcome "+username);
pw.println("You have successfully logged in!!!");
}catch(Exception exception)
{
System.out.println("In LoginServlet "+exception);
}
}
}
In the UserValidatorBean Class whether I do getLocalHome or getHome or using lookup I keep getting the error.
I have followed the following procedure to configure for db2
We begin by adding its driver to the CLASSPATH: copy db2java.zip to the /server/default/lib directory. To configure the JBoss server with the DB2 data source, copy /docs/examples/jca/db2-ds.xml to the /server/default/deploy directory.
Next we modify the db2-ds.xml configuration file, by setting to COM.ibm.db2.jdbc.app.DB2Driver and to jdbc:db2:, where is the DB2 database name.
Then we modify standardjaws.xml (or jaws.xml) to set and .
java:/DB2DS
DB2
And standardjbosscmp-jdbc.xml (or jbosscmp-jdbc.xml):
java:/DB2DS
DB2
Finally, we add the following element to login-config.xml:
sa
sa
jboss.jca:service=LocalTxCM,name=DB2DS
What is the error?
Please help me as I am a newbie to J2ee.
Any help is greatly appreciated!! :-)