Re: EJB Injection in Interceptor

2009-07-30 Thread David Blevins
Just to note, there has been some work in OpenEJB to make it so Struts  
objects can use Java EE injection like Servlets or JSF components  
can.  Karan did the work, he might be able to give more detail.


-David

On Jul 30, 2009, at 6:16 AM, Wes Wannemacher wrote:


Sorry Robin, this is on my to-do list, but it's not something I'm
working on right this second. One thing that is holding me up is the
lack of knowledge of JEE. Is there a standard mechanism for creating
instances of EJB-hydrated objects? For instance, if you annotated a
field on a servlet with @PersistenceContext, the entity manager will
be populated on the servlet. Obviously this works because the app
server instantiates the servlet and the app server knows to do things
like this. Is it part of the spec(s) that there is a way to
instantiate objects, complete with dependencies injected? I know you
can get objects from the JNDI context, but would that mean that
objects retrieved need to be defined in JNDI? In the example with the
servlet and EM, the servlet is defined in the web.xml, not the JNDI
context... So, is there a place where I can read up on standard
instantiation with EE DI?

If it's not part of the standard, then, I still wouldn't mind building
something specific to the app server that you are using (provided it
is something I can get my hands on for free i.e. JBoss, OpenEJB). I
started looking into this when this came up a few weeks ago, but I
wasn't finding what I wanted so it got put off. If there is a way for
me to call into the app server's own instantiation w/ DI facilities,
writing this plugin would be a snap...

-Wes

On Thu, Jul 30, 2009 at 2:17 AM, Robin Manneringro...@mtndesigns.co.uk 
 wrote:
Just to clear up my actual question from the thread below as  
feedback has

run dry unfortunately.

Is there anybody working daily with Struts 2 and EJB 3.0?

If so, what is the best way to obtain local references to EJB 3  
session

beans from within Struts 2 action classes?

Thanks for any thoughts on this subject.

Robin Mannering wrote:


Just wondering if the below thread has gone any further.

After creating another thread on the same subject at an earlier  
date, we

discussed using the EJB plugin here:

http://cwiki.apache.org/S2PLUGINS/ejb3-plugin.html

However, having started to use this plugin so that I can reference
stateless session beans, it seems that all EJB Session bean  
classes must be
defined as @Remote rather than @Local in order for the injection  
to obtain
the references correctly.  Failure to specify them as remote  
throws a

javax.naming.NameNotFoundException.

However, reading from a book entitled Pro EJB 3.0, the following
performance issues are mentioned in relation to using @Remote when  
@Local is

available.  Hopefully this link will work for you.


http://books.google.co.uk/books?id=fVCuB_Xq3pACpg=PA40lpg=PA40dq=Making+an+interface+remote+has+consequencessource=blots=Bg9DdpVAWWsig=vxrumZhYLhjmqbt6bdMJ96hrY7shl=enei=QIdtStuLC-WhjAf34KGeCwsa=Xoi=book_resultct=resultresnum=

So, the problem is :

How can we obtain references to EJB 3 session beans from within  
Struts 2

action classes?

I'd be very interested to hear your thoughts.

Thanks
Robin

Nathan Schulte wrote:


Wes Wannemacher wesw at wantii.com writes:



Seems to me that my idea to create an ObjectFactory based  
plugin ...

needs to



pick up some steam.



I only have one question for the EJB users out there... Do you  
guys need




Spring integration as well?

To answer your question, _I_ personally don't need Spring  
integration.

 I've
never used Spring, and for this project, it was too much overhead  
to

learn (on
top of Java EE, the JPA, Hibernate intricacies, Struts2...), and  
from

what I
understand, it seemed like using it and S2 together provided  
duplicate

functionality (another topic altogether...).

On another note, I find it awesome that the community (or  
whatever group

you're
part of) is so willing to provide support.  I mean, in my eyes,  
this is
something that I could see myself writing to make my coding  
easier, it's

just
that given my situation, it's easier to use the workaround.
 Admittedly, I'm
not very familiar with JEE5.  Some of this is still black magic,  
and I

don't
fully understand the issue, I just know enough to understand that  
the
architecture permits it as an issue (and not everyone is just  
blowing

smoke my
way) and can leave all of the intricate details be, as they don't
directly
affect my project.

-Nate


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org
  




No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.5.387 / Virus Database:
270.13.20/2248 - Release Date: 07/19/09 05:57:00





Re: Runtime error while using openEJB3.1

2009-01-02 Thread David Blevins

Hi Vikram,

This is an issue in OpenEJB 3.1.  An i18n log message was added  
containing illegal syntax.  One workaround is to set the Transaction  
log category to WARN or ERROR, which will avoid the message in question.


-David

On Jan 1, 2009, at 8:12 PM, vikram.g.by...@accenture.com vikram.g.by...@accenture.com 
 wrote:



Hi,

I am developing an application using Struts 2 (Tiles 2 framework).   
Below are the details of the platform used:


Java:  JDK 1.5
Framework: Strtus 2.0 (Tiles 2.0)
EJB Version:  EJB 3.1
Environment:  Windows XP
Server: Tomcat Apache 5.5


I am getting the following error while invoking a stateful session  
bean from Delegate (client).  We tried both Local  Remote options,  
but no success. We have a all the code deployed in one single  
server, local development setup, Apache Tomcat 5.5 version. Please  
help.


 1) The Local (DefectLocal), Remote (DefectRemote)  Implementation  
(DefectBean) of the Bean are done as per the documentation in open  
ejb  site
 2) The Delegate (client) code also as per the documentation –  
snippet below


 *
 Properties p = new Properties();
//p.put(java.naming.factory.initial,  
org.apache.openejb.client.RemoteInitialContextFactory);
 
p.setProperty(Context.INITIAL_CONTEXT_FACTORY,  
org.apache.openejb.client.LocalInitialContextFactory);
p.put(java.naming.provider.url, http://127.0.0.1:8080/openejb/ejb 
);

// user and pass optional
//p.put(java.naming.security.principal,  
myuser);
//p.put(java.naming.security.credentials,  
mypass);

try {

InitialContext ctx = new  
InitialContext(p);
//DefectBean defectBean =  
(DefectBean) ctx.lookup(DefectBeanRemote);
DefectLocal defectBean =  
(DefectLocal) ctx.lookup(DefectBeanLocal);

return defectBean.createDefect();

} catch (Exception e) {
// TODO: handle exception
 
System.out.println(DefectDelegate.createDefect(): +e);

e.printStackTrace();
}
 
 3) The open EJB jars are kept in the lib (class path)
 4) The openejb.war has been deployed in the Tomcat as per the  
instruction.



 java.util.concurrent.ExecutionException:  
java.lang.IllegalArgumentException: can't parse argument number
at java.util.concurrent.FutureTask$Sync.innerGet(Unknown  
Source)

at java.util.concurrent.FutureTask.get(Unknown Source)
at  
org.apache.openejb.util.Memoizer.compute(Memoizer.java:53)
at  
org.apache.openejb.util.Logger.formatMessage(Logger.java:185)

at org.apache.openejb.util.Logger.debug(Logger.java:234)
at  
org 
.apache 
.openejb 
.core 
.transaction 
.JtaTransactionPolicy.beginTransaction(JtaTransactionPolicy.java:235)
at  
org 
.apache.openejb.core.transaction.TxRequired.init(TxRequired.java:54)
at  
org 
.apache 
.openejb 
.core 
.transaction 
.JtaTransactionPolicyFactory 
.createTransactionPolicy(JtaTransactionPolicyFactory.java:36)
at  
org 
.apache 
.openejb 
.core 
.transaction 
.EjbTransactionUtil.createTransactionPolicy(EjbTransactionUtil.java: 
55)
at  
org 
.apache 
.openejb 
.core 
.stateful.StatefulContainer.createEJBObject(StatefulContainer.java: 
295)
at  
org 
.apache 
.openejb 
.core.stateful.StatefulContainer.invoke(StatefulContainer.java:263)
at  
org 
.apache 
.openejb 
.core.ivm.EjbHomeProxyHandler.create(EjbHomeProxyHandler.java:270)
at  
org 
.apache 
.openejb 
.core.ivm.EjbHomeProxyHandler._invoke(EjbHomeProxyHandler.java:161)
at  
org 
.apache 
.openejb 
.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:286)

at $Proxy45.create(Unknown Source)
at  
org 
.apache 
.openejb 
.core 
.ivm 
.naming.BusinessLocalReference.getObject(BusinessLocalReference.java: 
33)
at  
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java: 
150)
at  
org 
.apache 
.openejb.core.ivm.naming.ContextWrapper.lookup(ContextWrapper.java: 
115)

at javax.naming.InitialContext.lookup(Unknown Source)
at  
com 
.idtt 
.service 
.delegate.defect.DefectDelegate.createDefect(DefectDelegate.java:36)
at com.idtt.web.action.defect.NewDefectSubmitAction.execute 
(NewDefectSubmitAction.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native  
Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown  
Source)
at  
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)