Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] context parameter

Hello,

I apologize, my code example yesterday is incorrect (big thanks to Jan Bartel for pointing this out to me and helping me with the correct syntax). A much more simplified way of this would be:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Get name="initParams">
   <Put name="propertiesDir">C:/Users/myname/workspaceProva/propertiesDir</Put>
</Get>
</Configure>

You could also do the following, using setInitParameter on WebAppContext:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
 <Call name="setInitParameter">
   <Arg>propertiesDir</Arg>
   <Arg>C:/Users/myname/workspaceProva/propertiesDir</Arg>
</Call>
</Configure>

Best,
Chris

On Tue, Aug 9, 2016 at 12:32 PM, Chris Walker <chris@xxxxxxxxxxx> wrote:
Hello,

As Simone pointed out, there is no setInitParams method, rather it is getInitParams.  In your case this would look like

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Get name="InitParams">
   <Map>
     <Entry>
       <Item>propertiesDir</Item>
       <Item>C:/Users/myname/workspaceProva/propertiesDir</Item>
     </Entry>
   </Map>
</Get>
</Configure>

This XML is the same as doing the following in Java:

Map testmap = new HashMap();
testmap.put("propertiesDir", "C:/Users/myname/workspaceProva/propertiesDir");

You can find documentation on Jetty XML syntax here.

Regards,
Chris

On Tue, Aug 9, 2016 at 12:02 PM, Simone Bordet <sbordet@xxxxxxxxxxx> wrote:
Hi,

On Tue, Aug 9, 2016 at 5:43 PM, Andrea Franceschini <atariw@xxxxxxxxx> wrote:
> Dear Jetty team,
>
> I am trying to add a context parameter to Jetty, using a jetty-web.xml file:
>
> <?xml version="1.0"  encoding="UTF-8"?>
> <!DOCTYPE Configure PUBLIC
>     "-//Mort Bay Consulting//DTD Configure//EN"
>     "http://www.eclipse.org/jetty/configure_9_0.dtd">
>
> <Configure class="org.eclipse.jetty.webapp.WebAppContext">
> <Set name="initParams">
>    <Map>
>      <Entry>
>        <Item>propertiesDir</Item>
>        <Item>C:/Users/myname/workspaceProva/propertiesDir</Item>
>      </Entry>
>    </Map>
> </Set>
> </Configure>
>
>
> I am getting this exception:
>
>
>   ____    ___                   __    __  __         ___
>   / __/___/ (_)__  ___ ___   __ / /__ / /_/ /___ __  / _ \
>  / _// __/ / / _ \(_-</ -_) / // / -_) __/ __/ // /  \_, /
> /___/\__/_/_/ .__/___/\__/  \___/\__/\__/\__/\_, /  /___/
>            /_/                              /___/
> 2016-08-09 15:11:57.595:INFO::main: Logging initialized @2166ms
>    Configuration:
> C:\Users\AD7E7~1.FRA\AppData\Local\Temp\eclipseJettyPlugin.config.ReplyGAjetty.xml
>
> C:\Users\a.franceschini\workspaceProva\Servers\jetty\jetty-web.xml
> 2016-08-09 15:11:57.821:WARN:oejx.XmlConfiguration:main: Config error
> at <Set name="initParams">|?
> <Map><Entry><Item>propertiesDir</Item><Item>C:/Users/myname/workspaceProva/propertiesDir</Item></Entry></Map>|?</Set>
> java.lang.NoSuchMethodException: class
> org.eclipse.jetty.webapp.WebAppContext.setInitParams(class
> java.util.HashMap) in null

There is no such method.

You should *get* the initParams map, and then just call put() on it.
Jetty's XML can replicate invoking any Java code.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



Back to the top