NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
sarad
Joined: 28 Sep 2010 Posts: 14
|
Posted: Fri Nov 04, 2011 4:16 am Post subject: remote ejb call failing |
|
|
Hi ,
I am using Glassfish 3.1 with netbeans 7.1 . I have two projects - utility and ejb.
In project ejb, I have Impl class of the session bean and in project utility I have the Remote Interface of the same bean.
I am using the following connection code
remote = (NewSessionBeanRemote) ctx.lookup("java:global/ejb.NewSessionBean");
and
@Stateless (name="java:global/ejb.NewSessionBean")
public class NewSessionBean implements NewSessionBeanRemote {
...}
However , I am getting the naming exception and lookup is failed. Can anyone suggest the appropriate JNDI lookup expression when remote and Impl classes are in two different projects.
Thanks |
|
| Back to top |
|
 |
tdeit62
Joined: 06 Oct 2011 Posts: 36
|
Posted: Fri Nov 04, 2011 12:11 pm Post subject: Re: remote ejb call failing |
|
|
Is here any reason why the utility project cannot have a dependency on the
first project?
If that would be permitted, then don't use lookup, use CDI. (Not supported
in JBoss .. although I've not tried it with the latest JBoss
implementations!)
Ie in your utility class just use
@EJB
Private NewSessionBeanRemote nsbr;
The classic pattern, however, is to have the remote interface in an
independent (third) class library, with both primary projects having a
dependency on the library. That way you can introduce some separation in the
dependencies .. it also makes refactoring in future a little less painful.
Alternatively, boot the project(s) in Glassfish and look at the startup
trace, it'll tell you the public JNDI names for the various EBJ objects it
creates. What looks like you're missing is the full class qualification ..
ie the complete class specification including package name.
Tony Dietrich
-----Original Message-----
From: sarad [mailto:address-removed]
Sent: 04 November 2011 04:17
To: address-removed
Subject: [nbj2ee] remote ejb call failing
Hi ,
I am using Glassfish 3.1 with netbeans 7.1 . I have two projects - utility
and ejb.
In project ejb, I have Impl class of the session bean and in project utility
I have the Remote Interface of the same bean.
I am using the following connection code
remote = (NewSessionBeanRemote)
ctx.lookup("java:global/ejb.NewSessionBean");
and
@Stateless (name="java:global/ejb.NewSessionBean")
public class NewSessionBean implements NewSessionBeanRemote {
...}
However , I am getting the naming exception and lookup is failed. Can anyone
suggest the appropriate JNDI lookup expression when remote and Impl classes
are in two different projects.
Thanks |
|
| Back to top |
|
 |
sarad
Joined: 28 Sep 2010 Posts: 14
|
Posted: Sat Nov 05, 2011 12:04 am Post subject: |
|
|
Actually I am trying to have the same classic pattern you are referring to .
I have three tiers (projects) viz.
1. a client (javafx 2.0 application ) ,
2. ejb( remoteEjbImp )and
3. utility ( containing remoteEjbInterface and serviceLocator) as three different projects.
utility is the class library which both client and ejb refers to .
When client calls serviceLocator to provide ejb , as remoteEjbInterface and remoteEjbImpl are in two different projects, somehow I am not able to call the ejb.
As you suggested I tried to have CDI in servicelocator ( which is in utility class library), null value was returned.
Also as per your suggestion, I booted the glassfish and found out the following jNDI names.
INFO: Portable JNDI names for EJB NewSessionBean : [java:global/FXDemoEjbs/NewSessionBean!ejb.NewSessionBeanRemote, java:global/FXDemoEjbs/NewSessionBean]
INFO: Glassfish-specific (Non-portable) JNDI names for EJB NewSessionBean : [NewSessionBean#ejb.NewSessionBeanRemote, NewSessionBean]
However, trying these names in context lookup either gives me
(1) names not found exception or
(2) SEVERE: IIOP1005: An exception has occured in the ejb security initialization.
org.jvnet.hk2.component.ComponentException: injection failed on org.glassfish.api.invocation.InvocationManagerImpl.invHandlers with class [Lorg.glassfish.api.invocation.ComponentInvocationHandler;
followed by
java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/ejb/RemoveException.
| Code: | public NewSessionBeanRemote connect2ejb() {
NewSessionBeanRemote remote =null;
try {
Properties props=new Properties();
props.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort","3700"); //default is 3700
InitialContext ctx = new InitialContext(props);
System.out.println("trial13...");
// remote = (NewSessionBeanRemote) ctx.lookup("NewSessionBean#ejb.NewSessionBeanRemote"); // Pattern for Zndi.
// remote = (NewSessionBeanRemote) ctx.lookup("java:global/FXDemoEjbs/NewSessionBean!ejb.NewSessionBeanRemote");
remote = (NewSessionBeanRemote) ctx.lookup("java:global/FXDemoEjbs/NewSessionBean");
} catch (Exception e) {
e.printStackTrace();
}
return remote;
}
|
Any Idea where I might be going wrong. |
|
| Back to top |
|
 |
sarad
Joined: 28 Sep 2010 Posts: 14
|
Posted: Sat Nov 05, 2011 6:19 pm Post subject: how to convert javafx application into an Enterprise Application Client in Netbeans 7.1 |
|
|
I got the solution, for this I have to make the client side an Enterprise Application Client. I was able to run it by using simple main file as a client and then injecting the RemoteEjbInterface.
Thanks |
|
| Back to top |
|
 |
tdeit62
Joined: 06 Oct 2011 Posts: 36
|
Posted: Sun Nov 06, 2011 10:45 am Post subject: Re: remote ejb call failing |
|
|
I'm afraid all I can do is suggest you run through this example:
http://netbeans.org/kb/docs/javaee/entappclient.html
and compare the results with your project. It may help pick out any errors
you are making.
Tony Dietrich
-----Original Message-----
From: sarad [mailto:address-removed]
Sent: 05 November 2011 00:04
To: address-removed
Subject: [nbj2ee] remote ejb call failing
Actually I am trying to have the same classic pattern you are referring to .
I have three tiers (projects) viz.
1. a client (javafx 2.0 application ) ,
2. ejb( remoteEjbImp )and
3. utility ( containing remoteEjbInterface and serviceLocator) as three
different projects.
utility is the class library which both client and ejb refers to .
When client calls serviceLocator to provide ejb , as remoteEjbInterface and
remoteEjbImpl are in two different projects, somehow I am not able to call
the ejb.
As you suggested I tried to have CDI in servicelocator ( which is in utility
class library), null value was returned.
Also as per your suggestion, I booted the glassfish and found out the
following jNDI names.
INFO: Portable JNDI names for EJB NewSessionBean :
[java:global/FXDemoEjbs/NewSessionBean!ejb.NewSessionBeanRemote,
java:global/FXDemoEjbs/NewSessionBean]
INFO: Glassfish-specific (Non-portable) JNDI names for EJB NewSessionBean :
[NewSessionBean#ejb.NewSessionBeanRemote, NewSessionBean]
However, trying these names in context lookup either gives me
(1) names not found exception or
(2) SEVERE: IIOP1005: An exception has occured in the ejb security
initialization.
org.jvnet.hk2.component.ComponentException: injection failed on
org.glassfish.api.invocation.InvocationManagerImpl.invHandlers with class
[Lorg.glassfish.api.invocation.ComponentInvocationHandler;
followed by
java.lang.ClassFormatError: Absent Code attribute in method that is not
native or abstract in class file javax/ejb/RemoveException.
Code:
public NewSessionBeanRemote connect2ejb() {
NewSessionBeanRemote remote =null;
try {
Properties props=new Properties();
props.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.S
erialInitContextFactory");
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
props.setProperty("org.omg.CORBA.ORBInitialPort","3700"); //default
is 3700
InitialContext ctx = new InitialContext(props);
System.out.println("trial13...");
// remote = (NewSessionBeanRemote)
ctx.lookup("NewSessionBean#ejb.NewSessionBeanRemote"); // Pattern for Zndi.
// remote = (NewSessionBeanRemote)
ctx.lookup("java:global/FXDemoEjbs/NewSessionBean!ejb.NewSessionBeanRemote")
;
remote = (NewSessionBeanRemote)
ctx.lookup("java:global/FXDemoEjbs/NewSessionBean");
} catch (Exception e) {
e.printStackTrace();
}
return remote;
}
Any Idea where I might be going wrong. |
|
| Back to top |
|
 |
tdeit62
Joined: 06 Oct 2011 Posts: 36
|
Posted: Sun Nov 06, 2011 9:51 pm Post subject: Re: remote ejb call failing |
|
|
No.
And AFAIK, there's limited support for embedding JavaFX into a Swing
application, but you could take a look at the JavaFXtras package. Last time
I looked at this people were being warned that support for embedding was
being phased out, but I've also seen some comments that the JavaFXtras
project has a new bridge out...
Tony Dietrich
-----Original Message-----
From: sarad [mailto:address-removed]
Sent: 05 November 2011 18:19
To: address-removed
Subject: [nbj2ee] remote ejb call failing
I got the solution, for this I have to make the client side an Enterprise
Application Client. I was able to run it by using simple main file as a
client and then injecting the RemoteEjbInterface .
However for my requirement , I have JavaFx application as client side.
Is there any automated process in nebeans 7.1 to convert the JavaFx
application an Enterprise Application Client ?
Thanks |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|