aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes ejb 3.0,jboss 4.2.2 netbeans 6.0.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejb 3.0,jboss 4.2.2 netbeans 6.0.1" Watch "ejb 3.0,jboss 4.2.2 netbeans 6.0.1" New topic
Author

ejb 3.0,jboss 4.2.2 netbeans 6.0.1

riccardo alfrilli
Greenhorn

Joined: Mar 03, 2008
Posts: 16
Hi all,i'm trying to implements a simple EJB application using NetBeans 6.0.1 and jboss 4.2.2 . This is my code:

package ejb;

import javax.ejb.Stateless;

@Stateless
public class NewSessionBean implements NewSessionRemote {

public void helloWorld() {
System.out.println("HelloWorld");
}
/**********************************************************************/

package ejb;

import javax.ejb.Remote;

@Remote
public interface NewSessionRemote {
void helloWorld();

}
/******************************************************************/

package try_pkg;

import ejb.NewSessionRemote;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class ServiceLocator {

NewSessionRemote nsr;

ServiceLocator(){
nsr= this.lookupNewSessionBean();
}

private NewSessionRemote lookupNewSessionBean() {
try {
Properties env = new Properties();
env.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces");

Context ctx = new InitialContext(env);
return (NewSessionRemote) ctx.lookup("NewSessionBean");
} catch (NamingException ne) {
java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.SEVERE, "exception caught", ne);
throw new RuntimeException(ne);
}
}
public void helloWorld(){
nsr.helloWorld();
}
}
/***********************************************************************/

package try_pkg;

public class MainClass {
public static void main(String []args)
{
ServiceLocator sl=new ServiceLocator();
sl.helloWorld();
}
}

/********************************************************************/
And this is my jndi namespace in http://localhost:8080/jmx-console/HtmlAdaptor

+- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
+- jmx (class: org.jnp.interfaces.NamingContext)
| +- invoker (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor (proxy: $Proxy47 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
| +- rmi (class: org.jnp.interfaces.NamingContext)
| | +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
+- HTTPXAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
+- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
+- UserTransactionSessionFactory (proxy: $Proxy14 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
+- HTTPConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
+- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
+- TransactionSynchronizationRegistry (class: com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple)
+- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
+- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
+- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
+- queue (class: org.jnp.interfaces.NamingContext)
| +- A (class: org.jboss.mq.SpyQueue)
| +- testQueue (class: org.jboss.mq.SpyQueue)
| +- ex (class: org.jboss.mq.SpyQueue)
| +- DLQ (class: org.jboss.mq.SpyQueue)
| +- D (class: org.jboss.mq.SpyQueue)
| +- C (class: org.jboss.mq.SpyQueue)
| +- B (class: org.jboss.mq.SpyQueue)
+- topic (class: org.jnp.interfaces.NamingContext)
| +- testDurableTopic (class: org.jboss.mq.SpyTopic)
| +- testTopic (class: org.jboss.mq.SpyTopic)
| +- securedTopic (class: org.jboss.mq.SpyTopic)
+- console (class: org.jnp.interfaces.NamingContext)
| +- PluginManager (proxy: $Proxy48 implements interface org.jboss.console.manager.PluginManagerMBean)
+- NewSessionBean (class: org.jnp.interfaces.NamingContext)
| +- remote (proxy: $Proxy63 implements interface ejb.NewSessionRemote,interface org.jboss.ejb3.JBossProxy)
+- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
+- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
+- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
+- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
+- UUIDKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory)

/*************************************************************************/

Depends on the String that i pass to lookup method i have different errors
1)Exception in thread "main" java.lang.ClassCastException: org.jnp.interfaces.NamingContext cannot be cast to ejb.NewSessionRemote
2)not bound

i suppose that i have to configure the .xml file of my application....somebody can help me?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9318
    
109

Riccardo,

Welcome to JavaRanch

+- NewSessionBean (class: org.jnp.interfaces.NamingContext)
| +- remote (proxy: $Proxy63 implements interface ejb.NewSessionRemote,interface org.jboss.ejb3.JBossProxy)


Based on this output, your lookup string should be "NewSessionBean/remote"


[My Blog] [JavaRanch Journal]
riccardo alfrilli
Greenhorn

Joined: Mar 03, 2008
Posts: 16
Tnx for the rapid answer and the welcome!
However it doesn't work...here is the output:

Exception in thread "main" java.lang.NoClassDefFoundError: [Lorg/jboss/aop/advice/Interceptor;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
at java.lang.Class.getDeclaredField(Class.java:1880)
at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1610)
at java.io.ObjectStreamClass.access$700(ObjectStreamClass.java:52)
at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:425)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:413)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:310)
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:547)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.rmi.MarshalledObject.get(MarshalledObject.java:142)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:710)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at try_pkg.ServiceLocator.lookupNewSessionBean(ServiceLocator.java:34)
at try_pkg.ServiceLocator.<init>(ServiceLocator.java:23)
at try_pkg.MainClass.main(MainClass.java:15)
Caused by: java.lang.ClassNotFoundException: org.jboss.aop.advice.Interceptor
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 31 more

I have to set some xml file?I simply extract the zip file of jboss and when i create the project indicate the folder

Tnx again
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9318
    
109

Caused by: java.lang.ClassNotFoundException: org.jboss.aop.advice.Interceptor


Looks like you dont have the appropriate JBoss jar files in your classpath. Do you have the JBoss related jar files in the client's (MainClass) classpath? I usually place the jbossall-client.jar file (present in %JBOSS_HOME%/client) folder in the client's classpath.
riccardo alfrilli
Greenhorn

Joined: Mar 03, 2008
Posts: 16
yeah!that work!
really Tnx...I love you !
Anees Shaik
Greenhorn

Joined: Mar 27, 2008
Posts: 3
Hi
I am also trying to build a sample application in netbean 6.0.1 using Jboss AS 4.2.2 and EJB3. I will be glad if i can get working example and steps for the same.

early awaiting for the reply

Thank you
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9318
    
109

"AShaik"

Please check your private message for a message from JavaRanch.
 
jQuery in Action, 2nd edition
 
subject: ejb 3.0,jboss 4.2.2 netbeans 6.0.1
 
Similar Threads
netbeans 5.5 + Jboss 4.0.4 + EJB 3.0
Problem with this example
Problem deploying sample HelloWorld Bean in JBoss 4.2.1 GA
NameNotFoundException in database connectivity with Jboss
Stateful Bean Naming Exception