[EJB 3.0] - Re: NullPointerException in JavaEEComponentHelper with JBoss
by japase
An example of a bean declaration and injection with some other typical annotations (all our generated beans are more or less same):
| package ifs.application.administrateuserprofiles;
|
| import ifs.fnd.log.*;
| import ifs.fnd.record.*;
| import ifs.fnd.record.serialization.*;
| import ifs.fnd.remote.*;
| import ifs.fnd.remote.j2ee.*;
| import ifs.fnd.sf.j2ee.*;
| import ifs.fnd.sf.j2ee.meta.*;
| import ifs.fnd.base.*;
| import ifs.fnd.sf.*;
| import ifs.application.manageuserprofile.*;
|
| import java.util.Date;
| import javax.ejb.Stateless;
| import javax.ejb.EJB;
| import javax.annotation.PostConstruct;
| import javax.ejb.TransactionAttribute;
| import javax.ejb.TransactionAttributeType;
|
| @Stateless(name="AdministrateUserProfiles")
| public class AdministrateUserProfilesBean extends FndActivityBean implements AdministrateUserProfilesLocal {
|
| private AdministrateUserProfiles implementation;
|
| @EJB(mappedName="ifsapp/UserProfileService/local") private UserProfileServiceLocal userProfileService;
|
| @PostConstruct
| private void initialize() {
| // some code goes here â¦
| }
|
| @Override
| public String[] getOperations() {
| return operations;
| }
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public FndRecordResultWrapper clearClientProfile(ifs.application.manageuserprofile.ClientProfileExt inRecord, FndContext ctx) throws IfsException {
| // method code hereâ¦
| }
|
| // other methods
| }
|
All the generated beans extend indirectly the following class (complete code):
| package ifs.fnd.sf.j2ee;
|
| import ifs.fnd.base.SystemException;
| import ifs.fnd.base.IfsException;
| import ifs.fnd.base.FndConstants;
| import ifs.fnd.base.FndContext;
| import ifs.fnd.base.FndFramework;
| import ifs.fnd.log.*;
| //import ifs.fnd.service.IfsProperties;
|
| import javax.annotation.Resource;
| import javax.ejb.SessionContext;
| import javax.interceptor.AroundInvoke;
| import javax.interceptor.InvocationContext;
| import javax.sql.DataSource;
| import javax.annotation.security.DeclareRoles;
| import javax.annotation.security.RolesAllowed;
|
| /**
| * Base class for all EJB classes.
| */
| @DeclareRoles({FndConstants.USER_ROLE, FndConstants.TRUSTED_MODULE_ROLE})
| @RolesAllowed({FndConstants.USER_ROLE})
| abstract class FndAbstractBean {
|
| //private static final String DATASOURCE_JNDI_PREFIX = IfsProperties.getProperty("fndext.datasource.jndi.prefix");
|
| // this logger may be used during initialization of a bean; it is then recreated by @AroundInvoke method
| protected Logger log;
|
| // logger used for debugging of EJB specific events
| protected Logger clsLog;
|
| protected FndAbstractBean() {
| log = LogMgr.getFrameworkLogger();
| clsLog = LogMgr.getClassLogger(FndAbstractBean.class);
| if(clsLog.debug)
| clsLog.debug("Created bean [&1]", getClass().getName());
| }
|
| @Resource
| protected SessionContext sessionContext;
|
| @Resource(name="fndbas_en-US", mappedName="java:jdbc/fndbas_en-US")
| private DataSource dsEn;
|
| @Resource(name="fndbas-noxa_en-US", mappedName="java:jdbc/fndbas-noxa_en-US")
| private DataSource dsNoXaEn;
|
| public DataSource getDataSource(String name) throws SystemException {
| if("fndbas_en-US".equals(name))
| return dsEn;
| else if("fndbas-noxa_en-US".equals(name))
| return dsNoXaEn;
| throw new SystemException("No dependency to DataSource " + name);
| }
|
| protected SessionContext getSessionContext() {
| return sessionContext;
| }
|
| @AroundInvoke
| private Object aroundInvoke(InvocationContext ctx) throws Exception {
|
| // recreate the bean-protected instance of logger
| log = LogMgr.getFrameworkLogger();
|
| // prepare current FndContext for invocation of a business method
| FndJ2eeContext fndctx;
| if(this instanceof FndActivityBean) {
| Object[] params = ctx.getParameters();
| Object lastParam = params[params.length - 1];
| if(lastParam instanceof FndContext) {
| // typed invoke(): set passed FndContext as current context
| fndctx = (FndJ2eeContext) lastParam;
| setCallerAsApplicationUser(fndctx);
| FndContext.setCurrentContext(fndctx);
| }
| else {
| // untyped invoke(): create new FndContext and set it as current context
| fndctx = (FndJ2eeContext) FndFramework.getFramework().newContext();
| FndContext.setCurrentContext(fndctx);
| }
| }
| else {
| // for nested beans the current FndContext has been already set
| fndctx = FndJ2eeContext.getCurrentJ2eeContext();
| }
|
| // push this bean to the stack with current bens
| fndctx.pushCurrentBean(this);
| if(clsLog.info)
| clsLog.info("Pushed current bean [&1]", getClass().getName());
|
| try {
| // invoke business method
| return ctx.proceed();
| }
| finally {
| // pop this bean from the stack with current bens
| fndctx.popCurrentBean(this);
| if(log.debug)
| log.debug("Poped current bean [&1]", getClass().getName());
|
| // clear the current context after top-level bean method invocation
| if(this instanceof FndActivityBean) {
| FndContext.setCurrentContext(null);
| if(log.debug)
| log.debug("Current context cleared on exit from bean [&1]", getClass().getName());
| }
| }
| }
|
| /**
| * Sets the authenticated user as application user in the specified context.
| */
| protected void setCallerAsApplicationUser(FndJ2eeContext ctx) throws IfsException {
| try {
| String user = sessionContext.getCallerPrincipal().getName();
| ctx.setApplicationUser(user);
| if(log.debug)
| log.debug("Current application user set to authenticated user: &1", user);
| }
| catch (IllegalStateException e) {
| throw new ifs.fnd.base.SecurityException(e,
| "FNDSESSIONBEANSEC:No security context set. Check that security has been configured for the application.");
| }
| }
|
| }
|
There are some other levels of inheritance between a generated EJB and the FndAbstractBean class above, but without anything specific for EJB (I think). But, of course, I can post the code for those classes as well, if necessary.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4226913#4226913
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4226913
15 years, 7 months
[Beginners Corner] - Getting J BossAS Bind-Address/Host
by TobiasW
Hi,
i am already a while in development with a JBoss Application Server but now i'am searching for advice in this forum first time. Im not if im in the right corner but now on topic.
I have a Webapplication that is running on serveral JBoss Installations at different places. In last time i was trying around with the TimerServices API and found it quite usefull. I have a timeout method that should call different WebServices and Servlets in this WebApp. Until now we solved this via JNDI-Calls but for some reason this isnt possible anymore.
In future its the goal to call the servlets/webservices via the URLConnection-Class. Cause of this post is i need the servers host part so i can open a Connection from itself (timeout-Method) to itself(Servlet/WebService (mainly Servlet).
I hope you can understand the problem and can help me finding a solution to get the server host address.
Greetings,
Tobias
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4226905#4226905
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4226905
15 years, 7 months
[JBoss Portal] - SecurityException on stopping JBoss Portal Server
by dorothy
Hi All
I am quite a newbie with JBoss PS. I have recently configured the evalutaion version oj JBoss Enterprise Portal Server 4.3 in eclipse ganymede 3.4. I am able to start the server succesfully from within the IDE, but when I try to stop the server I get the following error messages. Also my portlets do not deploy when I select Run As > run on Server. Pl. help:
Exception in thread "main" java.lang.SecurityException: Failed to authenticate principal=admin, securityDomain=jmx-console
| at org.jboss.jmx.connector.invoker.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:97)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.invocation.jrmp.server.JRMPProxyFactory.invoke(JRMPProxyFactory.java:180)
| at sun.reflect.GeneratedMethodAccessor136.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
| at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
| at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
| at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
| at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:818)
| at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:419)
| at sun.reflect.GeneratedMethodAccessor135.invoke(Unknown Source)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
| at sun.rmi.transport.Transport$1.run(Transport.java:153)
| at java.security.AccessController.doPrivileged(Native Method)
| at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
| at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
| at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
| at java.lang.Thread.run(Thread.java:595)
| at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
| at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
| at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
| at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
| at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:133)
| at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365)
| at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197)
| at org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor.invoke(InvokerAdaptorClientInterceptor.java:66)
| at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
| at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74)
| at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
| at $Proxy0.invoke(Unknown Source)
| at org.jboss.Shutdown$ServerProxyHandler.invoke(Shutdown.java:266)
| at $Proxy1.shutdown(Unknown Source)
| at org.jboss.Shutdown.main(Shutdown.java:237)
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4226902#4226902
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4226902
15 years, 7 months