[EJB 3.0] - Error working wih EJB3, Struts2 & JBoss 4.2GA
by NAG Kum
NAG Kum [http://community.jboss.org/people/nk_2010] created the discussion
"Error working wih EJB3, Struts2 & JBoss 4.2GA"
To view the discussion, visit: http://community.jboss.org/message/537190#537190
--------------------------------------------------------------
Hi All,
Nice chatting with you all...:) Facing below error - while accessing struts 2 action from browser -
************************************************
java.lang.reflect.InvocationTargetException
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
root cause
java.lang.NoClassDefFoundError: Could not initialize class $Proxy146
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
org.jboss.ejb3.stateful.StatefulLocalProxyFactory.createProxy(StatefulLocalProxyFactory.java:150)
org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:53)
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1273)
org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1290)
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:763)
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
javax.naming.InitialContext.lookup(InitialContext.java:392)
com.tarangtech.framework.ejb.clients.util.CommonPaymentAction.getAuthentication(CommonPaymentAction.java:27)
com.tarangtech.mtg.authentication.struts.AuthenticationAction.execute(AuthenticationAction.java:23)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:440)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:279)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:242)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:236)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
************************************************
Please find my code below - to look up a EJB -
public
static TreeMap<String, String[]> getAuthentication(XmlHandlerRequestASM objReqHandAsm){
map = new TreeMap<String, String[]>();
try {
ctx = new InitialContext();
AuthenticationBean authEjb = (AuthenticationBean)
ctx.lookup("AuthenticationLocal");
XmlHandlerResponseASM objRespASM = authEjb.doLoginAdm(objReqHandAsm);
key = Constants.AdminConstants.authentication;
if(objRespASM.getStatus().get(Constants.Communication.STATUSCODE) != null ) {
values[0] = (String) objRespASM.getStatus().get(Constants.Communication.STATUSCODE);
}
else if(objRespASM.getStatus().get(Constants.Communication.ERRORCODE) != null ) {
values[0] = (String) objRespASM.getStatus().get(Constants.Communication.ERRORCODE);
}
else {
values[0] = "input";
}
map.put(key,values);
}
catch (NamingException e) {
//LoggerHelper.log(arg0, arg1, arg2, arg3)
e.printStackTrace();
}
catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (TarangFrameworkException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return map;
}
Below is the AuthenticationBean class ::
@Stateful
@Local
(AuthenticationLocal.class)
@LocalBinding
(jndiBinding="AuthenticationLocal")
@Remote
(Authentication.class)
@RemoteBinding
(jndiBinding="Authentication")
public
class AuthenticationBean implements AuthenticationLocal{
Appreciate any ideas to resolve my application issue.
Thanks in advance..
NK
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/537190#537190]
Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years
Re: [jboss-user] [jBPM] - How to provide my own transaction to jBPM?
by Guido Helmers
Guido Helmers [http://community.jboss.org/people/helmers] replied to the discussion
"How to provide my own transaction to jBPM?"
To view the discussion, visit: http://community.jboss.org/message/537177#537177
--------------------------------------------------------------
Hi Huisheng,
thanks for your reply.
Integration with Spring is not really an option for us; our DI standard is Guice.
Option 2. doesn't sound optimal either because it introduces an ugly dependency on jBPM; ideally we have dependencies on jBPM services but not on the internals (I think the Command is not really part of the jBPM API?). Apart from that we would end up using different transaction mechanisms for service calls that happen to have a dependency on jBPM (they're wrapped in a Command), and services without jBPM dependency (those don't need to be executed in a Command).
I was hoping for a cleaner solution...
Anyway, as for the other issue: https://community.jboss.org/message/537176 https://community.jboss.org/message/537176
Although I now have got one hibernate SessionFactory shared by my app and jBPM (see ...; not sure if this is a proper fix), things still seem to be running in different transactions. With the standard jbpm.tx.hibernate.cfg.xml (which configures a standard-transaction-interceptor for every command), when I roll back my top-level transaction, the jBPM stuff (executed inside the transaction created by the StandardTransactionInterceptor) is not rolled back.
So what I did was create my own tx.hibernate.cfg.xml, and remove the standard-transaction-interceptors from it. That doesn't really work either (now suddenly calls to "repositoryService.createDeployment().addResourceFromClasspath("myProcess.jpdl.xml").deploy()" seem to not properly insert process definitions in the database; it does insert into JBPM4_DEPLOYMENT, but 3 out of the 4 records from JBPM4_DEPLOYPROP are missing).
Before I dive into the deep, can someone let me know if this is the way to go? What's the way to have jBPM use my own transactions? Should it be possible to remove the standard-transaction-interceptor from the interceptor stack? Or is it strictly forbidden; if so, why?
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/537177#537177]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years
Re: [jboss-user] [jBPM] - Injected hibernate SessionFactory is not used by jBPM 4.3?
by Guido Helmers
Guido Helmers [http://community.jboss.org/people/helmers] replied to the discussion
"Injected hibernate SessionFactory is not used by jBPM 4.3?"
To view the discussion, visit: http://community.jboss.org/message/537176#537176
--------------------------------------------------------------
As sketched in my story above, jBPM *stores* the SessionFactory in the *"process-engine" WireContext* (see ConfigurationImpl), but *looks it up* in the *"transaction" WireContext*. In my simple view of life, that explains why it doesn't work. So I've overridden the ConfigurationImpl.setHibernateTransactionFactory() to store the descriptor *also* in the "transaction" WireContext, like this:
ProcessEngine processEngine = new ConfigurationImpl() {
@Override
public ConfigurationImpl setHibernateSessionFactory(Object hibernateSessionFactory) {
ProvidedObjectDescriptor descriptor = new ProvidedObjectDescriptor(hibernateSessionFactory, true);
getProcessEngineWireContext().getWireDefinition().addDescriptor(descriptor);
getTransactionWireDefinition().addDescriptor(descriptor);
return this;
}
}.setResource("jbpm/jbpm.cfg.xml").setHibernateSessionFactory(hibernateSessionFactory).buildProcessEngine();
Now jBPM does use my injected SessionFactory (verified by doing the same debug session as described above; it's now obtaining the injected object wherever it's looking up a SessionFactory).
I'm not very familiar with the different jBPM WireContexts, so I hope a jBPM expert can take a look at my 'workaround', and say some smart stuff about whether this is can be considered a bug in the standard ConfigurationImpl, or whether I'm doing something dangerous here with nasty side-effects...
Thanks for your help,
Guido
ps: The problem described here: https://community.jboss.org/thread/150582 https://community.jboss.org/thread/150582 remains. I now have one SessionFactory, but it's still not possible to run my own stuff and jBPM stuff in one single transaction.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/537176#537176]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years