posted 23 years ago
Thanx for ur reply.
I tried that way, but still the same problem.
Let me explain u in detail what I have done.
creating jar:
I have 3 class files as following:
Square.class - Bean class which implements SessionBean. It has a method square() which returns the square of the passed integer.
SquareHome.class - Home interface
SquareRemote.class - Remote interface.
I created a temporary folder named "a". Inside this I created a folder "META-INF". I put these 3 classes inside "a". Then on command prompt I went to the folder "a" ("d:\a>"). I ran the tool
"java weblogic.ant.taskdefs.ejb20.DDInit ." to generate ejb-jar.xml and weblogic-ejb-jar.xml. Then I created the jar file by running
"jar -cvf sqjar.jar .".
creating war:
I created a temporary folder named "aa". Inside this I created a folder "WEB-INF". Inside WEB-INF I created a folder "classes". I put SquareHome.class and SquareRemote.class inside classes folder. I put the jsp file "sqr.jsp" inside "aa". Then on command prompt I went to the folder "a" ("d:\aa>"). I ran the tool
"java weblogic.ant.taskdefs.war.DDInit ." to generate web.xml and weblogic.xml. Then I created the war file by running
"jar -cvf sqwar.war .".
creating ear:
I created a temporary folder named "aaa". Inside this I created a folder "META-INF". I put the "sqjar.jar" and "sqwar.war" inside "aaa". Then on command prompt I went to the folder "a" ("d:\aaa>"). I ran the tool
"java weblogic.ant.taskdefs.ear.DDInit ." to generate application.xml. Then I created the ear file by running
"jar -cvf sqear.ear .".
sqr.jsp content:
<%@ page language="java" import="java.sql.*,java.util.*,javax.naming.*;" session="true" isThreadSafe="true" contentType="text/html" %>
<HTML>
<HEAD>
<title>Squaring a number</title>
</HEAD>
<BODY bgcolor=#ddeeff>
<%
try{
Properties h = new Properties();
h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
h.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context initial = new InitialContext(h);
Object objref = initial.lookup("SQ2");
SquareHome home =(SquareHome)PortableRemoteObject.narrow(objref,SquareHome.class);
SquareRemote s = home.create();
System.out.println("After squaring : "+s.square(Integer.parseInt(4));
}catch(Exception e){out.println("Exception ::"+e.toString());}
%>
</BODY>
</HTML>
In the lookup method I have passed the JNDI-NAME that is provided in the tag <jndi-name> in weblogic-ejb-jar.xml.
In application.xml the <context-root> tag contains the value "sqwar".
When I run the jsp by the url "http://localhost:7001/sqwar/sqr.jsp" it gives "cannot resolve symbol" for SquareHome and SquareRemote.
Please tell me what is wrong in the above deployment process. I tried the other way by not putting SquareHome.class and SquareRemote.class inside classes folder while creating the war file. Still the same problem.
Waiting for reply.
regards
Rajesh