aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB +ClassNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB +ClassNotFoundException" Watch "EJB +ClassNotFoundException" New topic
Author

EJB +ClassNotFoundException

Roshnara Rose
Greenhorn

Joined: Nov 08, 2005
Posts: 15
Hi

I'm getting the following error while running..
can anybody help ... don't know whats with this....

18:23:27,277 INFO [EARDeployer] Undeploying J2EE application, destroy step: file:/home/leema/apps/jboss/server/default/deploy/HelloApp.ear
18:23:29,231 INFO [EARDeployer] Init J2EE application: file:/home/leema/apps/jboss/server/default/deploy/HelloApp.ear
18:25:04,716 INFO [EjbModule] Deploying Hello
18:26:07,529 INFO [ProxyFactory] Bound EJB Home 'Hello' to jndi 'ejb/Hello'
18:26:07,805 INFO [EJBDeployer] Deployed: file:/home/leema/apps/jboss/server/default/tmp/deploy/tmp3957HelloApp.ear-contents/HelloEJB.jar
18:26:49,493 INFO [TomcatDeployer] deploy, ctxPath=/hello, warUrl=.../tmp/deploy/tmp3957HelloApp.ear-contents/HelloWeb.war/
18:27:48,473 INFO [JBossCacheManager] init(): replicationGranularity_ is 0 and invaldateSessionPolicy is 2
18:27:48,968 ERROR [JBossCacheManager] JBossCacheService to Tomcat clustering not found
18:27:48,993 ERROR [TomcatDeployer] Failed to setup clustering, clustering disabled
18:28:54,098 INFO [EARDeployer] Started J2EE application: file:/home/leema/apps/jboss/server/default/deploy/HelloApp.ear
18:33:53,327 INFO [STDOUT] java.lang.ClassNotFoundException: HelloHome
18:33:53,382 ERROR [[Hello]] Allocate exception for servlet Hello
javax.servlet.ServletException: Lookup of java:/comp/env/ failed
at test.web.HelloServlet.init(HelloServlet.java:63)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
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:595)

my files are like this..

ejb-jar.xml

<ejb-jar >

<description></description>
<display-name></display-name>
<enterprise-beans>
<!-- Session Beans -->
<session >
<description></description>
<display-name>Name for Hello</display-name>
<ejb-name>Hello</ejb-name>
<home>test.interfaces.HelloHome</home>
<remote>test.interfaces.Hello</remote>
<ejb-class>test.ejb.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</ejb-jar>

jboss.xml

<jboss>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<jndi-name>ejb/Hello</jndi-name>
</session>
</enterprise-beans>

jboss-web.xml

<jboss-web>
<ejb-ref>
<ejb-ref-name>ejb/Hello</ejb-ref-name>
<jndi-name>ejb/Hello</jndi-name>
</ejb-ref>
</jboss-web>

web.xml

<web-app >
<distributable/>
<servlet>
<servlet-name>Hello</servlet-name>
<display-name>Name for Hello</display-name>
<description><![CDATA[Description for Hello]]></description>
<servlet-class>test.web.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/Hello</url-pattern>
</servlet-mapping>
<ejb-ref >
<description><![CDATA[Reference to Hello]]></description>
<ejb-ref-name>ejb/Hello</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>test.interfaces.HelloHome</home>
<remote>test.interfaces.Hello</remote>
</ejb-ref>

</web-app>


client

public class HelloServlet extends HttpServlet {
private HelloHome home;
public HelloServlet() {
super();
}
public void init(ServletConfig config) throws ServletException {
super.init(config);
try {

Context context = new InitialContext();
Object ref = context.lookup("java:comp/env/ejb/Hello");Object ob = PortableRemoteObject.narrow(ref,Class.forName("HelloHome"));
home = (HelloHome) ob;
} catch (Exception e) {
System.out.println(e);
throw new ServletException("Lookup of java:/comp/env/ failed");
}
}
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException,
IOException {
// TODO Auto-generated method stub
System.out.println(" in dopost ");
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();

out.println("<html><head><title>");
out.println("Hello Bean");
out.println("</title></head>");
out.println("<body>");

out.println("<h1>");
out.println("Hello Bean");
out.println("</h1>");
try {
Hello bean = home.create();
String ret = bean.sayHello("Hello World String");
out.println(ret);
bean.remove();
out.println("<p>");
out.print("The ");
out.print(ret);
out.println("</p>");
} catch (Exception e) {
out.println(e.getMessage());
e.printStackTrace(out);
} finally {
out.println("</body></html>");
out.close();
}
}

}
Pranav Shukla
Ranch Hand

Joined: Oct 05, 2005
Posts: 64
Change the init(ServletConfig) method of your servlet



If you are using Class.forName() then you should be using fully qualified class name like Class.forName("test.interfaces.HelloHome").

Another solution would be to use



Hope that helps,

Cheers


Pranav Shukla
SCJP, SCWCD, SCBCD
Roshnara Rose
Greenhorn

Joined: Nov 08, 2005
Posts: 15
Hi Pranav,

I'm great to have your reply. I did tried it both way. Now a new exception is throwing. That is like this.. What went wrong in the code.. I'm using jboss-IDE for the development..

This is at the jboss's console..

09:33:28,813 INFO [STDOUT] ejb/HelloHome
09:33:29,095 INFO [STDOUT] java.lang.ClassCastException
09:33:29,199 ERROR [[Hello]] Allocate exception for servlet Hello
javax.servlet.ServletException: Lookup of java:/comp/env/ failed
at test.web.HelloServlet.init(HelloServlet.java:64)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1091)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
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:595)
Pranav Shukla
Ranch Hand

Joined: Oct 05, 2005
Posts: 64
Hi Roshnara,

Please go through this entire thread. This might solve your problem.

Cheers
Roshnara Rose
Greenhorn

Joined: Nov 08, 2005
Posts: 15
Hi Pranav,

Thanks a lot.. Its working..

Regards,
Leema
Pranav Shukla
Ranch Hand

Joined: Oct 05, 2005
Posts: 64
You are welcome!
Pranav Shukla
Ranch Hand

Joined: Oct 05, 2005
Posts: 64
Hi Roshnara Rose,

Please change your display name to conform to javaranch's naming policy.

Thanks,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB +ClassNotFoundException
 
Similar Threads
NameNotFoundException - but the jndi bound
NameNotFoundException in EJB? could anyone tell me?
Not able to excute EJB ClassCastException
How to get the datasource from Bean through deployment descriptor
NameNotFoundException in EJB? could anyone tell me?