[EJB 3.0] - EJB 3.0 and Authorization
by slavago
Hi.
I have ejb 3.0 bean:
package org;
import javax.annotation.security.DenyAll;
import javax.annotation.security.RolesAllowed;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Stateless
public class ProcessPaymentBean implements ProcessPaymentRemote{
public ProcessPaymentBean () {
int a= 1;
}
@PersistenceContext(name = "Context")
private EntityManager em;
/* private void setEm(EntityManager em) {
this.em = em;
}
*/
@DenyAll
public int test1(int a) {
int res = 0;
if (em == null) {
return 0;
}
Provider prov = new Provider();
prov.setProviderName("zohar");
prov.setCredentials("password");
try {
em.persist(prov);
}
catch (Exception e) {
res = 2;
}
res = 1;
return res;
}
}
and client that wants to access this bean:
public class MyTest {
public static void main(String[] args){
EntityManager em = null;
try{
Context jndiContext = getInitialContext();
ProcessPaymentRemote ref = (ProcessPaymentRemote)jndiContext.lookup(("ProcessPaymentBean/remote"));
int res = ref.test1(1);
int a =1;
}
catch (Throwable e) {
e.printStackTrace();
}
}
public static Context getInitialContext() throws NamingException{
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming;org.jnp.interfaces");
p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
return new InitialContext( p );
}
}
And, when i'm execuyting my client, there is no access execption is thrown. everything is executed like no @denyall defined.
What i do wrong and what i need to configure, may be i missing something.
Or may be i can download some Jboss 4.0.4 (Ejb 3.0) authorization example ?
Thank You.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3967243#3967243
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3967243
19 years, 8 months
[EJB 3.0] - resource-ref problem
by rak0t
Hi. I am trying to inject resources into my MDB, here is the code in MDB:
| @Resource(name="senderQueue")
| protected Queue _queue;
|
Here is ejb-jar.xml entry
| <resource-ref>
| <description>Sender destination</description>
| <res-ref-name>senderQueue</res-ref-name>
| <res-type>javax.jms.Queue</res-type>
| <res-auth>Container</res-auth>
| </resource-ref>
|
Here is jboss.xml entry
| <resource-ref>
| <description>Sender destination</description>
| <res-ref-name>senderQueue</res-ref-name>
| <res-type>javax.jms.Queue</res-type>
| <jndi-name>GEDDEV1-ORC.CLIENT.CHANNEL-JAVAQ7</jndi-name>
| </resource-ref>
|
when my MDB initializes it throws
| java.lang.RuntimeException: Unable to inject jndi dependency: env/senderQueue into field interface javax.jms.Queue
| at org.jboss.ejb3.injection.JndiFieldInjector.lookup(JndiFieldInjector.java:86)
| at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:99)
| at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:61)
| at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:88)
| at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:48)
| at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.mdb.MDB.localInvoke(MDB.java:865)
| at org.jboss.ejb3.mdb.MDB.localInvoke(MDB.java:844)
| at org.jboss.ejb3.mdb.MDB$MessageListenerImpl.onMessage(MDB.java:1074)
| at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:266)
| at com.ibm.mq.jms.MQSession.run(MQSession.java:1561)
| at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:196)
| at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
| at java.lang.Thread.run(Thread.java:595)
| Caused by: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: GEDDEV1-ORC.CLIENT.CHANNEL-JAVAQ7 not bound]
| at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1067)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:700)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
| at org.jboss.ejb3.injection.JndiFieldInjector.lookup(JndiFieldInjector.java:75)
| ... 14 more
| Caused by: javax.naming.NameNotFoundException: GEDDEV1-ORC.CLIENT.CHANNEL-JAVAQ7 not bound
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
| at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
| at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
| at javax.naming.InitialContext.lookup(InitialContext.java:351)
| at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1061)
| ... 17 more
|
When i go to JNDIView i see this entry under java:
GEDDEV1-ORC.CLIENT.CHANNEL-JAVAQ7
com.ibm.mq.jms.MQQueue
Any help is appreciated
thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3967242#3967242
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3967242
19 years, 8 months