Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Help Package,Deploy and Run EJB in Weblogic6.1

  Asked By: Sebastion    Date: May 16    Category: Java    Views: 1204
  

I am having problem while running my ejb in weblogic 6.1. I dont know where i made a mistake (I compiled all the java files without error). I used the weblogic console and deployed my bean it says deployment ture. I packaged all the .class files and .xml files using jar cvf TemperatureEJB.jar com\deg\*.* command.
I am herewith pasted my coding and the error message. If anyone working in weblogic please let me know the steps to package and deploy the bean as well as how to run the client files.
(Note: My application server and client files are in the same mc. purpose of the program is to convert FahrenheitToCelsius it accepts the Fahrenheit from the user and displayed the Celsius value. if the user enter 'q' it will quit the program)


-----Remote Interface----
package com.deg;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface Temperature extends EJBObject
{
public double FahrenheitToCelsius(double degree) throws RemoteException;
}
-----------Home Interface----
package com.deg;
import java.io.Serializable;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;

public interface TemperatureHome extends EJBHome
{
Temperature create() throws RemoteException, CreateException;
}
-----------Ejb Class------
package com.deg;
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class TemperatureEJB implements SessionBean
{
public double FahrenheitToCelsius(double F)
{
double c;
c=((F-32)*5)/9;
return c;
}
public TemperatureEJB(){}
public void ejbCreate(){}
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}
public void setSessionContext(SessionContext sc){}
}
----------Client class----------
package com.deg;
import com.deg.Temperature;
import com.deg.TemperatureHome;
import javax.naming.Context;
import java.io.*;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

public class TemperatureClient
{
public static void main(String[] args)
{
TemperatureHome home;
BufferedReader stdin;
try
{
Context initial = new InitialContext();
Object objref = initial.lookup("MyTemperature");
home = (TemperatureHome)PortableRemoteObject.narrow(objref,TemperatureHome.class);
Temperature degreeConverter = home.create();
try
{
double F=0;
while(F!='q')
{
stdin = new BufferedReader(new InputStreamReader(System.in));
System.out.print("\n\n Enter the temperature in Fahrenheit (Type 'q' to quit):");
F= Double.parseDouble(stdin.readLine());
double Cel = degreeConverter.FahrenheitToCelsius(F);
System.out.println("The temperature in Celsius:" + String.valueOf(Cel));
}
}catch(Exception e){System.out.println("Thank you!");}
degreeConverter.remove();
}catch(Exception ex){System.err.println("Caught an unexpected exception!");
ex.printStackTrace();}
}
}
------------ejb-jar.xml------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>TemperatureBean</ejb-name>
<home>com.deg.TemperatureHome</home>
<remote>com.deg.Temperature</remote>
<ejb-class>com.deg.TemperatureEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

----------weblogic-ejb-jar.xml------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN" "www.bea.com/.../weblogic-ejb-jar.dtd">
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>TemperatureBean</ejb-name>
<jndi-name>MyTemperature</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>

----------Exception while running the client program--------
Caught an unexpected exception!
javax.naming.NameNotFoundException: Unable to resolve MyTemperature. Resolved: '
' Unresolved:'MyTemperature' ; remaining name ''
at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundR
equest.java:85)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:253)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteR
ef.java:220)
at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
at $Proxy0.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:323)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at TemperatureClient.main(TemperatureClient.java:21)

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Help Package,Deploy and Run EJB in Weblogic6.1 Or get search suggestion and latest updates.




Tagged: