You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by Karan Malhi <ka...@gmail.com> on 2009/02/22 00:35:10 UTC

[QUESTION] JaxbJavaee and struts 2 config

Try to add injection support for struts 2 actions, interceptors and results.
One of the things I have to do is read struts config files and discover
action classes. Was trying to use JaxbJavaee from the JEE module and it did
not work. I had done something similar with JSF without any issues.

The difference probably is that struts config files are based off of DTD's
instead of Schemas. And thats where I think JaxbJavaee blows up. I am
thinking of bypassing JaxbJavaee to read descriptors , does anybody have any
issues with me using straight JAXB API instead?
Secondly, when I generated java classes from JSF schema, I put them under
the JEE module in package org.apache.openejb.jee , where would i put the
generated classes for struts (module and package)?

-- 
Karan Singh Malhi

Re: [QUESTION] JaxbJavaee and struts 2 config

Posted by David Blevins <da...@visi.com>.
On Mar 8, 2009, at 7:26 AM, Karan Malhi wrote:

> It needed a ServletContext, I passed in null and worked fine.  
> However, there
> are some class loading issues. Struts throws an exception when it  
> tries to
> load an already loaded class, and then it stops right there, i.e.  
> does not
> go on to  process other classes. Trying to see if I can find other  
> options.

That's very puzzling.  The only possible "already loaded" issue that I  
can think of is if the class is loaded in two different classloaders  
and conflicts occur when attempting to use them as the same class as  
they are technically not the same class anymore.  Certainly asking for  
a class to be loaded that has already been loaded in that classloader  
is going to work.

-David


Re: [QUESTION] JaxbJavaee and struts 2 config

Posted by Karan Malhi <ka...@gmail.com>.
It needed a ServletContext, I passed in null and worked fine. However, there
are some class loading issues. Struts throws an exception when it tries to
load an already loaded class, and then it stops right there, i.e. does not
go on to  process other classes. Trying to see if I can find other options.

On Sat, Mar 7, 2009 at 7:40 PM, David Blevins <da...@visi.com>wrote:

>
> On Mar 7, 2009, at 3:15 PM, Karan Malhi wrote:
>
>  Looks like we will have to create a Jaxb tree for struts and scan struts
>> actions ourselves. I did find some struts facilities which will give me
>> the
>> info  about all "struts actions", but struts provides us with that
>> information after the webapp starts. We need this information "before" the
>> app starts. So, for now, so that we can add atleast some support for
>> struts
>> actions.
>>
>
> So what does struts need that isn't available?   I think you mentioned on
> IRC somehting about the ServletConfig?  Any idea what they're pulling out of
> that object?  Maybe we can give them a mock impl.
>
> -David
>
>


-- 
Karan Singh Malhi

Re: [QUESTION] JaxbJavaee and struts 2 config

Posted by David Blevins <da...@visi.com>.
On Mar 7, 2009, at 3:15 PM, Karan Malhi wrote:

> Looks like we will have to create a Jaxb tree for struts and scan  
> struts
> actions ourselves. I did find some struts facilities which will give  
> me the
> info  about all "struts actions", but struts provides us with that
> information after the webapp starts. We need this information  
> "before" the
> app starts. So, for now, so that we can add atleast some support for  
> struts
> actions.

So what does struts need that isn't available?   I think you mentioned  
on IRC somehting about the ServletConfig?  Any idea what they're  
pulling out of that object?  Maybe we can give them a mock impl.

-David


Re: [QUESTION] JaxbJavaee and struts 2 config

Posted by Karan Malhi <ka...@gmail.com>.
Looks like we will have to create a Jaxb tree for struts and scan struts
actions ourselves. I did find some struts facilities which will give me the
info  about all "struts actions", but struts provides us with that
information after the webapp starts. We need this information "before" the
app starts. So, for now, so that we can add atleast some support for struts
actions.

On Wed, Mar 4, 2009 at 9:54 PM, David Blevins <da...@visi.com>wrote:

> So maybe another module like we did with the Spring stuff.  Perhaps a
> container/openejb-struts/ module.
>
> This doesn't necessarily answer how we would plug it into the deployment
> process as we wouldn't want openejb-core to be dependent on the
> openejb-struts module, but we could potentially add some sort of classpath
> discovered abstraction for hooking it in.  Basically something we use the
> ResourceFinder.mapAllImplementations(Class) method to discover things that
> want to participate in some form of deployment.  These types of abstractions
> are always wrong on their first go around, so there's no need for it to bite
> off more than we can chew in this first iteration.  We can totally keep it
> very struts focused with the minimal goal of getting the hook in exactly,
> and only, where you need it to accomplish this task.  I.e. no need to make a
> general hook, in fact better not to initially.
>
> My thoughts anyways.
>
> -David
>
>
>
> On Mar 4, 2009, at 6:27 PM, Karan Malhi wrote:
>
>  Ignore the Jaxb + reflection comment. I dont think I was thinking right
>> when
>> i wrote the email.
>>
>> Regarding how much code, there would atleast be 4-6 struts classes
>> involved
>> for the code which goes inside openejb-core, this is the code which will
>> discover classes which are candidates for injection. We would also need a
>> separate project to create the struts-plugin which will perform the actual
>> injection.
>> On Wed, Mar 4, 2009 at 8:05 PM, David Blevins <david.blevins@visi.com
>> >wrote:
>>
>>
>>> On Mar 4, 2009, at 12:08 PM, Karan Malhi wrote:
>>>
>>> I am using struts facilities to discover classes which could be
>>> candidates
>>>
>>>> for injection. Struts provides me with those classes, but that means add
>>>> struts jar to the classpath of openejb-core if we want to add struts
>>>> support. Not sure if we want to do that or not. Please advise.
>>>> Should i use reflection instead and load our own Jaxb tree from struts
>>>> dtd?
>>>>
>>>>
>>> How much code using struts are we talking about?  Reflection is always an
>>> option for eliminating the compile time and even runtime requirement.
>>>
>>> Not sure I understood the jaxb + reflection comment.  Seems you have a
>>> way
>>> of going directly at Struts without the need for us to parse the
>>> struts.xml
>>> file.  If that's the case, seems we could use that way via reflection.
>>>
>>> At any rate, I'm sure we can figure something out.
>>>
>>> -David
>>>
>>>
>>>
>>>  On Sat, Feb 21, 2009 at 7:26 PM, David Blevins <david.blevins@visi.com
>>>>
>>>>> wrote:
>>>>>
>>>>
>>>>
>>>>  On Feb 21, 2009, at 3:35 PM, Karan Malhi wrote:
>>>>>
>>>>> Try to add injection support for struts 2 actions, interceptors and
>>>>>
>>>>>  results.
>>>>>> One of the things I have to do is read struts config files and
>>>>>> discover
>>>>>> action classes. Was trying to use JaxbJavaee from the JEE module and
>>>>>> it
>>>>>> did
>>>>>> not work. I had done something similar with JSF without any issues.
>>>>>>
>>>>>> The difference probably is that struts config files are based off of
>>>>>> DTD's
>>>>>> instead of Schemas. And thats where I think JaxbJavaee blows up. I am
>>>>>> thinking of bypassing JaxbJavaee to read descriptors , does anybody
>>>>>> have
>>>>>> any
>>>>>> issues with me using straight JAXB API instead?
>>>>>>
>>>>>>
>>>>>>  That's cool.  We essentially have one Jaxb* class for each schema
>>>>> because
>>>>> of the namespace filtering we do -- i.e. coercing the xml we're reading
>>>>> into
>>>>> the right namespace.
>>>>>
>>>>> Secondly, when I generated java classes from JSF schema, I put them
>>>>> under
>>>>>
>>>>>  the JEE module in package org.apache.openejb.jee , where would i put
>>>>>> the
>>>>>> generated classes for struts (module and package)?
>>>>>>
>>>>>>
>>>>>>  It's fine to put it in the openejb-jee module but it has to be in
>>>>> another
>>>>> package or Jaxb will get cranky.  Maybe in the package
>>>>> org.apache.openejb.jee.struts or something.
>>>>>
>>>>> -David
>>>>>
>>>>>
>>>>>
>>>>>
>>>> --
>>>> Karan Singh Malhi
>>>>
>>>>
>>>
>>>
>>
>> --
>> Karan Singh Malhi
>>
>
>


-- 
Karan Singh Malhi

Re: [QUESTION] JaxbJavaee and struts 2 config

Posted by David Blevins <da...@visi.com>.
So maybe another module like we did with the Spring stuff.  Perhaps a  
container/openejb-struts/ module.

This doesn't necessarily answer how we would plug it into the  
deployment process as we wouldn't want openejb-core to be dependent on  
the openejb-struts module, but we could potentially add some sort of  
classpath discovered abstraction for hooking it in.  Basically  
something we use the ResourceFinder.mapAllImplementations(Class)  
method to discover things that want to participate in some form of  
deployment.  These types of abstractions are always wrong on their  
first go around, so there's no need for it to bite off more than we  
can chew in this first iteration.  We can totally keep it very struts  
focused with the minimal goal of getting the hook in exactly, and  
only, where you need it to accomplish this task.  I.e. no need to make  
a general hook, in fact better not to initially.

My thoughts anyways.

-David


On Mar 4, 2009, at 6:27 PM, Karan Malhi wrote:

> Ignore the Jaxb + reflection comment. I dont think I was thinking  
> right when
> i wrote the email.
>
> Regarding how much code, there would atleast be 4-6 struts classes  
> involved
> for the code which goes inside openejb-core, this is the code which  
> will
> discover classes which are candidates for injection. We would also  
> need a
> separate project to create the struts-plugin which will perform the  
> actual
> injection.
> On Wed, Mar 4, 2009 at 8:05 PM, David Blevins  
> <da...@visi.com>wrote:
>
>>
>> On Mar 4, 2009, at 12:08 PM, Karan Malhi wrote:
>>
>> I am using struts facilities to discover classes which could be  
>> candidates
>>> for injection. Struts provides me with those classes, but that  
>>> means add
>>> struts jar to the classpath of openejb-core if we want to add struts
>>> support. Not sure if we want to do that or not. Please advise.
>>> Should i use reflection instead and load our own Jaxb tree from  
>>> struts
>>> dtd?
>>>
>>
>> How much code using struts are we talking about?  Reflection is  
>> always an
>> option for eliminating the compile time and even runtime requirement.
>>
>> Not sure I understood the jaxb + reflection comment.  Seems you  
>> have a way
>> of going directly at Struts without the need for us to parse the  
>> struts.xml
>> file.  If that's the case, seems we could use that way via  
>> reflection.
>>
>> At any rate, I'm sure we can figure something out.
>>
>> -David
>>
>>
>>
>>> On Sat, Feb 21, 2009 at 7:26 PM, David Blevins <david.blevins@visi.com
>>>> wrote:
>>>
>>>
>>>> On Feb 21, 2009, at 3:35 PM, Karan Malhi wrote:
>>>>
>>>> Try to add injection support for struts 2 actions, interceptors and
>>>>
>>>>> results.
>>>>> One of the things I have to do is read struts config files and  
>>>>> discover
>>>>> action classes. Was trying to use JaxbJavaee from the JEE module  
>>>>> and it
>>>>> did
>>>>> not work. I had done something similar with JSF without any  
>>>>> issues.
>>>>>
>>>>> The difference probably is that struts config files are based  
>>>>> off of
>>>>> DTD's
>>>>> instead of Schemas. And thats where I think JaxbJavaee blows up.  
>>>>> I am
>>>>> thinking of bypassing JaxbJavaee to read descriptors , does  
>>>>> anybody have
>>>>> any
>>>>> issues with me using straight JAXB API instead?
>>>>>
>>>>>
>>>> That's cool.  We essentially have one Jaxb* class for each schema  
>>>> because
>>>> of the namespace filtering we do -- i.e. coercing the xml we're  
>>>> reading
>>>> into
>>>> the right namespace.
>>>>
>>>> Secondly, when I generated java classes from JSF schema, I put  
>>>> them under
>>>>
>>>>> the JEE module in package org.apache.openejb.jee , where would i  
>>>>> put the
>>>>> generated classes for struts (module and package)?
>>>>>
>>>>>
>>>> It's fine to put it in the openejb-jee module but it has to be in  
>>>> another
>>>> package or Jaxb will get cranky.  Maybe in the package
>>>> org.apache.openejb.jee.struts or something.
>>>>
>>>> -David
>>>>
>>>>
>>>>
>>>
>>> --
>>> Karan Singh Malhi
>>>
>>
>>
>
>
> -- 
> Karan Singh Malhi


Re: [QUESTION] JaxbJavaee and struts 2 config

Posted by Karan Malhi <ka...@gmail.com>.
Ignore the Jaxb + reflection comment. I dont think I was thinking right when
i wrote the email.

Regarding how much code, there would atleast be 4-6 struts classes involved
for the code which goes inside openejb-core, this is the code which will
discover classes which are candidates for injection. We would also need a
separate project to create the struts-plugin which will perform the actual
injection.
On Wed, Mar 4, 2009 at 8:05 PM, David Blevins <da...@visi.com>wrote:

>
> On Mar 4, 2009, at 12:08 PM, Karan Malhi wrote:
>
> I am using struts facilities to discover classes which could be candidates
>> for injection. Struts provides me with those classes, but that means add
>> struts jar to the classpath of openejb-core if we want to add struts
>> support. Not sure if we want to do that or not. Please advise.
>> Should i use reflection instead and load our own Jaxb tree from struts
>> dtd?
>>
>
> How much code using struts are we talking about?  Reflection is always an
> option for eliminating the compile time and even runtime requirement.
>
> Not sure I understood the jaxb + reflection comment.  Seems you have a way
> of going directly at Struts without the need for us to parse the struts.xml
> file.  If that's the case, seems we could use that way via reflection.
>
> At any rate, I'm sure we can figure something out.
>
> -David
>
>
>
>> On Sat, Feb 21, 2009 at 7:26 PM, David Blevins <david.blevins@visi.com
>> >wrote:
>>
>>
>>> On Feb 21, 2009, at 3:35 PM, Karan Malhi wrote:
>>>
>>> Try to add injection support for struts 2 actions, interceptors and
>>>
>>>> results.
>>>> One of the things I have to do is read struts config files and discover
>>>> action classes. Was trying to use JaxbJavaee from the JEE module and it
>>>> did
>>>> not work. I had done something similar with JSF without any issues.
>>>>
>>>> The difference probably is that struts config files are based off of
>>>> DTD's
>>>> instead of Schemas. And thats where I think JaxbJavaee blows up. I am
>>>> thinking of bypassing JaxbJavaee to read descriptors , does anybody have
>>>> any
>>>> issues with me using straight JAXB API instead?
>>>>
>>>>
>>> That's cool.  We essentially have one Jaxb* class for each schema because
>>> of the namespace filtering we do -- i.e. coercing the xml we're reading
>>> into
>>> the right namespace.
>>>
>>> Secondly, when I generated java classes from JSF schema, I put them under
>>>
>>>> the JEE module in package org.apache.openejb.jee , where would i put the
>>>> generated classes for struts (module and package)?
>>>>
>>>>
>>> It's fine to put it in the openejb-jee module but it has to be in another
>>> package or Jaxb will get cranky.  Maybe in the package
>>> org.apache.openejb.jee.struts or something.
>>>
>>> -David
>>>
>>>
>>>
>>
>> --
>> Karan Singh Malhi
>>
>
>


-- 
Karan Singh Malhi

Re: [QUESTION] JaxbJavaee and struts 2 config

Posted by David Blevins <da...@visi.com>.
On Mar 4, 2009, at 12:08 PM, Karan Malhi wrote:

> I am using struts facilities to discover classes which could be  
> candidates
> for injection. Struts provides me with those classes, but that means  
> add
> struts jar to the classpath of openejb-core if we want to add struts
> support. Not sure if we want to do that or not. Please advise.
> Should i use reflection instead and load our own Jaxb tree from  
> struts dtd?

How much code using struts are we talking about?  Reflection is always  
an option for eliminating the compile time and even runtime requirement.

Not sure I understood the jaxb + reflection comment.  Seems you have a  
way of going directly at Struts without the need for us to parse the  
struts.xml file.  If that's the case, seems we could use that way via  
reflection.

At any rate, I'm sure we can figure something out.

-David

>
> On Sat, Feb 21, 2009 at 7:26 PM, David Blevins  
> <da...@visi.com>wrote:
>
>>
>> On Feb 21, 2009, at 3:35 PM, Karan Malhi wrote:
>>
>> Try to add injection support for struts 2 actions, interceptors and
>>> results.
>>> One of the things I have to do is read struts config files and  
>>> discover
>>> action classes. Was trying to use JaxbJavaee from the JEE module  
>>> and it
>>> did
>>> not work. I had done something similar with JSF without any issues.
>>>
>>> The difference probably is that struts config files are based off  
>>> of DTD's
>>> instead of Schemas. And thats where I think JaxbJavaee blows up. I  
>>> am
>>> thinking of bypassing JaxbJavaee to read descriptors , does  
>>> anybody have
>>> any
>>> issues with me using straight JAXB API instead?
>>>
>>
>> That's cool.  We essentially have one Jaxb* class for each schema  
>> because
>> of the namespace filtering we do -- i.e. coercing the xml we're  
>> reading into
>> the right namespace.
>>
>> Secondly, when I generated java classes from JSF schema, I put them  
>> under
>>> the JEE module in package org.apache.openejb.jee , where would i  
>>> put the
>>> generated classes for struts (module and package)?
>>>
>>
>> It's fine to put it in the openejb-jee module but it has to be in  
>> another
>> package or Jaxb will get cranky.  Maybe in the package
>> org.apache.openejb.jee.struts or something.
>>
>> -David
>>
>>
>
>
> -- 
> Karan Singh Malhi


Re: [QUESTION] JaxbJavaee and struts 2 config

Posted by Karan Malhi <ka...@gmail.com>.
I am using struts facilities to discover classes which could be candidates
for injection. Struts provides me with those classes, but that means add
struts jar to the classpath of openejb-core if we want to add struts
support. Not sure if we want to do that or not. Please advise.
Should i use reflection instead and load our own Jaxb tree from struts dtd?
On Sat, Feb 21, 2009 at 7:26 PM, David Blevins <da...@visi.com>wrote:

>
> On Feb 21, 2009, at 3:35 PM, Karan Malhi wrote:
>
> Try to add injection support for struts 2 actions, interceptors and
>> results.
>> One of the things I have to do is read struts config files and discover
>> action classes. Was trying to use JaxbJavaee from the JEE module and it
>> did
>> not work. I had done something similar with JSF without any issues.
>>
>> The difference probably is that struts config files are based off of DTD's
>> instead of Schemas. And thats where I think JaxbJavaee blows up. I am
>> thinking of bypassing JaxbJavaee to read descriptors , does anybody have
>> any
>> issues with me using straight JAXB API instead?
>>
>
> That's cool.  We essentially have one Jaxb* class for each schema because
> of the namespace filtering we do -- i.e. coercing the xml we're reading into
> the right namespace.
>
> Secondly, when I generated java classes from JSF schema, I put them under
>> the JEE module in package org.apache.openejb.jee , where would i put the
>> generated classes for struts (module and package)?
>>
>
> It's fine to put it in the openejb-jee module but it has to be in another
> package or Jaxb will get cranky.  Maybe in the package
> org.apache.openejb.jee.struts or something.
>
> -David
>
>


-- 
Karan Singh Malhi

Re: [QUESTION] JaxbJavaee and struts 2 config

Posted by David Blevins <da...@visi.com>.
On Feb 21, 2009, at 3:35 PM, Karan Malhi wrote:

> Try to add injection support for struts 2 actions, interceptors and  
> results.
> One of the things I have to do is read struts config files and  
> discover
> action classes. Was trying to use JaxbJavaee from the JEE module and  
> it did
> not work. I had done something similar with JSF without any issues.
>
> The difference probably is that struts config files are based off of  
> DTD's
> instead of Schemas. And thats where I think JaxbJavaee blows up. I am
> thinking of bypassing JaxbJavaee to read descriptors , does anybody  
> have any
> issues with me using straight JAXB API instead?

That's cool.  We essentially have one Jaxb* class for each schema  
because of the namespace filtering we do -- i.e. coercing the xml  
we're reading into the right namespace.

> Secondly, when I generated java classes from JSF schema, I put them  
> under
> the JEE module in package org.apache.openejb.jee , where would i put  
> the
> generated classes for struts (module and package)?

It's fine to put it in the openejb-jee module but it has to be in  
another package or Jaxb will get cranky.  Maybe in the package  
org.apache.openejb.jee.struts or something.

-David