1

I am new to jetty. I used to deploy solr using tomcat. But we moved to solr6 and I had hard time configuring resources in jetty which comes with solr 6.

How can I configure JNDI resource in Solr 6?

This is what I have tried so far with no luck.

Added below config in solr-6.4.0/server/etc/jetty.xml

<New id="test" class="org.eclipse.jetty.plus.jndi.Resource">
      <Arg></Arg>
      <Arg>jdbc/DSTest</Arg>
      <Arg>
          <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
              <Set name="Url">jdbc:mysql://localhost:3306/db</Set>
              <Set name="User">root</Set>
              <Set name="Password"></Set>
          </New>
      </Arg>
  </New>

And in solr-6.4.0/server/solr-webapp/webapp/WEB-INF/web.xml

<resource-ref>
      <description>My DataSource Reference</description>
      <res-ref-name>jdbc/DSTest</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>

I added two jars jetty-plus-9.3.14.v20161028.jar and mysql-connector-java-5.1.41-bin.jar to solr-6.4.0/server/lib/ext/

java -jar start.jar --list-modules says

Jetty All Available Modules:
----------------------------

 [ ] Module: http
     Depend: server
        XML: etc/jetty-http.xml
    Enabled: <not enabled in this configuration>

 [ ] Module: https
     Depend: ssl
        XML: etc/jetty-https.xml
    Enabled: <not enabled in this configuration>

 [ ] Module: server
        LIB: lib/*.jar
        LIB: lib/ext/*.jar
        LIB: resources/
        XML: etc/jetty.xml
    Enabled: <not enabled in this configuration>

 [ ] Module: ssl
     Depend: server
        XML: etc/jetty-ssl.xml
    Enabled: <not enabled in this configuration>

Jetty Selected Module Ordering:
------------------------------

Solr 6 documentation does not talk about how to go about JNDI. Any pointers would help. Thanks.

starkk92
  • 5,754
  • 9
  • 43
  • 59

1 Answers1

2

I got Solr working with JNDI by mostly doing what you did, but some changes:

  1. add your config to contexts/solr-jetty-context.xml, not to server/etc/jetty.xml
  2. do this for each of: jndi/plus/ext replacing 'jaas' below (some combinations do not exists, so ignore them):
    1. Copy modules/jaas.mod to the unpacked solr directory server/modules
    2. Copy etc/jetty-jaas.xml to server/etc
    3. Copy the lib/jetty-jaas-.jar to server/lib
  3. run

    java -jar start.jar --add-to-startd=plus
    java -jar start.jar --add-to-startd=ext
    
  4. verify modules available:

    java -jar start.jar --list-modules
    
  5. you might need to add other jars to lib/ext, like guava or bonecp.
Persimmonium
  • 15,593
  • 11
  • 47
  • 78