You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by matthew grisius <ma...@comcast.net> on 2016/11/07 17:14:31 UTC

Change Solr contextPath =“/“ ?

I previously asked this question and did not receive any suggestions.
I also asked on Jetty-Users and one person suggested I ask again here so I thought it might be worth it to ask again.

Solr is deployed to “/solr” and is then mapped to “/“, e.g. http://localhost:8983/ <http://localhost:8983/> gets mapped to http://localhost:8983/solr/# <http://localhost:8983/solr/#>.
I want to put a different servlet at “/“ while preserving Solr functionality at “/solr”.
The reason for this is that I previously deployed my app with Solr on tomcat/tomee via war file and now want to use a current Solr release using Solr/Jetty.

I thought the way to accomplish that was to re-assign  the "root context", e.g. contextPath =“/“ but cannot find a way to do this with Solr/Jetty.

My unsuccessful attempts included:

- edit contexts/solr-jetty-context.xml (contextPath, add resourceBase, etc.)
- unmap solr rewrite rule to pass thru . . .
- edit other '/contexts/' . . .
- edit etc/webdefault.xml . . .
- bin/solr does not appear to affect "/"
- org.apache.solr.util.SolrCLI does not appear to affect "/"

Perhaps I’m not trying the right combination of things in the right order to solve the issue, but I’ve run out of simple ideas to try.

Does anyone have any other suggestions?
Thank you, any help would be appreciated!

-matt.

Re: Change Solr contextPath =“/“ ?

Posted by Christian Ortner <ch...@gmail.com>.
Hi Matthew,

your problem sounds like you want to run something alongside Solr, that
probably uses Solr. Since current versions of Solr basically require you to
go over HTTP, you could deploy the thing you would like to run in the root
context in a separate application container that accesses Solr over HTTP.

Alternatively, if the path is the only issue, you could just put a reverse
proxy in front of your application server and re-map the path to you
context that sits beside Solr.

Making changes like the ones you are suggesting are difficult in current
versions of Solr, where everything is coupled tightly to Jetty, so I hope
my suggestions can inspire you to find the perfect solution for this
problem.

Best regards,
Chris

On Mon, Nov 7, 2016 at 6:14 PM, matthew grisius <matthew.grisius@comcast.net
> wrote:

> I previously asked this question and did not receive any suggestions.
> I also asked on Jetty-Users and one person suggested I ask again here so I
> thought it might be worth it to ask again.
>
> Solr is deployed to “/solr” and is then mapped to “/“, e.g.
> http://localhost:8983/ <http://localhost:8983/> gets mapped to
> http://localhost:8983/solr/# <http://localhost:8983/solr/#>.
> I want to put a different servlet at “/“ while preserving Solr
> functionality at “/solr”.
> The reason for this is that I previously deployed my app with Solr on
> tomcat/tomee via war file and now want to use a current Solr release using
> Solr/Jetty.
>
> I thought the way to accomplish that was to re-assign  the "root context",
> e.g. contextPath =“/“ but cannot find a way to do this with Solr/Jetty.
>
> My unsuccessful attempts included:
>
> - edit contexts/solr-jetty-context.xml (contextPath, add resourceBase,
> etc.)
> - unmap solr rewrite rule to pass thru . . .
> - edit other '/contexts/' . . .
> - edit etc/webdefault.xml . . .
> - bin/solr does not appear to affect "/"
> - org.apache.solr.util.SolrCLI does not appear to affect "/"
>
> Perhaps I’m not trying the right combination of things in the right order
> to solve the issue, but I’ve run out of simple ideas to try.
>
> Does anyone have any other suggestions?
> Thank you, any help would be appreciated!
>
> -matt.

Re: potential issue/bug reported by Jetty team? was: Re: Change Solr contextPath =“/“ ?

Posted by Shawn Heisey <ap...@elyograg.org>.
On 11/16/2016 10:22 AM, matthew grisius wrote:
> Looks like a little bug on solr. In jetty 9.1.something we changed the
> definition of the webdefault.xml file to avoid the "Uncovered http
> methods" warning.

I have opened an issue for this.

https://issues.apache.org/jira/browse/SOLR-9781

When I find some free time, I will look at all the Jetty config files
and try to refresh them with current defaults.

Thanks,
Shawn


potential issue/bug reported by Jetty team? was: Re: Change Solr contextPath =“/“ ?

Posted by matthew grisius <ma...@comcast.net>.
I can now deploy my app that uses Solr via Jetty similar to my previous tomcat/tomee+ stack war deployment thanks to the Jetty team (Simone Bordet).
It turned out to be very straightforward.
Per his suggestion I commented out the RewriteHandler def and reference in $solr/server/etc/jetty.xml.
Then I add standard servlet or static content at “/“ in server/etc/ dir:

CLJServlet.xml:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd <http://www.eclipse.org/jetty/configure_9_0.dtd>">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <!-- set "root context" .e.g. "/" -->
  <Set name="contextPath"><Property name="hostContext" default="/"/></Set>
  <!-- set non-root context, e.g. "/CLJServlet" -->
  <!-- <Set name="contextPath"><Property name="hostContext" default="/CLJServlet"/></Set> -->
  <Set name="war"><Property name="jetty.base"/>/webapps/CLJServlet</Set>
  <Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml</Set>
</Configure>

foo.xml:

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd <http://www.eclipse.org/jetty/configure_9_0.dtd>">
<Configure class="org.eclipse.jetty.server.handler.ContextHandler">
  <!-- set "root context" .e.g. "/" -->
  <!-- <Set name="contextPath"><Property name="hostContext" default="/"/></Set> -->
  <!-- set non-root context, e.g. "/foo" -->
  <Set name="contextPath"><Property name="hostContext" default="/foo"/></Set>
  <Set name="resourceBase"><Property name="jetty.home" />/webapps/foo</Set>
  <Set name="handler">
    <New class="org.eclipse.jetty.server.handler.ResourceHandler">
      <!-- nothing required here --> 
    </New>
  </Set>
</Configure>

I did report an interesting Jetty warning that tomcat/tomee+ did not catch for my servlet:
Log4j (org.slf4j.impl.Log4jLoggerFactory) warnings: {/CLJServlet} has uncovered http methods for path: /

The Jetty team (Jan Bartel) responded back and suggested a fix and suggested that I notify the Solr team, here is his reply in case it might help Solr Team:

Looks like a little bug on solr.  In jetty 9.1.something we changed the definition of the webdefault.xml file to avoid the "Uncovered http methods" warning. This is related to the security-constraint for the TRACE method.  We used to have:

  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Disable TRACE</web-resource-name>
      <url-pattern>/</url-pattern>
      <http-method>TRACE</http-method>
    </web-resource-collection>
    <auth-constraint/>
  </security-constraint>

Which meant that according to the servlet spec there were indeed uncovered methods.

So we changed it to this couplet instead:

  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Disable TRACE</web-resource-name>
      <url-pattern>/</url-pattern>
      <http-method>TRACE</http-method>
    </web-resource-collection>
    <auth-constraint/>
  </security-constraint>
  <security-constraint>
    <web-resource-collection>
      <web-resource-name>Enable everything but TRACE</web-resource-name>
      <url-pattern>/</url-pattern>
      <http-method-omission>TRACE</http-method-omission>
    </web-resource-collection>
  </security-constraint>

However, I notice that solr has the old definition in their etc/webdefault.xml file, and they have chosen to add the extra definition only to the web.xml file of their solr-webapp.

So the easiest thing for you to do is:

1. copy the extra security-constraint into the etc/webdefault.xml file so it applies to all webapps
2. let solr know :)

> On Nov 7, 2016, at 12:14 PM, matthew grisius <ma...@comcast.net> wrote:
> 
> I previously asked this question and did not receive any suggestions.
> I also asked on Jetty-Users and one person suggested I ask again here so I thought it might be worth it to ask again.
> 
> Solr is deployed to “/solr” and is then mapped to “/“, e.g. http://localhost:8983/ <http://localhost:8983/> gets mapped to http://localhost:8983/solr/# <http://localhost:8983/solr/#>.
> I want to put a different servlet at “/“ while preserving Solr functionality at “/solr”.
> The reason for this is that I previously deployed my app with Solr on tomcat/tomee via war file and now want to use a current Solr release using Solr/Jetty.
> 
> I thought the way to accomplish that was to re-assign  the "root context", e.g. contextPath =“/“ but cannot find a way to do this with Solr/Jetty.
> 
> My unsuccessful attempts included:
> 
> - edit contexts/solr-jetty-context.xml (contextPath, add resourceBase, etc.)
> - unmap solr rewrite rule to pass thru . . .
> - edit other '/contexts/' . . .
> - edit etc/webdefault.xml . . .
> - bin/solr does not appear to affect "/"
> - org.apache.solr.util.SolrCLI does not appear to affect "/"
> 
> Perhaps I’m not trying the right combination of things in the right order to solve the issue, but I’ve run out of simple ideas to try.
> 
> Does anyone have any other suggestions?
> Thank you, any help would be appreciated!
> 
> -matt.