Ejb access
Hi,
I'm currently trying to get to know Java EE and thus playing around a little. But off course this means some trouble can happen along the road...
I created an EJB called TitleCheckerBean with a local interface TitleCheckerLocal which I can use without problems in a servlet like this:
public class PostMessage extends HttpServlet {
@EJB
private TitleCheckerLocal titleChecker;
if (!titleChecker.checkTitle(e)) {
response.sendRedirect("invalidMessage.jsp");
} else { ...However, I tried doing the same using JSP and the following code but with a more negative result:
initCtx = new InitialContext();
TitleCheckerLocal titleChecker = (TitleCheckerLocal)initCtx.lookup("java:comp/env/ejb/TitleCheckerLocal");
ConnectionFactory connectionFactory = (ConnectionFactory)initCtx.lookup("jms/NewMessageFactory");
Queue queue = (Queue)initCtx.lookup("jms/NewMessage");Using this code, I get:
javax.naming.NameNotFoundException: No object bound to name java:comp/env/ejb/TitleCheckerLocal
However, my ConnectionFactory and Queue pose no problems.
So the question is what am I forgetting to do, because I read in numerous threads that to access an EJB from a JSP this is the way to go, but obviously not in my case. I suppose the @EJB annotation used in the servlet is doing some 'under the hood magic' that is not happening in the JSP case, but which kind of magic?
Is there maybe some *.xml I also need to change?
Thanks!
Vaak
Hi,
this thing keeps annoying me...
Referring to my first post in this thread, how come that in case of the JSP page, I need to add the ejb-local-ref in web.xml to resolve the lookup in JNDI, while this is not needed for the servlet case using the @EJB annotation?
As far as the code is concerned both cases get the same info (a local interface), but only for one of them it's enough to find which EJB is meant. Are they searching in different contexts or is the annotation doing some magic or ...
I hope I'm not blind to the obvious here!
Regards,
Vaak
Similar Messages
-
Hello everyone,
I developed a Web Service prototype accessing remote EJB using the EJB
control with special syntax in the jndi-name attribute: @jws:ejb
home-jndi-name="t3://10.10.245.70:7131/AccountDelegatorEJB"
Everything works fine, but I get an error when I restrict access to my web
service with a declarative security model by implementing steps provided in
help doc:
- Define the web resource you wish to protect
- Define which security role is required to access the web resource
- Define which users are granted the required security role
- Configure WebLogic Server security for my web service(Compatibility
Security/Users)
I launch the service by entering the address in a web browser. When prompted
to accept the digital certificate, click Yes, when prompted for network
authentication information, enter username and password, navigate to the
Test Form tab of Test View, invoke the method by clicking the button and I
get the following exception:
<error>
<faultcode>JWSError</faultcode>
<faultstring>Error during JNDI lookup from
jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookup failed for
name:t3://10.10.245.70:7131/AccountDelegatorEJB]</faultstring>
<detail>
<jwErrorDetail> weblogic.jws.control.ControlException: Error during JNDI
lookup from jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookup failed
for name:t3://10.10.245.70:7131/AccountDelegatorEJB] at
weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
8) at
weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
.java:220) at
weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260) at
ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
ibas.GetSecure.retrieveVisaHistoryTxn(GetSecure.jws:64) </jwErrorDetail>
</detail>
</error>
I have a simple Hello method as well in my WebService (which is also
restricted) and it works fine, but remote EJB access doesn't. I tested my
prototype on Weblogic 7.2 and 8.1 platforms - same result.
Is that a bug or I am missing some additional configuration in order to get
that working. Has anyone seen similar behavior? Is there a known resolution?
Or a suggested way to work around the problem?
Thank you.
AndreAndre,
It would be best if this issue is handled as an Eval Support case. Please
BEA Customer Support at http://support.beasys.com along with the required
files, and request that an Eval support case be created for this issue.
Thanks
Raj Alagumalai
WebLogic Workshop Support
"Andre Shergin" <[email protected]> wrote in message
news:[email protected]...
Anurag,
I removed "t3", still get an error but a different one (Unable to create
InitialContext:null):
<error>
<faultcode>JWSError</faultcode>
<faultstring>Error during JNDI lookup from
jndi://secuser1:[email protected]:7131/AccountDelegatorEJB[Unable to
create InitialContext:null]</faultstring>
<detail>
<jwErrorDetail> weblogic.jws.control.ControlException: Error during JNDI
lookup from
jndi://secuser1:[email protected]:7131/AccountDelegatorEJB[Unable to
create InitialContext:null] at
weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
8) at
weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
.java:220) at
weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260) at
ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
ibas.GetVisaHistoryTransactions.getVisaHistoryTxn(GetVisaHistoryTransactions
.jws:67) </jwErrorDetail>
</detail>
</error>
Note: inter-domain communication is configured properly. The Web Service to
remote EJB works fine without a declarative security.
Any other ideas?
Thank you for your help.
Andre
"Anurag" <[email protected]> wrote in message
news:[email protected]...
Andre,
It seems you are using the URL
jndi:t3://secuser1:[email protected]:7131/AccountDelegatorEJB
whereas you should not be specifying the "t3:" protocol.
The URL should be like
jndi://secuser1:[email protected]:7131/AccountDelegatorEJB
Please do let me know if you see any issues with this.
Note that this will only allow you to access remote EJBs in the same WLS
domain. For accessing EJBs on another domain, you need to configure
inter-domain communication by
following a few simple steps as mentioned at
http://e-docs.bea.com/wls/docs81/ConsoleHelp/jta.html#1106135. This link has
been provided in the EJB Control Workshop documentation.
Regards,
Anurag
"Andre Shergin" <[email protected]> wrote in message
news:[email protected]...
Raj,
I tried that before, it didn't help. I got similar error message:
<error>
<faultcode>JWSError</faultcode>
<faultstring>Error during JNDI lookup from
jndi:t3://secuser1:[email protected]:7131/AccountDelegatorEJB[Lookup
failed for
name:t3://secuser1:[email protected]:7131/AccountDelegatorEJB]</faultstr
ing>
<detail>
<jwErrorDetail> weblogic.jws.control.ControlException: Error during JNDI
lookup from
jndi:t3://secuser1:[email protected]:7131/AccountDelegatorEJB[Lookup
failed for
name:t3://secuser1:[email protected]:7131/AccountDelegatorEJB] at
weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
8) at
weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
.java:220) at
weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260) at
ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
ibas.GetSecure.retrieveVisaHistoryTxn(GetSecure.jws:64) </jwErrorDetail>
</detail>
</error>
Anything else should I try?
P.S. AccountDelegatorEJB, the remote EJB my Web Service calls is NOTaccess
restricted.
I hope there is a solution.
Thanks,
Andre
"Raj Alagumalai" <[email protected]> wrote in message
news:[email protected]...
Andre,
Can you try using the following url with username and password
jndi://username:password@host:7001/my.resource.jndi.object ?
once you add webapp level security, the authenticated is the user who
invokes the EJB.
http://e-docs.bea.com/workshop/docs81/doc/en/workshop/guide/controls/ejb/con
CreatingANewEJBControl.html?skipReload=true
has more info on using remote EJB's.
Hope this helps.
Thanks
Raj Alagumalai
WebLogic Workshop Support
"Alla Resnik" <[email protected]> wrote in message
news:[email protected]...
Hello everyone,
I developed a Web Service prototype accessing remote EJB using the EJB
control with special syntax in the jndi-name attribute: @jws:ejb
home-jndi-name="t3://10.10.245.70:7131/AccountDelegatorEJB"
Everything works fine, but I get an error when I restrict access to my
web
service with a declarative security model by implementing steps
provided
in
help doc:
- Define the web resource you wish to protect
- Define which security role is required to access the web resource
- Define which users are granted the required security role
- Configure WebLogic Server security for my web service(Compatibility
Security/Users)
I launch the service by entering the address in a web browser. Whenprompted
to accept the digital certificate, click Yes, when prompted for
network
authentication information, enter username and password, navigate tothe
Test Form tab of Test View, invoke the method by clicking the buttonand
I
get the following exception:
<error>
<faultcode>JWSError</faultcode>
<faultstring>Error during JNDI lookup from
jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookup failed for
name:t3://10.10.245.70:7131/AccountDelegatorEJB]</faultstring>
<detail>
<jwErrorDetail> weblogic.jws.control.ControlException: Error during
JNDI
lookup from jndi:t3://10.10.245.70:7131/AccountDelegatorEJB[Lookupfailed
for name:t3://10.10.245.70:7131/AccountDelegatorEJB] at
weblogic.knex.control.EJBControlImpl.acquireResources(EJBControlImpl.java:27
8) at
weblogic.knex.context.JwsInternalContext.acquireResources(JwsInternalContext
.java:220) at
weblogic.knex.control.ControlHandler.invoke(ControlHandler.java:260)at
ibas.AccountControl.getTransactionHistory(AccountControl.ctrl) at
ibas.GetSecure.retrieveVisaHistoryTxn(GetSecure.jws:64)</jwErrorDetail>
</detail>
</error>
I have a simple Hello method as well in my WebService (which is also
restricted) and it works fine, but remote EJB access doesn't. I testedmy
prototype on Weblogic 7.2 and 8.1 platforms - same result.
Is that a bug or I am missing some additional configuration in order
to
get
that working. Has anyone seen similar behavior? Is there a knownresolution?
Or a suggested way to work around the problem?
Thank you.
Andre -
EJB access from C++ client / Failover+LoadBalancing
We are accessing an EJB from VisiBroker for C++. The EJB is deployed in a WLS cluster.
Trying to achieve something like 'failover', we discovered that VisiBroker supports
multiloc addresses, so we are able to start our client as follows:
./client -ORBInitRef NameService=corbaloc::server1:8001,:server2:8002/NameService
As a result, server2 is only used when NameService of server1 is not available.
After connecting to a distinct NameService in a cluster, all further IIOP calls
are routed to this cluster server only. If the server shuts down, a new NameService
connection has to be made to get access to the other server and its objects.
Is this correct so far?
For the idea of 'load balancing' our EJB accesses, we didn't find a solution -
so it seems that this is completely impossible or is there any trick we could
use?
Thanks for your help
ml"Marko Lorentz" <[email protected]> writes:
We are accessing an EJB from VisiBroker for C++. The EJB is deployed in a WLS cluster.
Trying to achieve something like 'failover', we discovered that VisiBroker supports
multiloc addresses, so we are able to start our client as follows:
./client -ORBInitRef NameService=corbaloc::server1:8001,:server2:8002/NameService
As a result, server2 is only used when NameService of server1 is not available.
After connecting to a distinct NameService in a cluster, all further IIOP calls
are routed to this cluster server only. If the server shuts down, a new NameService
connection has to be made to get access to the other server and its objects.
Is this correct so far?
For the idea of 'load balancing' our EJB accesses, we didn't find a solution -
so it seems that this is completely impossible or is there any trick we could
use?If you use the Tuxedo 8.1 C++ client, then you will get per-request
load-balancing and failover. The C++ client is free to WLS licensees.
andy -
Excessive cxs socket connections created for ejb access
We are seeing a large number of TCP connections being created to the cxs engine for ejb access in our application.
We are running iPlanet application server 6.0, sp3 on Solaris 8. We have a web application that accesses a singleton component running in a kjs engine. That singleton accesses cmp entity beans and stateless session beans for serving client requests over the RMI/IIOP bridge. When three clients are connected and making requests, the number of TCP connections to the IIOP port (9010) starts to increase until everything freezes. I believe the "freezing" of the client apps is due to the open socket limit of 1024 being exceeded. According to the developer doc we can increase rlim_fd_max to 8192 to fix that problem.
However, my question is why are there an increasing number of socket connections? We are caching the ejb instances in the singleton so we should not be creating a large pool of EJBs. I have verfied the large number of sockets using netstat and also using RMI runtime logging in the kjs engine.
Does anyone have any ideas what could be happening here?
Thanks,
MarkI noticed that most of the TCP connections are made to port 32787. Can anyone from iPlanet tell me what is listening on this port? The large number of socket connections is really tying up server resources.
Thanks,
Mark -
Does an enterprise bean which is accessing the local interface on another enterprise bean need to be packaged together in the same EAR file?
I have a Session EJB which I want to deploy on my J2EE server so that it can be invoked by EJBs in various applications running on the same server instance (or JVM). I have tried to package up that Session EJB in its own EAR and have successfully deployed it on the server. However, when I deploy code in a separate EAR that attempts to use the local interface for that Session EJB, I get a ClassCastException.
Any suggestions on how to properly package and deploy reusable EJBs?>
So i suppose that we need to deploy the same code
with the same project name do be able to acces EJB in
remote.No, not at all. The caller of the Remote EJB only needs the relevant
Remote interfaces and related classes. It can be in any application,
whether that application is running on the same server as the target EJB,
a different server instance, or in an Application Client or stand-alone
client. The key advantage of Remote EJB access is location transparency.
You might want to take a look at some of our EJB FAQ entries, as well
as some of our simple EJB 3.0 example programs :
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
https://glassfish.dev.java.net/javaee5/ejb/EJB30.html
--ken -
Client remote Authentication using JAAS and EJB Access
Hi,
I have a problem using JAAS in combination with Sun One Appserver 8.1 and a java remote client trying to access an EJB. Here is the scenario:
I have implemented an EJB who's methods are protected through the deployment descriptor:
<assembly-descriptor>
<security-role>
<description>role for clients outside of the server </description>
<role-name>sedna</role-name>
</security-role>
<method-permission>
<role-name>sedna</role-name>
<method>
<ejb-name>ServerInfoBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
</method-permission>
<method-permission>
<unchecked/>
<method>
<ejb-name>ServerInfoBean</ejb-name>
<method-name>getVersion</method-name>
</method>
<method>
<ejb-name>ServerInfoBean</ejb-name>
<method-name>create</method-name>
</method>
</method-permission>
</assembly-descriptor>I've deployed the EJB in a jar file which was packed into an ear file of a bigger application. The role has been mapped to the admin Principal in the sun-ejb-jar.xml descriptor.
I can find the EJB, create it, and call the unchecked method getVersion and that works fine, so far so good.
But then I try to access another method which is protected and then I get this exception
org.omg.CORBA.NO_PERMISSION: vmcid: 0x2000 minor code: 1806 completed: Maybe
at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:179)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:853)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:137)
...I have to mention that I do make a login via the LoginContext. My jaas.config File has a reference to the com.sun.enterprise.security.auth.login.ClientPasswordLoginModule module.
After login (which works perfectly) I lookup the context with a corbaname url which - if I understood it right - ignores the Context.SECURITY_PRINCIPAL and Context.SECURITY_CREDENTIALS settings.
After that I make the calls to the EJB. And I am allways ANONYMOUS on the server side, which is definitely the problem. Because ANONYMOUS is not allowed to call the protected EJB Methods. But I made a jaas login in advance. So where am I making a mistake???
Am I doing something wrong?
Need help! Thx,
StephanHi.
I understand correctly that you call Subject.doAs on
the client to call the remote EJB. I guess It isn't
right way.I had also a bad feeling about this, so I forget it. But anyway it wasn't working with or without using that doAs().
>
>
Subject contextSubject =
Subject.getSubject(AccessController.getContext());
contextSubject.getPrincipals();This code throws exceptions in the Appserver. Unfortunately they are catched somewhere so I'm unable to find out what was going wrong. But I guess, that these exceptions where security exceptions. Never the less thanks for the hint!
But I don't think that doing the check on the server side is the way I want to go because that is programmatically security and I want to use the declarative security which can be used through the deployment descriptor. If used correctly - and supposed I do not completely misunderstand the specification - then it should be possible to create an EJB that is protected via it's deployment descriptor and access it through the client only if the client has been authenticated through JAAS mechanisms. After successful authentication the principal should be accessible through the EJB context but not for security check, that should allready been done at this time.
Unfortunately I don't find any resource on the internet describing the scenario in such a detail that I can reproduce it. There are only very high level documentations and hints in forums.
Again, thanks for your effort,
Stephan -
(jdeveloper11g,MacOSX,EJB) access to EJB in jdevdeloper but not from jar
hello,
I have created an application with an EJB which contains only one method : sayHello, which returns "hello" as a string.
I have also created another project in the same application, and the project is a swing project with one button; when you click opne the button the text of a jlabel is modified with the result of the method sayHello of the EJB.
The program runs well, I mean when I launch the application from jdeveloper, the window appears and when I click on the button the text of the label is changed
: the access to the EJB is good.
I specify the EJB is deplyed to a weblogic server, which seems to run well (I can access to the administration page).
But when I try to deploy the client to a JAR or a client JAR (I don't know the difference between them), the jar is created, and if I try to launch it the window appears but the text of the label isn't changed.
can you help me to make it work?
the access to the EJB seems good as it works from jdeveloper.
here is the client:
public class Frame1 extends JFrame {
private JButton jButton1 = new JButton();
private JLabel jLabel1 = new JLabel();
public Frame1() {
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
private void jbInit() throws Exception {
this.getContentPane().setLayout( null );
this.setSize( new Dimension(400, 300) );
jButton1.setText("Click me!");
jButton1.setBounds(new Rectangle(50, 30, 85, 29));
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
jLabel1.setText("jLabel1");
jLabel1.setBounds(new Rectangle(55, 80, 125, 15));
this.getContentPane().add(jLabel1, null);
this.getContentPane().add(jButton1, null);
private void jButton1_actionPerformed(ActionEvent e) {
myEJB MyEJB=null;
try {
final Context context = getInitialContext();
MyEJB = (myEJB)context.lookup("weblogic_2-Project1-myEJB#app7.myEJB");
} catch (Exception ex) {
ex.printStackTrace();
jLabel1.setText(MyEJB.disBonjour());
private static Context getInitialContext() throws NamingException {
Hashtable env = new Hashtable();
// WebLogic Server 10.x connection details
env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
return new InitialContext( env );
I can go deep further in details concerning the deployment of the project if you ask me a peculiar question (I start in jdeveloper and don't know it well).
olivier.Hi Grzegorz,
you answered most of your questions by yourself already. First of all do NEVER EVER share database schemes between J2EE and ABAP. Why? Because in most cases, the data models of an ABAP system are not only represented by fields of database tables and relations between database tables, but by the application logic behind it. As a consequence this means, that it is not recommended to access any database table used by an ABAP system directly from the J2EE engine.
The only safe way for access is the usage of JCo/SAPJRA, so, as you also already said, the better or only choice is to use JCo calls from session beans. It doesn't matter, if the ABAP system is remote or not.
Hope that helps.
Regards
Stefan -
I am using JDev 10g(9.0.4) I have created an EJB, I can deploy the EJB to OC4J Standalone 10g (9.0.4) and everything works great.
However, when I deploy the EJB to Oracle Application Server 10g(9.0.4) enterprise edition, I cannot assess the EJB.
I assume it may be a security issue??
Anyone have any ideas?It may be security but it may just be the JNDI URL you are using.
If you are accessing a remote EJB and specifying the full JNDI as "ormi://host:23971/application" then you'll need to modify it to specify a slightly different JNDI lookup string.
In an OracleAS environment, the ports for the OC4J instance are dynamically allocated, so what was an easily identifiable fixed port (23791 for OC4J standalone) isn't the same in OracleAS.
So what we've provided is a way to specify a JNDI URL which first will interrogate our server to find the OC4J RMI port, and then connect to that.
The EJB Developer's Guide describes this. Look for the location section at the following link.
http://download-west.oracle.com/docs/cd/B10464_02/web.904/b10324/primer.htm#1019664
cheers
-steve- -
Ejb accessing the deployment descriptor
My ejb needs to be able to access the deployment descriptor to retrieve some user information needed to connect to a web service. What is the best way to do this? I know servletts can do this, and if necessary, I could have my servlet retrieve the info and pass it to the bean, but I was hoping to avoid this.
Thanks
MattWell, sure I think that is easy. In your <entity> or <session> deployment descriptor you can have:
<env-entry>
<env-entry-name>WebServiceLogins</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>su, dan, bob, steve, richard, suzie, carla</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>WebServicePasswords</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>drs100, vfdds2, ajk14, pass411, richard23, q4lty, uo738ww1</env-entry-value>
</env-entry>
Then in your intial-context in your session or entity ejb.....
InitialContext ic = new InitialContext();
String logins = (String) ic.lookup("java:comp/env/WebServiceLogins");
String passwords = (String) ic.lookup("java:comp/env/WebServicePasswords"); -
Hi
Am I correct in thinking that if I require a browser based Java
client to access an EJB that I have to perform the following ....
SETUP for the browsers
1) You need to remove the iiop10.jar file from the
...Netscape/Communicator/Program/Java/Classes directory. Renaming
this
file is not enough - you must remove it.
2) You need to copy $ORACLE_HOME/lib/aurora_client.jar
$ORACLE_HOME/lib/vbjorb.jar and $ORACLE_HOME/lib/vbjapp.jar into
the
...Netscape/Communicator/Program/Java/Classes directory.
aurora_client.jar is 2.3MB! This effectively means ejb's are
totally useless in the real world if you want to access them from
a browser over the internet.
Somebody please tell me there's an alternative or even better
it's not true.
Thanks
ritchie
nullCheck the JNDI name specified in the xml file.
Hope this will help
Ashish Mangla -
Hi,
I have application deployed on Oracle 10.1.3.1 application server. The application uses customs security provider and EJB's are secured in this server.
I need to access these EJB's from another remote server.
Below is the sample code:
public static void checkEJB(){
final String authFile = "C:/jaas/authfile.txt";
System.setProperty("java.security.auth.login.config", authFile);
MyCallbackHandler handler = new MyCallbackHandler(userName,password);
try {
LoginContext lc = new LoginContext("someXYZLogin",handler);
lc.login();
System.out.println("Successfully logged in user: " + userName);
Hashtable env = new Hashtable();
env.put(Context.PROVIDER_URL,"opmn:ormi://appsvr4:6003:customs/ces");
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "user"
env.put(Context.SECURITY_CREDENTIALS, "test");
env.put("dedicated.connection" ,"true");
InitialContext context = new InitialContext(env);
System.out.println("context ------>>>" +context);
Object objref = context.lookup("StockNumber");
System.out.println(objref);
}catch(Exception ex){
ex.printStackTrace();
class MyCallbackHandler implements CallbackHandler {
private String username;
private String password;
public MyCallbackHandler(String username, String password) {
this.username = username;
this.password = password;
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
System.out.println("handle()------>"+callbacks.length);
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof NameCallback) {
//if the Callback is for NameCallback, then set the name of the NameCallback to ‘userName’
NameCallback nc = (NameCallback) callbacks;
System.out.println("handle 1()------>"+username);
nc.setName(username);
} else if (callbacks[i] instanceof PasswordCallback) {
//if the Callback is for PasswordCallback, then set the name of the PasswordCallback to ‘password’
PasswordCallback pc = (PasswordCallback) callbacks[i];
pc.setPassword(password.toCharArray());
System.out.println("handle 2()------>"+password.toCharArray());
} else {
System.out.println("handle 3() else block------>");
//if Callback is NOT NameCallback or PasswordCallback then throw UnsupportedCallbackException
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
Output is:
handle()------>2
handle 1()------>user
handle 2()------>[C@15cda3f
returning true, user code=user
returning true, password=test
user and password checked out okay
Successfully logged in user: user
context ------>>>javax.naming.InitialContext@f11404
javax.naming.NamingException: Lookup error: javax.naming.AuthenticationException: Not authorized; nested exception is:
javax.naming.AuthenticationException: Not authorized [Root exception is javax.naming.AuthenticationException: Not authorized]
at com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:64)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at mdbproject.LookupCustoms.checkEJB(LookupCustoms.java:62)
at mdbproject.LookupCustoms.main(LookupCustoms.java:19)
Caused by: javax.naming.AuthenticationException: Not authorized
at oracle.oc4j.rmi.ClientRmiTransport.connectToServer(ClientRmiTransport.java:99)
at oracle.oc4j.rmi.ClientSocketRmiTransport.connectToServer(ClientSocketRmiTransport.java:68)
at com.evermind.server.rmi.RMIClientConnection.connect(RMIClientConnection.java:609)
at com.evermind.server.rmi.RMIClientConnection.sendLookupRequest(RMIClientConnection.java:153)
at com.evermind.server.rmi.RMIClientConnection.lookup(RMIClientConnection.java:137)
at com.evermind.server.rmi.RMIClient.lookup(RMIClient.java:251)
at com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:51)
Any hints to overcome the problem?
Regards,
Prashant
Edited by: pprashant on Jan 18, 2011 1:21 AMBut my custom authentication provider logs tell that user credentials are correct.
Below is a cope snippet of orion-application.xml
<security-role-mapping name="USER">
<group name="USER" />
</security-role-mapping>
<jazn provider="XML">
<property name="role.mapping.dynamic" value="true" />
<property name="custom.loginmodule.provider" value="true" />
</jazn>
<log>
<file path="application.log" />
</log>
<namespace-access>
<read-access>
<namespace-resource root="">
<security-role-mapping impliesAll="true" name="USER">
<group name="USER" />
</security-role-mapping>
</namespace-resource>
</read-access>
<write-access>
<namespace-resource root="">
<security-role-mapping impliesAll="true" name="USER">
<group name="USER" />
</security-role-mapping>
</namespace-resource>
</write-access>
</namespace-access> -
StatelessSession EJB access via JCOM???
I have successfuly accessed the sample containerManaged EJB using the zeroclient and
latebound examples, but now I am trying to access the statelessSession EJB (ejb20-statelessSession-TraderHome)
sample using both zeroclient and latebound examples, but I keep getting the error
"Cannot create ActiveX object". My question is... are Entity EJB's the only type
of EJB's that one can access using JCOM? or do I need to perform extra steps to the
statelessSession EJB to make it accessible via JCOM?
Thanks in advance.
FrankI have successfuly accessed the sample containerManaged EJB using the zeroclient and
latebound examples, but now I am trying to access the statelessSession EJB (ejb20-statelessSession-TraderHome)
sample using both zeroclient and latebound examples, but I keep getting the error
"Cannot create ActiveX object". My question is... are Entity EJB's the only type
of EJB's that one can access using JCOM? or do I need to perform extra steps to the
statelessSession EJB to make it accessible via JCOM?
Thanks in advance.
Frank -
Hi ,
I am learning the basic EJB and trying to write my first piece of code.
I wrote a HelloWorld.jar(EJB) and deployed it in Websphere server.
Then I wrote a standalone java program with main method to access the EJB client. As per the tutorial..
public void callEJB()
try
java.util.Properties env = new java.util.Properties();
env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"com.ibm.websphere.naming.WsnInitialContextFactory");
env.put(javax.naming.Context.PROVIDER_URL,"iiop://localhost:2809/");
javax.naming.Context initial = new javax.naming.InitialContext(env);
//Object objref =(javax.naming.Context)initial.lookup("java:comp/env/HelloWorld");
Object objref =initial.lookup("ejb/ejb/demo/HelloWorldHome");
System.out.println(objref.getClass());
HelloWorldComponent helloRef = (HelloWorldRemote)PortableRemoteObject.narrow(objref, HelloWorldComponent.class);
}catch(Exception e){e.printStackTrace();}
How will my code compile???? Because HelloWorldComponent is on the application server, but my client is on a different server. It cannot find the HelloWorldComponent class right??
What should I do now?
Thanks.env.put(javax.naming.Context.PROVIDER_URL,"iiop://localhost:2809/");you should change the localhost to the server's IP address instead since you are running the client from another computer. hope this will work.
cheers,
clarence -
Initial Context Factory for same OC4J EJB access in 10.1.3.1
What should the INITIAL_CONTEXT_FACTORY be set to when you try to access an EJB from within the same OC4J instance? Should it be:
a) ApplicationClientInitialContextFactory
b) RMIInitialContextFactory
c) Nothing at all
d) Something else completely
I ask because I am try to move from 10.1.3.0 to 10.1.3.1 and I have a thread spawned during startup that is unable to access the EJB
2007-05-25 07:22:50.862 WARNING J2EE RMI-00009 Exception returned by remote server: {0}
07/05/25 07:22:50 Unknown service: MySessionHome
javax.naming.NameNotFoundException: MySessionHome not found
It does not set the INITIAL_CONTEXT_FACTORY because it has been my understanding that this is not necessary. Did something change in 10.1.3.1?Has anyone found a solution for this problem? I tried adding the following entry to my orion-application.xml file with no luck. I was able to fix the problem by adding commons-digester.jar,commons-logging.jar, and log4j-1.2.15.jar to the /BC4J/lib folder on the server. Unfortunately this fix caused errors when trying to launch the BPEL console. Any help would be greatly appreciated.
<imported-shared-libraries>
<remove-inherited name="apache.commons.logging"></remove-inherited>
</imported-shared-libraries>
I am unable to deploy my application due to the error below.
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@6b8c38 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@6b8c38 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at com.sun.faces.config.ConfigureListener.<clinit>(ConfigureListener.java:212)
... 19 more
Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@6b8c38 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:413)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 23 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.getConstructor(Class.java:1629)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410)
... 24 more -
EJB accessing web application classes
Hi,
what is the right method to enable packaged EJB to access classes of a
web application? Packaging both the EJB and web application in same
ear is not possible in this situation. We are running WebLogic 6.0 and
ejb is in
wlserver6.0/config/mydomain/applications/EJB.jar
and the classes it should use are in
wlserver6.0/config/mydomain/applications/application_name/WEB-INF/classes,
i.e. not packed into war -package. adding
wlserver6.0/config/mydomain/applications/application_name/WEB-INF/classes
to WebLogic's CLASSPATH enables the ejb to deploy but seems to screw
other deployments.Please address calling and EJB from a JSP using the EJB to JSP tags...?I'm throwing
ClassCast errros on Object...
William Kemp <[email protected]> wrote:
This is addressed numerous times in this newsgroup and others. So, if
you are
insterested in additional explanations, a search of the newsgroups will
be
productive.
The WLS 6.x classloading scheme for enterprise apps, ejbs, and webapps
does
not permit and ejb to access webapp classes in the WEB-INF/classes directory
unless those classes are placed in the java system classpath, which,
you have
found, creates other problems.
If classes are needed by both webapp and ejb, place them in a utility
jar file
that is packaged in the ear with the ejb, or webapp, or both, and refer
to
them with the Class-Path manifest directive in the ejb jar file or the
webapp
war file.
For the details, see:
http://e-docs.bea.com/wls/docs61/programming/packaging.html#1029830
and the 7.0 stuff is good, too:
http://edocs.bea.com/wls/docs70/programming/classloading.html#1029830
Bill
janne wrote:
Hi,
what is the right method to enable packaged EJB to access classes ofa
web application? Packaging both the EJB and web application in same
ear is not possible in this situation. We are running WebLogic 6.0and
ejb is in
wlserver6.0/config/mydomain/applications/EJB.jar
and the classes it should use are in
wlserver6.0/config/mydomain/applications/application_name/WEB-INF/classes,
i.e. not packed into war -package. adding
wlserver6.0/config/mydomain/applications/application_name/WEB-INF/classes
to WebLogic's CLASSPATH enables the ejb to deploy but seems to screw
other deployments.
Maybe you are looking for
-
Hi I am loading a new MDM SRM Catalog repository with a supplier file. The supplier items are for hire i.e. computers, cabins, etc. We want to load the catalog items that can be hired/leased. However in the search interface we can only select a quant
-
Macbook pro 10.6.8 internal mic not working
Hi there, After I got back my mac book pro from repair. I realised my internal mic is not working? Any idea? Or can I fix this myself? I tried quicktime to record my voice. I dun hear my voice after I played it. Thanks.
-
Oracle 10.2.0.2 installation in hang
We are installing EP 70 over Win2003 R2 64 bit Enterprise Edition on a server with XEON CPU's. THe server is a node on and MSCS cluster. The installation of the latest Oracle patch 10.2.0.2 is hanging. The Oracle Installation windows does not says 'F
-
WebService monitoring & Status in PI system
Hi Experts, Kindly help to find out WebService status(down or running) and Monitored WebService in PI system Java stack Only. Regards, Srini
-
JAVA + 32 bit Borland DLL + gpib-32.dll
Hello, I develop a Java application, which - thanks to the Java Native Interface - communicates with a 32 bit DLL (I called gpib-jni.dll) I wrote this DLL with Borland C++ under Windows 98. This DLL contains .cpp and .h files that make a link between