Hmmm, after being stuck on this for hours, I find the answer myself 15minutes after asking for help... as usual. :)
For anyone interested, and no doubt this will not be a revelation for some, I need the servlet API in my app for it to work, despite being command line. So adding this to the maven POM fixed everything: <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency> Perhaps this dependency could be listed on the wiki? Alongside the sample code for using embedded solr? http://wiki.apache.org/solr/Solrj Logback is passing along all of my logging but I suspect I'd have to add some Solr logging config before it would tell me this itself. I only stumbled on it by accident: http://osdir.com/ml/solr-user.lucene.apache.org/2009-11/msg00831.html On 6 April 2011 14:48, Greg Pendlebury <greg.pendleb...@gmail.com> wrote: > Hi All, > > I'm hoping this is a reasonably trivial issue, but it's frustrating me to > no end. I'm putting together a tiny command line app to write data into an > index. It has no web based Solr running against it; the index will be moved > at a later time to have a proper server instance start for responding to > queries. My problem however is I seem to have stalled on instantiating the > embedded server: > > private SolrServer startSolr(String home) throws Exception { > try { > System.setProperty("solr.solr.home", home); > CoreContainer.Initializer initializer = new > CoreContainer.Initializer(); > solrCore = initializer.initialize(); > return new EmbeddedSolrServer(solrCore, ""); > } catch(Exception ex) { > log.error("\n=======\nFailed to start Solr server\n"); > throw ex; > } > } > > The constructor for the embedded server just never comes back. I've seen > three or four different ways of starting the server with varying levels of > complexity, and they all APPEAR to work, but still do not return. STDOUT > show the output I have largely come to expect from watching Solr start > 'correctly': > > ======= > Starting Solr: > > JNDI not configured for solr (NoInitialContextEx) > using system property solr.solr.home: C:\test\harvester\solr > looking for solr.xml: C:\test\harvester\solr\solr.xml > Solr home set to 'C:\test\harvester\solr\' > Loaded SolrConfig: solrconfig.xml > Opening new SolrCore at C:\test\harvester\solr\, > dataDir=C:\tf2\geonames\harvester\solr\.\data\ > Reading Solr Schema > Schema name=test > created string: org.apache.solr.schema.StrField > created date: org.apache.solr.schema.TrieDateField > created sint: org.apache.solr.schema.SortableIntField > created sfloat: org.apache.solr.schema.SortableFloatField > created null: org.apache.solr.analysis.WhitespaceTokenizerFactory > created null: org.apache.solr.analysis.LowerCaseFilterFactory > created null: org.apache.solr.analysis.WhitespaceTokenizerFactory > created null: org.apache.solr.analysis.LowerCaseFilterFactory > created text: org.apache.solr.schema.TextField > default search field is basic_name > query parser default operator is AND > unique key field: id > No JMX servers found, not exposing Solr information with JMX. > created /update: solr.XmlUpdateRequestHandler > adding lazy requestHandler: solr.CSVRequestHandler > created /update/csv: solr.CSVRequestHandler > Opening Searcher@11b86c7 main > AutoCommit: disabled > registering core: > [] Registered new searcher Searcher@11b86c7 main > Terminate batch job (Y/N)? y > > > At this stage I'm grasping at straws. It appears as though the embedded > instance is behaving like a proper server, waiting for a request or > something. I've scrubbed the solrconfig.xml (from from the Solr example > download) file back to remove most entries, but perhaps I'm using the > incorrect handlers/listeners for an embedded server? > > I'm a tad confused though, because every other time I've done this > (admittedly in a servlet, not a command line app) the constructor simply > returns straight away and execution of my app code continues. > > Any advice or suggestions would be greatly appreciated. > > Ta, > Greg > > >