You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Miguel <mi...@almeida.at> on 2011/06/07 19:07:30 UTC

Adding a JNDI lookup yields unexpected Struts errors

Dear all,

I am having a strange problem and was hoping anyone knows why this is
happening.

My web app was working correctly and running in development in jetty
running with maven. I'm using Spring's to inject dependencies.

The problem arises when I add a JNDI entry. To do so I:

1) change my container configuration in Maven's pom, so that it sees
jetty-env.xml:
<webAppConfig>
	<contextPath>/</contextPath>						
	<jettyEnvXml>${basedir}/src/main/resources/jetty/jetty-env.xml
	</jettyEnvXml>
</webAppConfig>

2) Configure a new env-entry in the jetty-env.xml:
<Configure id="myApp" class="org.eclipse.jetty.webapp.WebAppContext">
	<New class="org.eclipse.jetty.plus.jndi.EnvEntry">
		<Arg><Ref id="myApp"/></Arg>	
		<Arg>xoxoGG</Arg>
		<Arg type="java.lang.String">AAA</Arg>
		<Arg type="boolean">true</Arg>
	</New>
</Configure>

3) Add a spring bean definition for this JNDI entry:
<jee:jndi-lookup jndi-name="java:comp/env/xoxoGG"
id="currentEnvironment"  />

The outcome of this is that all links are appended with the value of
xoxoGG (AAA), yielding errors like:
There is no Action mapped for action name
AAA/tutorial/randomiseRedirect. -
or trying to reach http://localhost:8080/AAA/welcome!AAA.action#AAA (why
it is appending so many AAA I don't know)

While this is not strictly a problem with struts, perhaps somehow this
configuration is conflicting with Struts. 
Any help is appreciated in trying to understand this problem!

Regards,

Miguel Almeida



Re: Adding a JNDI lookup yields unexpected Struts errors (Spring injection)

Posted by Lukasz Lenart <lu...@googlemail.com>.
It works for me ...

Hello Lukasz, today is 2011/06/08


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/


2011/6/8 Miguel <mi...@almeida.at>:
> Hi,
>
> I have created a test maven project to demonstrate the issue, based on
> struts archetype.
>
> To see the problem:
>
> 1) run the maven goal jetty:run
> 2) browse to http://localhost:8080
> 3) Write "issue" on the top form and submit
>
> Expected:
> - The action has an "if issue, return login". Login has a global
> redirectAction result to index. I'd expect the action to redirect do index,
> which in turn redirects to /jsp/index.jsp
>
> Actual:
> Error - Problem accessing /zzz/index!zzz.action.
>
> Happens when:
> 1) applicationContext.xml - <jee:jndi-lookup> is active. If you comment this
> line and the referring  <property name="wtf"... , the redirect is correct.
> Notice that zzz is the default for that jndi-lookup (and we haven't
> configured jndi, so the default is being used)
> 2) The login result is a redirectAction. If you change the line in
> struts.xml to, say, <result name="login"> /jsp/index.jsp</result>, the
> problem isn't visible.
>
> Can someone try to understand why this is happening. It might be a very
> basic problem, but I've been looking at this for hours and can't figure out
> what is wrong.
>
> Thank you in advance,
>
> Miguel Almeida
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>

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


Re: Adding a JNDI lookup yields unexpected Struts errors (Spring injection)

Posted by Miguel <mi...@almeida.at>.
Hi,

I have created a test maven project to demonstrate the issue, based on
struts archetype.

To see the problem:

1) run the maven goal jetty:run
2) browse to http://localhost:8080
3) Write "issue" on the top form and submit

Expected:
- The action has an "if issue, return login". Login has a global
redirectAction result to index. I'd expect the action to redirect do
index, which in turn redirects to /jsp/index.jsp

Actual:
Error - Problem accessing /zzz/index!zzz.action.

Happens when:
1) applicationContext.xml - <jee:jndi-lookup> is active. If you comment
this line and the referring  <property name="wtf"... , the redirect is
correct. Notice that zzz is the default for that jndi-lookup (and we
haven't configured jndi, so the default is being used)
2) The login result is a redirectAction. If you change the line in
struts.xml to, say, <result name="login"> /jsp/index.jsp</result>, the
problem isn't visible.

Can someone try to understand why this is happening. It might be a very
basic problem, but I've been looking at this for hours and can't figure
out what is wrong.

Thank you in advance,

Miguel Almeida

Re: Adding a JNDI lookup yields unexpected Struts errors

Posted by Miguel <mi...@almeida.at>.
On a follow-up of the previous post, the error is the same in Tomcat. It
happens whenever this line is added to applicationContext.xml:
<jee:jndi-lookup jndi-name="java:comp/env/xoxoGG"
id="currentEnvironment"  />

Even if no xoxoGG env property is defined, if I add a
default-value="YYY" to the above property Struts will say (for every
action):
There is no Action mapped for action name
YYY/tutorial/randomiseRedirect.

Why is it adding my jndi property to the URL?

On Tue, 2011-06-07 at 18:07 +0100, Miguel wrote:

> Dear all,
> 
> I am having a strange problem and was hoping anyone knows why this is
> happening.
> 
> My web app was working correctly and running in development in jetty
> running with maven. I'm using Spring's to inject dependencies.
> 
> The problem arises when I add a JNDI entry. To do so I:
> 
> 1) change my container configuration in Maven's pom, so that it sees
> jetty-env.xml:
> <webAppConfig>
> 	<contextPath>/</contextPath>						
> 	<jettyEnvXml>${basedir}/src/main/resources/jetty/jetty-env.xml
> 	</jettyEnvXml>
> </webAppConfig>
> 
> 2) Configure a new env-entry in the jetty-env.xml:
> <Configure id="myApp" class="org.eclipse.jetty.webapp.WebAppContext">
> 	<New class="org.eclipse.jetty.plus.jndi.EnvEntry">
> 		<Arg><Ref id="myApp"/></Arg>	
> 		<Arg>xoxoGG</Arg>
> 		<Arg type="java.lang.String">AAA</Arg>
> 		<Arg type="boolean">true</Arg>
> 	</New>
> </Configure>
> 
> 3) Add a spring bean definition for this JNDI entry:
> <jee:jndi-lookup jndi-name="java:comp/env/xoxoGG"
> id="currentEnvironment"  />
> 
> The outcome of this is that all links are appended with the value of
> xoxoGG (AAA), yielding errors like:
> There is no Action mapped for action name
> AAA/tutorial/randomiseRedirect. -
> or trying to reach http://localhost:8080/AAA/welcome!AAA.action#AAA (why
> it is appending so many AAA I don't know)
> 
> While this is not strictly a problem with struts, perhaps somehow this
> configuration is conflicting with Struts. 
> Any help is appreciated in trying to understand this problem!
> 
> Regards,
> 
> Miguel Almeida
> 
>