Increasing Jetty ThreadPool size in Karaf - rest

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

Related

Loading stopwords from Postgresql to Solr6

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

Set system properties in standalone-full.xml in wildfly 8.2

I have added system-properties tag in standalone-full.xml, but its not working in standalone mode. However, if I add the same tag in domain.xml it's working for domain mode.
<?xml version='1.0' encoding='UTF-8'?>
<server xmlns="urn:jboss:domain:2.2">
<extensions>
....
</extensions>
<system-properties>
<property name="java.util.Arrays.useLegacyMergeSort" value="true"/>
</system-properties>
</server>
According to this article on jBoss General configuration concepts
System property values can be set in a number of places in domain.xml, host.xml and standalone.xml.
Then what about standalone-full.xml?
I don't want to set it through command line and not even in java code.
In standalone it's probably too late to set it in the configuration files. You'll need to add it to the standalone.conf or standalone.conf.bat in the JAVA_OPTS environment variable. A global property like that needs to be set before anything else attempts to use java.util.Arrays.
If you have started the Wildfly server with standalone-full.xml instead of standalone.xml(the default) than this should be reflected in the start of the server:
standalone.sh -b <hostIP> -c standalone-full.xml -Dorg...
Then this will have effect on first start.
If you change something in this config file, you will need to reload Wildfly(configuration) from jboss cli:
[standalone#localhost:9990 /] :reload
For Wildfly 10 it's working nontheless. I was able to read the property for an instance started with the standalone-full.xml containing some properties.
The manual must be outdated then I guess? Because even Wildfly itself inserts a new property in the standalone-full.xml when using the Wildfly admin webinterface: http://localhost:9990 > Configuration > System Properties (Wildfly will add the property of course to the xml config which was used to start the instance). That's enough proof for me.

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

jaas authentication using jetty and gwt

I am trying to use JAAS to authenticate my users. My project is in GWT v2, which runs jetty. I use eclipse for development.
From http://code.google.com/p/google-web-toolkit/issues/detail?id=4462 I found out that jetty doesn't like any realm definitions in web.xml, so I moved them to jetty-web.xml.
I keep getting ClassNotFound exceptions so I followed the advice here: communitymapbuilder.org/display/JETTY/Problems+with+JAAS+in+Jetty+6.0.0
However, I am still getting ClassNotFoundExceptionsHere in my jetty-web.xml file. How do I configure jetty to work jaas in GWT projects?
My jetty-web.xml file:
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<Set name="serverClasses">
<Array type="java.lang.String">
<Item>-org.mortbay.jetty.plus.jaas.</Item>
<Item>org.mortbay.jetty</Item>
<Item>org.slf4j.</Item>
</Array>
</Set>
<Get name="securityHandler">
<Set name="userRealm">
<New class="org.mortbay.jetty.plus.jaas.JAASUserRealm">
<Set name="name">xyzrealm</Set>
<Set name="LoginModuleName">xyz</Set>
<Set name="config"><SystemProperty name="jetty.home" default="."/>/WEB-INF/classes/jdbcRealm.properties</Set>
</New>
</Set>
<Set name="authenticator">
<New class="org.mortbay.jetty.security.FormAuthenticator">
<Set name="loginPage">/login.jsp</Set>
<Set name="errorPage">/error.jsp</Set>
</New>
</Set>
</Get>
Error I am receiving:
[WARN] Failed startup of context com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload#1fcef4f7{/,/home/dev/workspace/project/war}
java.lang.ClassNotFoundException: org.mortbay.jetty.plus.jaas.JAASUserRealm
at java.lang.ClassLoader.findClass(ClassLoader.java:359)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:352)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)
at org.mortbay.util.Loader.loadClass(Loader.java:91)
at org.mortbay.xml.XmlConfiguration.nodeClass(XmlConfiguration.java:216)
at org.mortbay.xml.XmlConfiguration.newObj(XmlConfiguration.java:564)
at org.mortbay.xml.XmlConfiguration.itemValue(XmlConfiguration.java:907)
at org.mortbay.xml.XmlConfiguration.value(XmlConfiguration.java:829)
at org.mortbay.xml.XmlConfiguration.set(XmlConfiguration.java:278)
at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:240)
at org.mortbay.xml.XmlConfiguration.get(XmlConfiguration.java:460)
at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:246)
at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:182)
at org.mortbay.jetty.webapp.JettyWebXmlConfiguration.configureWebApp(JettyWebXmlConfiguration.java:109)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1217)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448)
at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:447)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.handler.RequestLogHandler.doStart(RequestLogHandler.java:115)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:222)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39)
at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:543)
at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:421)
at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1035)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:783)
at com.google.gwt.dev.DevMode.main(DevMode.java:275)
Apparently you need to include the optional 'plus' jar from the jetty's /lib distribution for jaas to work. That made the classnotfound exception go away.

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>