• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

what is wrong with this EJB

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends
This is the EJB sample that is provided by Budi Kurniawan:

The EJB's are as follows:

package com.brainysoftware.ejb;

import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;

public interface AdderHome extends EJBHome {
Adder create() throws RemoteException, CreateException;
}


package com.brainysoftware.ejb;

import javax.ejb.EJBObject;
import java.rmi.RemoteException;

public interface Adder extends EJBObject {
public int add(int a, int b) throws RemoteException;


package com.brainysoftware.ejb;

import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

public class AdderBean implements SessionBean {

public int add(int a, int b) {
System.out.println("from AdderBean");
return (a + b);
}

public void ejbCreate() {
}

public void ejbRemove() {
}

public void ejbActivate() {
}

public void ejbPassivate() {
}

public void setSessionContext(SessionContext sc) {
}
}


The one below is the ejb-jar.xml that goes with these EJBs

<?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>
<description>Your first EJB application </description>
<display-name>Adder Application</display-name>
<enterprise-beans>
<session>
<ejb-name>Adder</ejb-name>
<home>com.brainysoftware.ejb.AdderHome</home>
<remote>com.brainysoftware.ejb.Adder</remote>
<ejb-class>com.brainysoftware.ejb.AdderBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>


I still get the following errors:
lCMFactory bound to 'java:/MinervaSharedLocalCMFactory'
[INFO,MinervaSharedLocalCMFactory] Started
[INFO,MinervaXACMFactory] Starting
[INFO,MinervaXACMFactory] Connection manager factory 'MinervaXACMFactory bound t
o 'java:/MinervaXACMFactory'
[INFO,MinervaXACMFactory] Started
[INFO,MinervaDS] Starting
[INFO,MinervaDS] Started
[INFO,JmsXA] Starting
[INFO,JmsXA] Started
[INFO,AutoDeployer] Starting
[INFO,AutoDeployer] Watching directory: C:\jboss\deploy
[INFO,AutoDeployer] Watching directory: C:\jboss\deploy\lib
[INFO,AutoDeployer] Auto deploy of file:/C:/jboss/deploy/lib/jms-ra.rar
[INFO,RARDeployer] Attempting to deploy RAR at 'file:/C:/jboss/deploy/lib/jms-ra
.rar'
[WARN,JmsXA] Using default value 'java efaultJMSProvider' for config property '
JmsProviderAdapterJNDI'
[INFO,JmsXA] FINE: Setting LogWriter: org.jboss.logging.log4j.CategoryWriter@afa
68a
[INFO,JmsXA] Bound connection factory for resource adapter 'JMS Adapter' to JNDI
name 'java:/JmsXA'
[INFO,AutoDeployer] Auto deploy of file:/C:/jboss/deploy/adder.jar
[INFO,J2eeDeployer] Deploy J2EE application: file:/C:/jboss/deploy/adder.jar
[INFO,J2eeDeployer] Create application adder.jar
[INFO,J2eeDeployer] install EJB module adder.jar
[INFO,ContainerFactory] Deploying:file:/C:/jboss/tmp/deploy/Default/adder.jar
[ERROR,ContainerFactory]
Bean : Adder
Section: 16.2
Warning: The Bean Provider must specify the fully-qualified name of the enterpri
se bean's home interface in the home element.

[ERROR,ContainerFactory]
Bean : Adder
Section: 16.2
Warning: The Bean Provider must specify the fully-qualified name of the enterpri
se bean's remote interface in the remote element.

[INFO,ContainerFactory] Deploying Adder
[ERROR,ContainerFactory] DeploymentError
java.lang.ClassNotFoundException: com.brainysoftware.ejb.AdderHome
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at org.jboss.ejb.StatelessSessionContainer.init(StatelessSessionContaine
r.java:147)
at org.jboss.ejb.Application.init(Application.java:202)
at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:372)
at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:306)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:487)

at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:
459)
at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:190)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.deployment.AutoDeployer.deploy(AutoDeployer.java:395)
at org.jboss.deployment.AutoDeployer.run(AutoDeployer.java:233)
at org.jboss.deployment.AutoDeployer.startService(AutoDeployer.java:371)

at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103
)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(Conf
igurationService.java:967)
at $Proxy0.start(Unknown Source)
at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.Main.<init>(Main.java:208)
at org.jboss.Main$1.run(Main.java:110)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.Main.main(Main.java:106)
[ERROR,J2eeDeployer] Starting adder.jar failed!
[ERROR,Default] java.lang.NullPointerException
[ERROR,Default] at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker
.stop(BaseLocalContainerInvoker.java:152)
[ERROR,Default] at org.jboss.ejb.Container.stop(Container.java:382)
[ERROR,Default] at org.jboss.ejb.StatelessSessionContainer.stop(Stateles
sSessionContainer.java:216)
[ERROR,Default] at org.jboss.ejb.Application.stop(Application.java:231)
[ERROR,Default] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactor
y.java:400)
[ERROR,Default] at org.jboss.ejb.ContainerFactory.deploy(ContainerFactor
y.java:306)
[ERROR,Default] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native M
ethod)
[ERROR,Default] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMet
hodAccessorImpl.java:39)
[ERROR,Default] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Deleg
atingMethodAccessorImpl.java:25)
[ERROR,Default] at java.lang.reflect.Method.invoke(Method.java:324)
[ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
rverImpl.java:1628)
[ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
rverImpl.java:1523)
[ERROR,Default] at org.jboss.deployment.J2eeDeployer.startModules(J2eeDe
ployer.java:487)
[ERROR,Default] at org.jboss.deployment.J2eeDeployer.startApplication(J2
eeDeployer.java:459)
[ERROR,Default] at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer
.java:190)
[ERROR,Default] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native M
ethod)
[ERROR,Default] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMet
hodAccessorImpl.java:39)
[ERROR,Default] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Deleg
atingMethodAccessorImpl.java:25)
[ERROR,Default] at java.lang.reflect.Method.invoke(Method.java:324)
[ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
rverImpl.java:1628)
[ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
rverImpl.java:1523)
[ERROR,Default] at org.jboss.deployment.AutoDeployer.deploy(AutoDeployer
.java:395)
[ERROR,Default] at org.jboss.deployment.AutoDeployer.run(AutoDeployer.ja
va:233)
[ERROR,Default] at org.jboss.deployment.AutoDeployer.startService(AutoDe
ployer.java:371)
[ERROR,Default] at org.jboss.util.ServiceMBeanSupport.start(ServiceMBean
Support.java:103)
[ERROR,Default] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown S
ource)
[ERROR,Default] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Deleg
atingMethodAccessorImpl.java:25)
[ERROR,Default] at java.lang.reflect.Method.invoke(Method.java:324)
[ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
rverImpl.java:1628)
[ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
rverImpl.java:1523)
[ERROR,Default] at org.jboss.configuration.ConfigurationService$ServiceP
roxy.invoke(ConfigurationService.java:967)
[ERROR,Default] at $Proxy0.start(Unknown Source)
[ERROR,Default] at org.jboss.util.ServiceControl.start(ServiceControl.ja
va:79)
[ERROR,Default] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native M
ethod)
[ERROR,Default] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMet
hodAccessorImpl.java:39)
[ERROR,Default] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Deleg
atingMethodAccessorImpl.java:25)
[ERROR,Default] at java.lang.reflect.Method.invoke(Method.java:324)
[ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
rverImpl.java:1628)
[ERROR,Default] at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanSe
rverImpl.java:1523)
[ERROR,Default] at org.jboss.Main.<init>(Main.java:208)
[ERROR,Default] at org.jboss.Main$1.run(Main.java:110)
[ERROR,Default] at java.security.AccessController.doPrivileged(Native Me
thod)
[ERROR,Default] at org.jboss.Main.main(Main.java:106)
[INFO,J2eeDeployer] Module adder.jar is not running
[INFO,J2eeDeployer] Destroying application adder.jar
[ERROR,AutoDeployer] DeploymentInfo failed:file:/C:/jboss/deploy/adder.jar
org.jboss.deployment.J2eeDeploymentException: Error while starting adder.jar: nu
ll, Cause: java.lang.NullPointerException
at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:530)

at org.jboss.deployment.J2eeDeployer.startApplication(J2eeDeployer.java:
459)
at org.jboss.deployment.J2eeDeployer.deploy(J2eeDeployer.java:190)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.deployment.AutoDeployer.deploy(AutoDeployer.java:395)
at org.jboss.deployment.AutoDeployer.run(AutoDeployer.java:233)
at org.jboss.deployment.AutoDeployer.startService(AutoDeployer.java:371)

at org.jboss.util.ServiceMBeanSupport.start(ServiceMBeanSupport.java:103
)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.configuration.ConfigurationService$ServiceProxy.invoke(Conf
igurationService.java:967)
at $Proxy0.start(Unknown Source)
at org.jboss.util.ServiceControl.start(ServiceControl.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.Main.<init>(Main.java:208)
at org.jboss.Main$1.run(Main.java:110)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.Main.main(Main.java:106)
Caused by: java.lang.NullPointerException
at org.jboss.ejb.plugins.local.BaseLocalContainerInvoker.stop(BaseLocalC
ontainerInvoker.java:152)
at org.jboss.ejb.Container.stop(Container.java:382)
at org.jboss.ejb.StatelessSessionContainer.stop(StatelessSessionContaine
r.java:216)
at org.jboss.ejb.Application.stop(Application.java:231)
at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:400)
at org.jboss.ejb.ContainerFactory.deploy(ContainerFactory.java:306)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.deployment.J2eeDeployer.startModules(J2eeDeployer.java:487)

... 30 more
[INFO,AutoDeployer] Auto deploy of file:/C:/jboss/deploy/lib/jbosspool-jdbc.rar
[INFO,RARDeployer] Attempting to deploy RAR at 'file:/C:/jboss/deploy/lib/jbossp
ool-jdbc.rar'
[INFO,RARMetaData] Loading Minerva Resource Adapter for JDBC 1/2 drivers
[INFO,RARMetaData] Required license terms present. See deployment descriptor.
[WARN,MinervaDS] Not setting config property 'Password'
[WARN,MinervaDS] Not setting config property 'Driver'
[WARN,MinervaDS] Not setting config property 'UserName'
[INFO,MinervaDS] Bound connection factory for resource adapter 'Minerva JDBC Loc
alTransaction ResourceAdapter' to JNDI name 'java:/MinervaDS'
[INFO,AutoDeployer] Started
[INFO,JMXAdaptorService] Starting
[INFO,JMXAdaptorService] Started
[INFO,RMIConnectorService] Starting
[INFO,RMIConnectorService] Started
[INFO,MailService] Starting
[INFO,MailService] Mail Service 'Mail' bound to java:/Mail
[INFO,MailService] Started
[INFO,ServiceControl] Started 47 services
[INFO,Default] JBoss-2.4.4 Started in 0m:7s.270
[INFO,AutoDeployer] Auto undeploy of file:/C:/jboss/deploy/adder.jar
[ERROR,AutoDeployer] Undeployment failed
org.jboss.deployment.J2eeDeploymentException: The application " Default" has not
been deployed.
at org.jboss.deployment.J2eeDeployer.undeploy(J2eeDeployer.java:279)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:16
28)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:15
23)
at org.jboss.deployment.AutoDeployer.undeploy(AutoDeployer.java:415)
at org.jboss.deployment.AutoDeployer.run(AutoDeployer.java:196)
at java.lang.Thread.run(Thread.java:534)
------------------

all help is appreciated. Thanks in advance
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rahul,
It�s absolutely nothing wrong with this ejb classes and the deployment descriptor you�ve sent. I compiled those classes, packed them and deploy them on weblogic; it worked just fine. In my opinion you have a packing problem. Hence try to make sure that your jar has this structure (all files are required):
/com/brainysoftware/ejb/Adder.class
/com/brainysoftware/ejb/AdderBean.class
/com/brainysoftware/ejb/AdderHome.class
META-INF/ejb-jar.xml
Manifest.mf (optional)
By the way, because I deployed this bean on weblogic8.1 I had to add the weblogic-ejb-jar.xml file META-INF folder. Here I specified the bean�s jndi name like this:

And by the way, check jboss documentation and find out how can you specify jndi name for your bean. I guess you have to dig up and find out how to pack ejbs for jboss.
Regards.
 
rahul bivalkar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi valentin
Thank you so much. Your invaluble help really helped. I could run iut without any fuss.
Now I have a client program BeanClient.java to test these EJBs and it is as follows:

import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import java.util.Properties;
import com.brainysoftware.ejb.Adder;
import com.brainysoftware.ejb.AdderHome;

public class BeanClient {

public static void main(String[] args) {
// preparing properties for constructing an InitialContext object
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "localhost:1099");

try {
// Get an initial context
InitialContext jndiContext = new InitialContext(properties);
System.out.println("Got context");

// Get a reference to the Bean
Object ref = jndiContext.lookup("Adder");
System.out.println("Got reference");

// Get a reference from this to the Bean's Home interface
AdderHome home = (AdderHome)
PortableRemoteObject.narrow (ref, AdderHome.class);

// Create an Adder object from the Home interface
Adder adder = home.create();
System.out.println ("2 + 5 = " + adder.add(2, 5));
}
catch(Exception e) {
System.out.println(e.toString());
}
}
}
-----------

I included jars in <JBOSS_HOME>/client directory ( jboss-client.jar, and jnp-client.jar). I was suggested by the author to include ejb.jar too, but i cannot find that file there.

So when i run the application like below,
C:\classes>javac -classpath C:\jboss\client\*.jar;. BeanClient.java
error: cannot read: BeanClient.java
1 error

this is what i get. What could be wrong? Many thanks for any suggestions or way out.

thanks
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


So when i run the application like below,
C:\classes>javac -classpath C:\jboss\client\*.jar;. BeanClient.java
error: cannot read: BeanClient.java
1 error


This is a compile error actually, which tells you that your compiler cannot locate the BeanClient.java class. You have to specify the full path to this file in order for the class to be located. You also need to specify the classpath to your home and remote interfaces as well, to avoid other compile errors. I guess from your command line that they are located within the current directory, under the appropriate subfolder com\brainysoftware\ejb.
By the way I tested the client as well and it works fine. Of course I had to do few weblogic specific changes, but it worked pretty smoothly after that. You just need to be careful to specify the correct jundi name of your bean. In my case I had to make this change:

Regards.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic