File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.naming.NamingException: Could not dereference object

 
rajareddya reddy
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am getting following exception while deploying application in jboss 5.0.1.




please help to resolve this exception.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any other exception before that? Check the names that you are refering.
 
Anjan Chowdhury
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic