Why tomcat7 can't read my context.xml? - solr

I'm trying to integrate apache solr4.5 with tomcat7.0.
Here is my prob, I make a directory named "solr" under $CATALINA_BASE/webapps, and create an context.xml under the path, which the directory structure looks like.
$CATALINA_BASE/webapps/solr/META-INF/context.xml
The context.xml looks like as follow:
<?xml version="1.0" encoding="utf-8" ?>
<Context docBase="/solr/home/root/solr.war">
<Environment name="solr/home" type="java.lang.String" value="/solr/home/root" />
</Context>
I was expecting when I visit "localhost:8080/solr/", the solr webapp should work fine, but what I got is some errors like this:
HTTP Status 404 - /solr/
type Status report
message /solr/
description The requested resource (/solr/) is not available.
Apache Tomcat/7.0.26
But according to the apache tomcat7.0 document,
Individual Context elements may be explicitly defined:
In an individual file at /META-INF/context.xml inside the application files. Optionally (based on the Host's copyXML
attribute) this may be copied to
$CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to
application's base file name plus a ".xml" extension.
In individual files (with a ".xml" extension) in the $CATALINA_BASE/conf/[enginename]/[hostname]/ directory. The context
path and version will be derived from the base name of the file (the
file name less the .xml extension). This file will always take
precedence over any context.xml file packaged in the web
application's META-INF directory.
Inside a Host element in the main conf/server.xml.
So, please anyone give me some clues, thanks.

If you check the catalina log file located in /logs, you will probably see some errors from Solr, one of which will be:
SEVERE: Error filterStart
This is due to a change in the way that logging in general is now implemented within Solr as of version 4.3. Please refer to SolrLogging - Using the example logging setup in containers other than Jetty for the necessary steps to setup logging within Tomcat.
This should resolve your issue.

Try placing your context.xml (for all webapps) or solr.xml (solr only) file in Catalina/localhost folder instead.
For instance:
<Context docBase="webapps/solr.war" allowLinking="true" reloadable="true">
<Environment name="solr/home" type="java.lang.String" value="/opt/solr" override="true" />
</Context>
Troubleshooting:
check your logs, e.g.:
cd /var/log/tomcat? && tail -f *.log *.out *.txt

Related

How can i include a master changelog file inside another master changelog file in liquibase

I have a requirement where am pulling changelog files containing changesets as a maven dependency from other project module. I need to include the master changelog file of other project (which has reference to all the changesets in it)in current project from where i will execute the maven liquibase update / rollback or spring boot liuqibase setup. Is there a way to make it work?
I tried to do that like shown below
<?xml version="1.0" encoding="UTF-8" standalone="no"?><databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangeloghttp://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
<property name="blob" value="bytea" dbms="postgresql"/>
<property name="blob" value="blob" dbms="derby"/>
<preConditions>
<or>
<dbms type="derby"/>
<dbms type="postgresql"/>
</or>
</preConditions>
<include file="db/changelog/db.changelog-master.xml"/>
<include file="db/changelog/changesets/2019-06-001-modeler.changelog.xml"/>
</databaseChangeLog>
But i get error
Error setting up or running Liquibase: liquibase.exception.SetupException:
Error Reading Migration File: Found 2 files that match db/changelog/db.changelog-master.xml
I have same folder structure in all the projects.
This was a reported bug a while back and is now fixed with the later versions of Liquibase.
Please try to use the latest Liquibase version and see if the issue goes away.
Below is a reference for Liquibase releases.
https://github.com/liquibase/liquibase/releases
Liquibase can't understand which of your files with same name it should use.
If it's possible you should change path to your changelog.
So if your changelogs are both on path db/changelog/db.changelog-master.xml try to rename the paths at least. For example use db/changelog/module1/db.changelog-master.xml or db/changelog/db.changelog-module1-master.xml.

can data-import-handler use HikariCP?

I'm using solr4.5.1 in work.
The trouble is that a lot of getConnection occurred, when I execute data-import(full-import). So I thought if HikariCP could be used in data-import, but I haven't found similar problem.
Is it possible? If so please advice.
Solr 4.5.1 with Tomcat
data-config.xml
<dataSource driver="oracle.jdbc.driver.OracleDriver"
name="jdbc"
url="jdbc:oracle:thin:#address/mydb"
user="user" password="pass"/>
Heavily borrowed from David H Nebinger's post: Tomcat and HikariCP.
Install HikariCP
To make use of JNDI, you need to declare the JNDI datasource with all its' settings, password and cache options within the JNDI declaration. This has nothing to do with Solr at this point. This is a Tomcat mechanism. How you do this is described in this tutorial that also makes use of HikariCP.
First is to download the .zip or .tar.gz file from http://brettwooldridge.github.io/HikariCP/. This is actually a source release that you'll need to build yourself.
Second option is to download the built jar from a source like Maven Central, https://mvnrepository.com/artifact/com.zaxxer/HikariCP
Once you have the jar, copy to the Tomcat lib/ext directory. Note that Hikari CP does have a dependency on SLF4J, so you'll need to put that jar into lib/ext too.
Do not forget to place your datasource's JDBC driver in the lib/ext folder.
Configure the JNDI datasource
Location of your JNDI datasource <Resource /> definitions depends upon the scope for the connections. You can define them globally by specifying them in Tomcat's conf/server.xml and conf/context.xml, or you can scope them to individual applications by defining them in conf/Catalina/localhost/WebAppContext.xml (where WebAppContext is the web application context for the app, basically the directory name from Tomcat's webapps directory).
Create the file conf/Catalina/localhost/ROOT.xml if it doesn't already exist. Use the table from https://github.com/brettwooldridge/HikariCP#popular-datasource-class-names to find your data source class name, we'll need it when we define the element.
<Resource name="jdbc/SolrPool" auth="Container"
factory="com.zaxxer.hikari.HikariJNDIFactory"
type="javax.sql.DataSource"
minimumIdle="5"
maximumPoolSize="10"
connectionTimeout="300000"
dataSourceClassName="oracle.jdbc.pool.OracleDataSource"
dataSource.url="jdbc:oracle:thin:#address/mydb"
dataSource.implicitCachingEnabled="true"
dataSource.user="user"
dataSource.password="pass" />
Make use of the JNDI datasource in Solr
After you have followed this tutorial, you will need to use the declared JNDI datasource, this would be like described in the Solr Wiki:
<dataSource
jndiName="java:jdbc/SolrPool"
type="JdbcDataSource"
user="" password=""/> <!-- leave out user/password here -->

How to install solr-4.6.1 on ubuntu using tomcat7?

I want step by step instructions for installation of solr search engine using tomcat7 on ubuntu. I searched on google but I am not getting proper reference. Please help me to install it.
1- Download Solr dist: here. Unzip it anywhere.
2- find $EXTRACTEDDIR/solr/dist/solr-4.6.1.war and copy it to the location you want to configure solr.
3- configure the solr.xml as explained here. You will need to change your hostport to 8080(or what ever port tomcat7 is configured) and put it where you put solr-4.6.1.war
4- create /etc/tomcat7/Catalina/localhost/solr.xml and put
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="$SOLRBASE/solr-4.6.1.war" debug="0" privileged="true" allowLinking="true" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="$SOLRBASE" override="true" />
</Context>
replace SOLRBASE with the loacation you put solr.war and solr.xml.
5- copy $EXTRACTEDDIR/example/lib/ext/* . * to /usr/share/tomcat7/lib(for loging libs)
6- give permissions of the folder where you put solr.war and solr.xml to "tomcat7" user.
7- restart tomcat and you are done.
copy the solr files to ubuntu.
copy the file "solr.war" into "%tomcat_home%/webapps/" and add the solr service's context to the "%tomcat_home%/server.xml"
set the environment value "solr/home" int server.xml or web.xml
visit here for detail:https://wiki.apache.org/solr/SolrTomcat
it's a piece of cake, may you succeed!

Guestbook app deployment error cloud SQL

app engine log says
java.sql.SQLException: No suitable driver found for jdbc:mysql://173.194.111.127:3306/Guestbook
Help says make sure appengine-web.xml includes true which is the last line before in my file. I could use some help getting this connection to work.
A couple of things that you should check:
Please make sure that the MySQL JAR file is present in your WEB-INF\lib directory.
Once that is done, you can ensure that you enable the MySQL/ConnectorJ (https://developers.google.com/appengine/docs/java/cloud-sql/#enable_connector_j). As mentioned in the document, go to war\WEB-INF folder. You will find the appengine-web.xml file. Inside this file, enable the JAR file as given below:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
...
<use-google-connector-j>true</use-google-connector-j>
...
</appengine-web-app>
According to the documentation you should only be using the "jdbc:mysql" connection string for local development. For running on appengine you should use jdbc:google:mysql.

#500 Internal Server Error when trying to add PDF to Solr index with extraction

I am a first-time Solr user, using v3.5 with Tomcat 7 on a Windows 7 system. I went through the XML example in example-docs with no problems. However, I'm going to need to use extraction with HTML and PDF files, and when I try to Post a PDF file for indexing I'm getting the following:
SimplePostTool: version 1.4
SimplePostTool: POSTing files to http://localhost:8080/solr/update/extract?literal.id=doc2..
SimplePostTool: POSTing file test.pdf
SimplePostTool: FATAL: Solr returned an error #500 Internal Server Error
The command I used is:
java -Durl=http://localhost:8080/solr/update/extract?literal.id=doc2 -Dtype=application/pdf -jar post.jar test.pdf
My solr home directory is C:\solr, where I have done the following so far:
Copied the contents of the solr download package's example/solr folder
Copied the solr download package's contrib/extraction/lib folder to C:\solr\lib
Copied the solr download package's dist/apache-solr-cell-3.5.0.jar to C:\solr\dist\apache-solr-cell-3.5.0.jar
Modified the appropriate "lib" tags in C:\solr\conf\solrconfig.xml to <lib dir="lib" /> and <lib dir="dist/" regex="apache-solr-cell-\d.*\.jar" />
What else do I need to do to make this work for PDF and HTML files? I've read multiple tutorials and "Getting Started" guides but can't seem to understand what's wrong. I'm also a Tomcat beginner and as far as I can tell, none of this is showing up in Tomcat's logs ... so I'm pretty much stuck. Again, I'm not having any problem with the XML example, so Tomcat itself is running fine and recognizes solr (I can see the solr admin page). Any help is appreciated.

Resources