Pages

Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Tuesday, 30 July 2013

MySQL Server (5.6), Installer, Connector or WorkBench Wont't Install (Windows 7 64-bit)

If you’re having trouble installing MySQL on Windows 7 (Any other platform will probably be the same) then I’d recommend the following process.  Don’t skip the first steps that describe the uninstall and removal of the previous install as this seems to clear up most issues.   

Caution: deleting the data files will delete any data previously entered into MySQL.

1.  Remove previous MySQL installs (and remnants)
a.  Stop the MySQL service ( Start | Control Panel | System & Security | Administrative Tools | Services)

b.  Remove All programs with MySQL in the name from Windows Add or Remove Programs (Start | Control Panel | Uninstall a Program)

c.  Delete the MySQL data directory (It is a hidden folder) from  (You will lose any stored data so you may wish to make a copy) :
       c:\Users\{Your Username}\AppData\Local\MySQL
       c:\Users\{Your Username}\AppData\LocalLow\MySQL
       c:\Users\{Your Username}\AppData\Roaming\MySQL


d.  Delete the MySQL folders from
        c:\program files\MySQL\
        c:\program files(x86)\MySQL\
        c:\program data\MySQL\                --(this is also a hidden folder)


————–
That’s it for the removal and clean up.  Now, we’ll begin the install.

2.a  Go to the MySQL Website and install the latest MySQL Installer.  It should come in the form of an MSI installer and comes for a 32 bit machine(x86) but will run on a 64-bit machine.

b.  Launch the installer which can be found in your Downloads folder.  Follow the Wizard through to the end and make sure you make note of the password you set for your new installation of the server in case you forget it 

TROUBLESHOOTING
What if it didn’t work?

1.  Check the service from the control panel.  Is it running?  If so, try to log into MySQL.  I’ve seen instances where an error was received, but it completed successfully.  If it’s not running, try to start it and please post the complete error message.

2.  Check the error log.  It’s in C:\Users\AppData\MySQL\MySQL Server 5.6\data   It has an .err extension and you should be able to open it with notepad.  Ignore any errors about the innodb plugin not loading.  It’s a symptom, not the problem.  Look for an error about missing data files or a mismatch in file sizes.

3.  1045 error?  It should indicate Password: No or Password:yes.  If “yes”, it’s not a port issue, not a firewall issue — it’s a password issue.  It’s usually caused by not deleting out the data files from an old install.  The password is kept in the data directory and it’s likely that the password you entered during the previous install doesn’t match what you’re entering now.  You can either re-install after deleting all the files or try to reset your root password.  (resetting root password: http://dev.mysql.com/doc/refman/5.1/en/resetting-permissions.html )

4.  Still stuck?   Email Oracle's Support Team

Thursday, 25 July 2013

XSLT Error For Solr - HTTP Status 500 - {msg=getTransformer fails in getContentType...

It is common to apply an XSLT stylesheet to an xml file to give it a cleaner look and Solr is no different coming with 4 pre-written xslt files for you to choose from.  

The error message XSLT Error For Solr - HTTP Status 500 - {msg=getTransformer fails in getContentType... is a common one and in most cases is easily fixed.  There are a few reasons that the error message appears:

  1. You have not specified a stylesheet to use
           e.g http://localhost:8080/solr/select?q=*&wt=xslt
    Make sure you have specified a stylesheet and that the stylesheet you specified actually exists
           e.g http://localhost:8080/solr/select?q=*&wt=xslt&tr=example.xsl
  2. A common mistake is to think that a stylesheet has a .xslt file extension - THEY DONT! The file extension is .xsl so be sure when you save your file and when you specify it in your query that you use .xsl
  3. There are errors in you XSL file - Be careful if you are working in an environment that does not do syntax checking (notepad) - It is easy to forget to close a tag or make a spelling mistake.

Stack Trace:
 {msg=getTransformer fails in getContentType,trace=java.lang.RuntimeException: getTransformer fails in getContentType at org.apache.solr.response.XSLTResponseWriter.getContentType(XSLTResponseWriter.java:74) at org.apache.solr.servlet.SolrDispatchFilter.writeResponse(SolrDispatchFilter.java:623) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:372) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:155) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: java.io.IOException: 'tr' request parameter is required to use the XSLTResponseWriter at org.apache.solr.response.XSLTResponseWriter.getTransformer(XSLTResponseWriter.java:1

Monday, 22 July 2013

C# Web Service To Query Solr (REST)

Preparation

You should have a Solr Server set-up on port 8080, configured to use Tika's extracting reuqest handler as well as having the highlighting functionality: 
http://amac4.blogspot.co.uk/2013/08/setting-up-highlighting-for-solr-4.html
http://amac4.blogspot.co.uk/2013/07/setting-up-tika-extracting-request.html
http://amac4.blogspot.co.uk/2013/07/setting-up-solr-with-apache-tomcat-be.html
Now that you have your Solr server up and running, now what? How do you query? How to you make use of the server? Well, you need to create a web service that will query Solr when the method is called from an ASP page. If you want your search service to be used on the web then you should most certainly consider creating a web service to provide you with a clean solution to the problem.
I am a novice when it comes to C# and this was my first involvement with the language, but due to the similarities it holds with Java, it wasn't difficult to understand the basics and get the web service up and running. It will return an xml file based on the input parameters and has the capability of highlighting too

You will require:

  • Microsoft Visual Studio with .NET framework of 3.5 or higher

Running The Web Service

  • Open Microsoft Visual Studio
  • Go to File→New Project and ensure that .NET Framework 3.5 is selected from the pull-down menu. Then select ASP.NET Web Service Application using Visual C#. Give your Web Service a relevant name and hit OK
  • Input the source code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Net;
    using System.Xml;
    using System.Web.UI;
     
    namespace Query
    {
        /// <summary>
        /// Queries the Solr Server based on input parameters and returns the XML response
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
        // [System.Web.Script.Services.ScriptService]
        public class Service1 : System.Web.Services.WebService
        {
     
            [WebMethod(Description = "Query Solr server and return XML response")]
            public XmlDocument QuerySolr(string keyword, string notKeyword, string exact, string rows, string filter,
                string fuzzy, string highlight)
            {
     
     
                /*  Default values should the user not enter anything */
                if (rows.Equals(""))
                    rows = "50";
     
                if (keyword.Equals("") && notKeyword.Equals("") && exact.Equals(""))
                    keyword = "*";
     
                if (filter.Equals(""))
                    filter = "id,title";
     
                if (!exact.Equals(""))
                    exact = " \"" + exact + "\"";
     
                if(!highlight.Equals(""))
                    highlight = "&hl=true&hl.fl=content";
     
                /* Should the user require that a certain word or words are not present */
                if (!notKeyword.Equals(""))
                {
     
                    /* Split each word */
                    string[] nwords = notKeyword.Split(null);
                    notKeyword = "";
     
                    /* Loops and adds the hyphen to each word */
                    for (int i = 0; i < nwords.Length; i++)
                    {
                        notKeyword = notKeyword + "-" + nwords[i] + " ";
                    }
                    notKeyword = notKeyword.Substring(0, notKeyword.Length - 1);
     
                }
     
                /* Should the user enable a fuzzy search a tilda must be added on to the end of each word */
                if (fuzzy.Equals("true") && !keyword.Equals(""))
                {
     
                    /* Splits the words by whitespace */
                    string[] words = keyword.Split(null);
                    keyword = "";
     
                    /* Loops and adds the tilda to each word */
                    for (int i = 0; i < words.Length; i++)
                    {
                        keyword = keyword + words[i] + "~ ";
                    }
                    keyword = keyword.Substring(0, keyword.Length - 1);
     
                }    
     
                /* Will throw an error should it have problems connecting to the Solr server */
                try
                {
     
                    /* Connecting to the Solr server and querying it with the search criteria that the user has provided*/
                    WebClient client = new WebClient();
                    string text = client.DownloadString(
                        "http://localhost:8080/solr/select?q=url:("+ keyword + " " + notKeyword + exact + ")^20%20text:("+ keyword
                        + " " + notKeyword + exact + ")&fl=" + filter + "&rows=" + rows + highlight);
     
                    /* The response is returned as a string so it must turn it into an XML document */
                    XmlDocument xml = new XmlDocument();
                    xml.LoadXml(text.Replace("%20", " ").Replace("\\", "/"));   //Changes to windows style filepath
     
                    return xml;
     
                }
                catch (Exception)
                {
                    /* Should an exception occur it returns an XML document with details of the problem */
                    XmlDocument xmle = new XmlDocument();
                    xmle.LoadXml("<Problem>Solr server cannot be reached</Problem>");
     
                    return xmle;
                }
            }
     
        }
    }
  • To test the Web Service hit the Green Triangle in the Top Menu
  • A Browser Window should open and display the Web Services that are currently being offered, click on the Query Solr Web Service
  • You should be able to enter the search criteria beneath and hit invoke to test your results