Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

a problem with a very simple statless ejb

  Asked By: Bill    Date: Jun 25    Category: Java    Views: 783
  

I'm trying to deploy a very simple stateless ejb. It's a little temperature
converter - from Celsius to Fahrenhet and back. The source compile with out
any problems, but I for some reason can't deploy it. I have an identical
bean that I copied from the book and it works. These two beans are almost
identical, except for the logic. I went through the working bean one line
at a time, and I still can't figure out why it works, and the other one
doesn't. Below are the sources and the stack trace. If any one could help
I'd greatly appreciate it.

home interface:
************************************
package com.alnsab.convert;

public interface TemperatureConverterHome extends javax.ejb.EJBHome {
TemperatureConverter create()
throws java.rmi.RemoteException, javax.ejb.CreateException;
}

remote interface:
************************************
package com.alnsab.convert;

public interface TemperatureConverter extends javax.ejb.EJBObject {

String getCelsius(String fahrenheit) throws
java.rmi.RemoteException;

String getFahrenheit(String celsius) throws
java.rmi.RemoteException;
}

implementation class:
************************************
package com.alnsab.convert;

public class TemperatureConverterBean implements javax.ejb.SessionBean {

/**
* Calculate temperature in Fahrenheit, using this formula:
* Tf = ((9/5)*Tc)+32
*/

public String getFahrenheit ( String celsius ) {


return Long.toString( ((9/5) * Long.parseLong(celsius)) +
32);
}


/**
* Calculate temperature in Celsius, using this formula:
* Tf = ((9/5)*Tc)+32 Tc = (Tf - 32) * 5/9
*/

public String getCelsius ( String fahrenheit ) {

return Long.toString( (Long.parseLong(fahrenheit) - 32) *
(5/9) );
}


public void ejbCreate() { }

public void ejbRemove() { }

public void ejbActivate() { }

public void ejbPassivate() { }

public void setSessionContext(javax.ejb.SessionContext ctx) { }
}

ejb-jar.xml
*****************************************
<?xml version="1.0"?>

<!DOCTYPE ejb-jar PUBLIC
'-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN'
'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>

<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>TemperatureConverter</ejb-name>
<home>com.alnsab.tempconv.TemperatureConverterHome</home>
<remote>com.alnsab.tempconv.TemperatureConverter</remote>
<ejb-class>com.alnsab.tempconv.TemperatureConveterBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>TemperatureConverter</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

weblogic-ejb-jar.xml
****************************************
<?xml version="1.0"?>

<!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>TemperatureConverter</ejb-name>
<jndi-name>TempConv</jndi-name>

</weblogic-enterprise-bean>

</weblogic-ejb-jar>



stack trace:
*****************************************
[alex@mandrake alnsab61]$ <Sep 16, 2002 11:37:35 AM PDT> <Error> <J2EE>
<Error deploying application tempconv:

Unable to deploy EJB: tempconv.jar from tempconv.jar:


com.alnsab.tempconv.TemperatureConveterBean
at weblogic.ejb20.ejbc.EJBCompiler.setupEJB(EJBCompiler.java:130)
at weblogic.ejb20.deployer.Deployer.runEJBC(Deployer.java:295)
at weblogic.ejb20.deployer.Deployer.compileEJB(Deployer.java:676)
at weblogic.ejb20.deployer.Deployer.deploy(Deployer.java:843)
at weblogic.j2ee.EJBComponent.deploy(EJBComponent.java:30)
at weblogic.j2ee.Application.addComponent(Application.java:160)
at weblogic.j2ee.J2EEService.addDeployment(J2EEService.java:117)
at

weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(DeploymentTarge\
t.java:329)

at

weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(DeploymentTarge\
t.java:144)

at java.lang.reflect.Method.invoke(Native Method)
at

weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl.jav\
a:608)

at

weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:592)

at

weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBeanImp\
l.java:352)

at
com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
at
com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at

weblogic.management.internal.ConfigurationMBeanImpl.updateConfigMBeans(Configura\
tionMBeanImpl.java:484)

at

weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBeanImp\
l.java:354)

at
com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
at
com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at

weblogic.management.internal.DynamicMBeanImpl.addDeployment(DynamicMBeanImpl.jav\
a:945)

at

weblogic.management.internal.DynamicMBeanImpl.addDeployment(DynamicMBeanImpl.jav\
a:932)

at
weblogic.management.internal.DynamicMBeanImpl.add(DynamicMBeanImpl.java:917)
at

weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl.jav\
a:620)

at

weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:592)

at

weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBeanImp\
l.java:352)

at
com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
at
com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at
weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:449)
at
weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:190)
at $Proxy72.addTarget(Unknown Source)
at

weblogic.management.mbeans.custom.ApplicationManager.autoDeploy(ApplicationManag\
er.java:837)

at

weblogic.management.mbeans.custom.ApplicationManager.addApplication(ApplicationM\
anager.java:936)

at

weblogic.management.mbeans.custom.ApplicationManager.addApplication(ApplicationM\
anager.java:856)

at

weblogic.management.mbeans.custom.ApplicationManager.poll(ApplicationManager.jav\
a:772)

at

weblogic.management.mbeans.custom.ApplicationManager.poll(ApplicationManager.jav\
a:705)

at

weblogic.management.mbeans.custom.ApplicationManager.update(ApplicationManager.j\
ava:200)

at java.lang.reflect.Method.invoke(Native Method)
at

weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl.jav\
a:608)

at

weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:592)

at

weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBeanImp\
l.java:352)

at
com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
at
com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at
weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:449)
at
weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:190)
at $Proxy5.update(Unknown Source)
at

weblogic.management.console.webapp._domain.__upload_app._jspService(__upload_app\
.java:149)

at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at

weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265\
)

at

weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200\
)

at

weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.ja\
va:215)

at
weblogic.servlet.jsp.PageContextImpl.forward(PageContextImpl.java:112)
at

weblogic.management.console.actions.ForwardAction.perform(ForwardAction.java:35)

at

weblogic.management.console.actions.internal.ActionServlet.doAction(ActionServle\
t.java:167)

at

weblogic.management.console.actions.internal.ActionServlet.doPost(ActionServlet.\
java:85)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at

weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:265\
)

at

weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200\
)

at

weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContex\
t.java:2456)

at

weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:203\
9)

at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)


Share: 

 

4 Answers Found

 
Answer #1    Answered By: Alexander Fields     Answered On: Jun 25

make sure that tempconv.jar is included in your classpath.

 
Answer #2    Answered By: Vivian Ruiz     Answered On: Jun 25

I'm deploying  it on weblogic, the server takes care of loading of this bean.
there's something else...

 
Answer #3    Answered By: Harold Graham     Answered On: Jun 25

what happens when you run ejbc on it without deploying  it to the server?

 
Answer #4    Answered By: Giovanna Silva     Answered On: Jun 25

I managed to fix the problem  - stupidity was on my part - there was an error in
the package  name, in the source.
Afterwards, I was able to deploy, and connect to the bean.

Strangely though, this is what I get after running weblogic.ejbc:

[alex@thinkpad java]$ java  weblogic.ejbc -compiler java
/home/alex/Development/java/jars/tempconv.jar
/home/alex/Development/java/jars/ejbc_tempconv
.jar
<Sep 16, 2002 9:45:06 PM PDT> <Warning> <EJB> <EJB Deployment:
TemperatureConverter has a class
com.alnsab.convert.TemperatureConverterBean which is in the classpath. This
class should only be located in the ejb-jar file.>
<Sep 16, 2002 9:45:06 PM PDT> <Warning> <EJB> <EJB Deployment:
TemperatureConverter has a class
com.alnsab.convert.TemperatureConverterHome which is in the classpath. This
class should only be located in the ejb-jar file.>
<Sep 16, 2002 9:45:06 PM PDT> <Warning> <EJB> <EJB Deployment:
TemperatureConverter has a class
com.alnsab.convert.TemperatureConverter which is in the classpath. This class
should only be located in the ejb-jar file.>
Unrecognized option: -nowarn
Could not create the Java virtual machine.
Exec failed .. exiting

The warnings I understand, but what's up with the '-nowarn' ?

 
Didn't find what you were looking for? Find more on a problem with a very simple statless ejb Or get search suggestion and latest updates.




Tagged: