This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes javax.naming.NamingException: Could not dereference object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "javax.naming.NamingException: Could not dereference object" Watch "javax.naming.NamingException: Could not dereference object" New topic
Author

javax.naming.NamingException: Could not dereference object

rajareddya reddy
Ranch Hand

Joined: Jul 23, 2011
Posts: 49
Hi, I am getting following exception while deploying application in jboss 5.0.1.




please help to resolve this exception.
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Is there any other exception before that? Check the names that you are refering.


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Anjan Chowdhury
Greenhorn

Joined: Nov 02, 2011
Posts: 3
hello,
to create an ejb3 application, you have to create the ejb jar. look at the console of eclipse IDE, while deploying the jar.
here the code that i create to make a simple EJB:

bean:
-------

package ejb;

import javax.ejb.Stateless;

/**
* Session Bean implementation class Anju
*/
@Stateless
public class Anju implements AnjuLocal {

/**
* Default constructor.
*/
public Anju() {
// TODO Auto-generated constructor stub
}
public void yes(){
System.out.println("connected to jsp");
}
}
-----------------------------
-----------------------------
interface:
----------
package ejb;
import javax.ejb.Local;

@Local
public interface AnjuLocal {
public void yes();
}
-----------------------------
------------------------------
now create a dynamic web project. and create a html page:
--------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
enter your name
<form method="get" action="AnjuServlet">
<input type="text" name="name">
<button type="submit" style="width : 92px; height : 25px;">
go
</button>
</form>
</body>
</html>
-------------------------------------------------
-------------------------------------------------
now create a servlet : src/web/AnjuServlet.java
-----------------------
package web;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ejb.AnjuLocal;

/**
* Servlet implementation class AnjuServlet
*/
public class AnjuServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

@EJB(mappedName="Anju/local")
private AnjuLocal al;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
al.yes();
}


}
------------------------------------
don't forget to configure the java build path. to add the ejb project in the web project.
-------------------------
now deploy the jar(ejb) file first .
then deploy the war(web) file.
-----------------------
and check .
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: javax.naming.NamingException: Could not dereference object
 
Similar Threads
java.lang.Exception: javax.naming.NamingException: Could not dereference object
JBoss 5.1 throwing error for missing jsp files in /WEB-INF folder
tomcat6 and eclipse - NullPointer Exception in _jspInit-method
Context is read only exception
org.springframework.beans.factory.NoSuchBeanDefinitionException No bean named