Loading stopwords from Postgresql to Solr6 - postgresql

I am new to solr. I want to load synonyms or stopwords from DB instead of txt file to solr at analyzing phase. How can I acheive it in solr 6.
I tried porting Solr-JDBC(https://github.com/shopping24/solr-jdbc), and I configured web.xml with code below:
<resource-ref>
<description>my datasource</description>
<res-ref-name>jdbc/dsTest</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
and solr-jetty-context.xml with:
<New id="dsTest" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/dsTest</Arg>
<Arg>
<New class="org.postgresql.ds.PGSimpleDataSource">
<Set name="User">username</Set>
<Set name="Password">password</Set>
<Set name="DatabaseName">DBName</Set>
<Set name="ServerName">localhost</Set>
<Set name="PortNumber">5432</Set>
</New>
</Arg>
</New>
But I encountered the following error when I was trying to start SolrCloud.
Error: did not see solr at http://localhost:8983/solr come online
within 30
Also, the needed libraries are added to the correct folder.

Honestly I think this solution is a mess, I strongly suggest to export your synonyms and stopwords in a text file and save them overwriting your old configuration files.
After that, maybe you already know, you have to reload the core/collection configuration and, depending from your analyzer chain, reindex all the documents involved.
On the other hand, if you really want follow this way, looking at your question I can give you the following suggestion, you have to double check:
jdbc driver (check you copied postgresql-xxxxx.jdbc.jar to $JETTY_HOME/lib/ext)
network (check that postgres instance is up and listening on localhost:5432)
account (check username and password are correct)
db name (check the such db is present and the user has the permission)

Yes, it is fixed, I have downloaded jetty-jndi.jar but forgot to add it in lib folder.
So do not forget add postgresql-xxxx, jetty-jndi and jetty-plus to server/lib

Related

Increasing Jetty ThreadPool size in Karaf

Trying to increase the number of threads in embedded jetty running in karaf .Im changing the jetty.xml with the following properties as described in the POST .
<Configure class="org.eclipse.jetty.server.Server">
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">1000</Set>
</New>
</Arg>
</Call>
</Configure>
And also having org.ops4j.pax.web.cfg file in karaf ,with below properties :
org.ops4j.pax.web.config.file=${karaf.home}/jetty.xml
so to refer the external configurations (Jetty). But Im not able to increase/decrease the default thread size of the server . So What am I missing ?
With the latest Pax-Web 4.2.0 it's possible to configure those settings via configuration admin. The following three new settings can be used:
org.ops4j.pax.web.server.maxThreads
org.ops4j.pax.web.server.minThreads
org.ops4j.pax.web.server.idleTimeout

EF5 Code First Migration problems publishing to IIS

I've created a MVC 4 project which uses EF5 Code First with migrations.
Because I was new to this topic I used the following article.
Now that the development is finished I want to publish to IIS (I use FTP or Web deployment package). So before publishing I changed the connectionstring to the right db server.
But after publishing the site I get an exception when accessing pages which make use of the DB. The exceptions refers to the fact that he can't connect to the database.
Because of these problems I decided to try it out locally on another DB server than the default one "(LocalDB)\v11.0". BTW: "(LocalDB)\v11.0" works like a charm...
While debugging I got a better look at the error.
Here is an image of the error:
What I've already tried:
Generate a sql script by executing "Update-Database -Script
-SourceMigration:$InitialDatabase" in the Package manager console. After I ran this script on the dbserver to create the db. Tables were
created but the error was still there.
I changed my connectionstring to all kinds of combination with no
results
I already used a custom user for the app pool in ISS and gave this user full rights to the DB server and the db.
Here is the most important part of my web.config:
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=LOCALHOST\MSSQLSERVER;Initial Catalog=ProjectX;Integrated Security=TRUE;MultipleActiveResultSets=True" />
</connectionStrings>
And
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Data Source=LOCALHOST\MSSQLSERVER; Integrated Security=True; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
My DBCcontext class constructor looks like
public DBContext(): base("DefaultConnection")
{
}
I guess I am missing something, this is the first time I use EF Code First with migrations.
This problem is really driving me crazy. I am out of ideas.
Just found out that the problem was caused by the connectionstring.
The string was incorrect, seems like you if you have a default SQL Server you just need to use
"Data Source=LOCALHOST".
I guess because of all the problems I had that day with the deployment i overlooked the easy parts. Yust make sure you the following things are true when you have problems like I did:
Your connectionstring has the same name as your DBContext. Another sollution could be to do like i did and add the connectionstring name to the base:
public DBContext(): base("DefaultConnection")
{
}
If you also have the defaultconnectionfactory set. Make sure to also update the Data Source there. This was one of the problems I struggled with. I didn't check the bottom of my web.config ...
If the problem still persists you can use EF profiler to have a look at the connectionstring when your app of site is accessing the DB.

How dow I setup Archiva standalone to use Postgres?

Ok, I'm struggling to get Archiva 1.4 in standalone mode to use an existing Postgres db. Can anyone help me configure it?
Working with Olivier, this was my final, working db config:
<New id="users" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>jdbc/users</Arg>
<Arg>
<New class="org.apache.tomcat.jdbc.pool.DataSource">
<Set name="driverClassName">org.postgresql.Driver</Set>
<Set name="url">jdbc:postgresql://<server>/Archiva</Set>
<Set name="name">ArchivaApp</Set>
<Set name="username">...</Set>
<Set name="password">...</Set>
<!-- depends on your concurrent users numbers -->
<Set name="maxWait">10000</Set>
<Set name="removeAbandonedTimeout">10000</Set>
<Set name="maxActive">30</Set>
<Set name="initialSize">15</Set>
<Set name="removeAbandoned">true</Set>
<Set name="logAbandoned">true</Set>
<Set name="testOnBorrow">true</Set>
<!-- very rigourous sql query validation -->
<Set name="validationQuery">select 1</Set>
</New>
</Arg>
</New>
It was important to set the testOnBorrow parameter; some of the others don't matter.
Depends if you are using standalone or in a servlet container
1)Standalone have a look here
http://archiva.apache.org/docs/1.4-M4-SNAPSHOT/adminguide/standalone.html
replace com.mysql.jdbc.Driver with
your jdbc driver
and replace url jdbc:mysql://localhost/archiva
put your jdbc driver jar to lib directory
2) servlet container (it depends :-) )
for Apache Tomcat see
http://archiva.apache.org/docs/1.4-M4-SNAPSHOT/adminguide/webapp.html
put your jdbc driver jar to lib directory
change values
driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
url="jdbc:derby:/path/to/database/users;create=true"
I have updated documentation here database section

MVC2 - Custom MembershipProvider Implementation Isn't Found

Despite finding several references to this problem on the web, I have been unable to find a solution.
I have a custom MembershipProvider called ConfigMembershipProvider in the Config.Web.Areas.Accounts.Providers namespace. The assembly name is Config.Web.
My web.config looks like this:
<membership defaultProvider="ConfigMembershipProvider">
<providers>
<clear/>
<add name="ConfigMembershipProvider"
type="Config.Web.Areas.Accounts.Providers.ConfigMembershipProvider,
Config.Web"
applicationName="Configurator"
connectionStringName="Test_User_and_RolesConnectionString"/>
</providers>
</membership>
The error message I am getting is Parser Error Message: Default Membership Provider could not be found.
I cannot figure out why it cannot find the default membership provider... any assistance would be greatly appreciated.
Scott.
Looks okay .
Not sure but looking at syntax -
try removing *Config.Web"*
type="Config.Web.Areas.Accounts.Providers.ConfigMembershipProvider,
Config.Web"
Is this the root web.config? Could a web.config in a lower directory be clearing the membership provider?
Not sure what happened, but I created another Membership Provider & literally copy/pasted the contents from each method in the original to the new one, changed web.config file to reflect the new name and everything works.
Crazy, but true.

GWT eclispe embedded jetty and DBCP connection pooling

I am trying to setup the embedded Jetty that comes with the GWT (2.0.3) Eclipse plugin to use a JNDI connection pool that works perfectly under Tomcat, without success. Now since i have read some things regarding the issue, i have managed to do the following:
Included the Jetty naming initial context factory to the classpath by launching the jvm with the following parameter: -Djava.naming.factory.initial=org.mortbay.naming.InitialContextFactory.
I have also created a jetty-web.xml that looks like this:
<New id="mysqltest" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>java:comp/env/jdbc/mysqldb</Arg>
<Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
<Set name="Url">jdbc:mysql://192.168.0.5:3306/mydb</Set>
<Set name="User">testuser</Set>
<Set name="Password">testpass</Set>
</New>
</Arg>
</New>
<New id="db2test" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>java:comp/env/jdbc/db2db</Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">com.ibm.db2.jcc.DB2Driver</Set>
<Set name="url">jdbc:db2://192.168.0.6:50000/mydb2</Set>
<Set name="username">testuser</Set>
<Set name="password">testpass</Set>
</New>
</New>
</Configure>
and have included the neccessary files in my build path. As you can see, there are two JNDI resources declared there, a handle to a MySQL database using MysqlConnectionPoolDataSource (i saw that on a blog post) that works fine under my environment and used that to ensure that jetty was parsing the jetty-web.xml correctly and a second one that attempts to use DBCP to connect to a DB2 database. The problem is that whenever i try to use the DBCP resource i get the following error when Jetty starts up:
[WARN] Config error at <New id="db2test" class="org.mortbay.jetty.plus.naming.Resource"><Arg>java:comp/env/jdbc/db2db</Arg>...
[WARN] Failed startup of context com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload#7a74db2c{/,/home/..}
java.lang.IllegalStateException: No Constructor <New id="db2test" class="org.mortbay.jetty.plus.naming.Resource"><Arg>java:comp/env/jdbc/db2db</Arg>...
As i said, these work fine under Tomcat and the problem is not specific to DB2, i cannot get a MySQL Datasource using DBCP as well. Looking at the error message, it seems that the DBCP files are not in the classpath but i have no clue on how to put them there (they are of course in the projects build path but that seems irrelevant to Jetty). I probably have to add another parameter to Djava.naming.factory.initial but i am not sure whats the correct one for DBCP to work.
Cheers
I think you are missing an 'Arg' tag.
Try:
<New id="db2test" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>java:comp/env/jdbc/db2db</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">com.ibm.db2.jcc.DB2Driver</Set>
<Set name="url">jdbc:db2://192.168.0.6:50000/mydb2</Set>
<Set name="username">testuser</Set>
<Set name="password">testpass</Set>
</New>
</Arg>
</New>