Solr + Eclipse + Jetty + custom jsp - eclipse

i wish to design a jsp page which uses solr to index and search for queries. I would like to know how to do that with eclipse, jetty, solr and jsp. Please advise. Thanks.

You don't want to expose Solr directly to the web. Think of it as a special kind of database that needs to be protected. So, it will be a standalone service and you ignore that it is running as part of a container (Jetty). With Solr 5, just released, this is now the official position.
So, then you design your client anyway you want in the other service and it should talk to Solr using SolrJ client.
Or you could use something like Spring Boot with Spring Data Solr, which does not use JSP, but does make it easier to build a web interface quickly and to talk to Solr using it's own client library.

Related

How to set up Apache Sling to use a relational DB

I am on Sling 11, which uses Jackrabbit Oak as content repository. I was wondering how to set up Sling to store the JCR repo on an RDBMS (DB2 to be specific).
I found this link on Jackrabbit Persistence, but looks like it does not apply to Oak and Oak documentation is mostly about MongoDB.
Also found an implementation of a Cassandra Resource Provider, although that seems designed to access specific paths mapped to Cassandra without using Oak.
Thanks,
Answering here but credit goes to Sling user's mailing list
Package the DB driver in an OSGi bundle
Download Sling's starter project
In boot.txt add a new running mode (in my case oak_db2)
[settings]
sling.run.mode.install.options=oak_tar,oak_mongo,oak_db2
Download Sling's datasource project and compile it.
In oak.txt configure the running mode (this will load the bundles for you in Felix):
[artifacts startLevel=15 runModes=oak_db2]
com.h2database/h2-mvstore/1.4.196
com.ibm.db2/jcc4/11.1
org.apache.sling/org.apache.sling.datasource/1.0.3-SNAPSHOT
And set-up the services that will manage persistence:
[configurations runModes=oak_db2]
org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreService
documentStoreType="RDB"
org.apache.sling.datasource.DataSourceFactory
url="jdbc:db2://10.1.2.3:50000/sling"
driverClassName="com.ibm.db2.jcc.DB2Driver"
username="****"
password="****"
datasource.name="oak"
Create a 'sling' named database.
run with java -jar -Dsling.run.modes=oak_db2 sling-starter.jar

Does com.sun.net.httpserver.HttpServer have scalability issues (for production environments)?

I want to use an embedded http server in my enterprise apps (and move away from standalone containers) and was expecting Tomcat to provide an implementation. I was assuming Sun, Jetty and Jersey's implementations cannot support enterprise load.
But looking at Tomcat, I see no way to run REST apps that use JAX-RS, only servlets. So my questions are:
Will use of com.sun.net.httpserver.HttpServer work in a production environment, or do I need another library?
Am I understanding correctly the boundary between JAX-RS embedded servers and servlet containers (maybe that will explain why Tomcat doesn't provide such a server)
Other notes:
I do not want to use Spring unless that's the only choice

Elastic search to be deployed as embedded or client/server mode

Which is the preferred mode of deployment for Elasticsearch, embedded mode (embedded in to the product/application) or client/server mode?
Apache Solr and most of the SQL, NOSQL databases are usually deployed in client/server mode. Where server runs as standalone, the client might be a driver library which will be used in the application.
In case of Elasticsearch, client and server binaries are the same. It would be difficult to package two separate Elasticsearch binaries, one for client to use in the application and another for the standalone server. I am planning to go with Rest API because I cannot package two set of Elasticsearch binaries in my product.
What is the general practice for Elasticsearch deployment? Keep Elasticsearch as standalone and use Rest API or embedded Elasticsearch within the application?
For production usage it is better to decouple your application from elasticsearch srever.
Lets say you want to upgrade to elastic 2.X that mean that you will need to re-compile your application - wouldnt it be overhead?
If you to run unit/data integration test you can use elasticsearch as embedded service to your testing needs

start solrserver deployed inside tomcat from within eclipse

I am working in windows 7 machine.I want to implement search using apache solr with hbase ta
bles as datasource. I have configured apache solr 4.3.1 in tomcat 7. I can able to deploy it successfully by manually starting tomcat server.
When i try to start solr server from within spring mvc web application it says solrserver started,but when i query the solr its giving the following without any errors:
page 0 of 0 containing UNKNOWN instances
As per my research on solr, it is mentioned embedded solrserver is unfit for production so i need to have httpsolrserver.
So somebody help me clear my head and give me some solution...
Thanks in advance..
For production, you would be better with hosting Solr as a seperate instance.
This would keep the responsibility separate, web application and search engine.
Indexing process are resource intensive and would the web application behavior as well.
This can be catered by Master Slave arch, providing best search performance.
External instance can be scaled at will and would not impact the web application.

Java Servlets + JDBC + Postgres: How does it all interact?

I'm having trouble wrapping my head around how to use servlets properly
I've set up a postgres database, and downloaded a JDBC driver for it.
What I want to have is my webpages post to the servlet, and the servlet get info from the database. I understand how to code everything (eg add library for driver, open connections, execute queries), but I think I'm lacking knowledge in how to set up the file structure.
I have the postgresql database running on pgAdmin. Do I also need to have a server running to make the servlets work as well? Can't I just make a web.xml file that maps to the servlets, and open the webpages to use the website? If I run the project through an IDE with a server running (glassfish) everything works. If I close the IDE and go to open the webpages on my browser again, I get 404's whenever I submit to a servlet.
Can someone give me a bit of guidance on the big picture of how everything is supposed to interact (with details on servers please). I've been searching the web and I havent found anything that explains the big picture very well.
Thanks
A Java web application is a set of files obeying a well-defined structure, and which can be packaged in a war file.
This web application is deployed into a server (also called container), which understands the file structure, listens to HTTP requests, and calls the appropriate servlet of the appropriate deployed web application when it receives one.
And of course, if you shut down the server, nothing listens to the HTTP requests anymore, so you won't get any response.
You could read the Java EE tutorial for more explanations.