okay this looks promising. I will give it a try and let you know how it goes. Thanks
On Wed, Apr 17, 2013 at 9:19 AM, jnduan <jnd...@gmail.com> wrote: > hi Adeel, > I have use solr with maven since 2011,and my dependency is not solr but > solr-core and some other dependencies . > therefore,my project structure is just like unpack the solr.war file with > out the dir 'WEB-INF/lib'. > > So I can write some code work with solr ,e.g. a listener set up system > properties 'solr.solr.home' to the right path before solr is lunch.Even set > up some properties for zookeeper in solr 4.2.1. > > You said your solr home's source path is > 'src/main/resources/solr-dev/',that means the solr home is > 'WEB-INF/classes/solr-dev' at the runtime.Then just use > ClassLoader.getResource() in a ServletContextListener to get the absolute > path of solr home ,just like this: > > private static final String SOLR_HOME_PROP_NAME = "solr.solr.home"; > > …………. > > try { > URL url = > this.getClass().getClassLoader().getResource("/solr-dev"); > if (url != null) { > File file = new File(url.toURI()); > if (file.exists()) { > > System.setProperty(SOLR_HOME_PROP_NAME,file.getCanonicalPath()); > logger.info(" Set /solr/home to system > properties,key:{}, value:{}",SOLR_HOME_PROP_NAME,file.getCanonicalPath()); > } > else{ > logger.error("Resouce url '/solr' is not exists"); > } > } > else{ > logger.error("Can not locate resource url '/solr'"); > } > } catch (Exception e) { > logger.error(e.getMessage(), e); > } > > I wish this could help,best regards. > > Duan Jienan > 在 2013-4-16,上午4:33,Adeel Qureshi <adeelmahm...@gmail.com> 写道: > > > I am trying to embed solr war in an empty application to be able to use > > maven to deploy the generated war file (that includes solr war) to > tomcat. > > My pom file is simple > > > > <dependencies> > > <dependency> > > <groupId>org.apache.solr</groupId> > > <artifactId>solr</artifactId> > > <version>${solr.version}</version> > > <type>war</type> > > </dependency> > > </dependencies> > > > > this brings in the solr war but now i need to specify solr home to choose > > between a dev and prod directory as the solr home. So I have setup a env > > variable > > > > <Environment name="solr/home" override="true" type="java.lang.String" > > value="src/main/resources/solr-dev"/> > > > > but this leads to absolute path of > > > > INFO: Using JNDI solr.home: src/main/resources/solr-dev > > INFO: looking for solr.xml: > > C:\springsource\sts-2.8.1.RELEASE\src\main\resources\solr-dev\solr.xml > > > > notice that its uses the given path as absolute path and obviously doesnt > > ends up looking inside the application directory for these config > directory. > > > > Any help would be appreciate. > > Thanks > > Adeel > >