How to run multiple applications on single jetty instance - solr

As it will be apparent in some moments am more than a novice in jetty and tomcat.
The job in hand is to run multiple applications in single jetty server and to change the url of SOLR home page something like localhost:8989/solr/node1 and localhost:8989/solr/node2.
I have gone through the solutions at stackoverflow and also at http://wiki.apache.org/solr/SolrJetty but as I am handling jetty for the first time I am not aquaited with the jargons.
I will be very obliged if somebody can give me a stepwise process,including what and where to change.
Thanks a lot.

Check contexts directory under Jetty Home.
You should add a new xml file for each application.
Something like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">solr/node2</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/node2.war</Set>
<Set name="extractWAR">true</Set>
</Configure>
For more information check http://wiki.eclipse.org/Jetty/Howto/Deploy_Web_Applications ,
http://docs.codehaus.org/display/JETTY/ContextDeployer , http://www.enavigo.com/2008/08/29/deploying-a-web-application-to-jetty/

If you want to run jetty in embedded way then you just need to place an xml file for each context at the place where your war/web application is present.
In case you are not running jetty in embedded way then below link is useful.
How can I map multiple contexts to the same war file in Jetty?

Related

How to configure redirects Glassfish4 Maven Webapp

I am developing a WebApp using Glassfish 4. I have a REST backend, developed in JAVA using Jersey, and a AngularJS frontend. All this is contained in a MAVEN Jersey-Quickstart-Webapp.
Now, the problem I have is that when people query the URL for my app:
http://localhost:8080/MyApp/
It works fine, and sends the appropriate index.html to the user. However, if the user types a URL that 'should' be handled by my Apps routing, say like:
http://localhost:8080/MyApp/search
it gives a 404 error. However, this URL can be reached from within in the app if you start from the /MyApp/ route, because the index.html that is served with all the angularJS stuff is able to understand and control the routing.
Essentially the problem I face is that I need to set up the appropriate redirects for all the necessary places that should return the index.html.
So, when I hit any of the following URLs it should send the user the index.html, and let AngularJs figure out the routing
Eg.
http://localhost:8080/MyApp/search ----> index.html
http://localhost:8080/MyApp/results ----> index.html
http://localhost:8080/MyApp/browse ----> index.html
Unfortunately, I am probably being really thick here, but I don't know how to configure the server/webapp to do this. How do I go about doing this? I assume it is fairly obvious/trivial, but I'm pretty new to all this stuff, so go easy on me!
EDIT 1: I've had some good help about using a mod-rewrite or the UrlRewriteFilter but neither of these seems to work for Glassfish4 as far as I can see. Is there an equivalent out there for these that somebody might know of?
Log into glassfish In the Admin Console, expand the Configurations
node. Expand the server-config node. Ignore this step if you are
running a developer domain (a domain that does not have clustering
capability). Expand HTTP Service. Expand Virtual Servers. Click
server. On the Edit Virtual Server page, click the Add Property
button. In the Name column, type redirect_1.
If you are using Application Server 9.0, type
from=//myproduct1
url-prefix=/mywarname/mypages/products/myproduct1.jsp in the Value
column.
Note - The value of the you provide here needs to
match the value of the context root specified in the web.xml or
application.xml file.
As #Tunaki says, you need use an apache and use the mod_rewrite.
also, you can use UrlRewriteFilter thats allows you to rewrite URLs before they get to your code.
For that, you need add to your maven file the dependency:
<dependency>
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
<version>4.0.3</version>
</dependency>
And add in your WEB-INF/web.xml file:
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
Also, you have a big number of parameters specified in the documentation:
http://cdn.rawgit.com/paultuckey/urlrewritefilter/master/src/doc/manual/4.0/index.html#filterparams
http://localhost:8080/MyApp/search ----> search.html
http://localhost:8080/MyApp/results ----> results.html
http://localhost:8080/MyApp/browse ----> browse.html

vCloud: Create and configure a vm in vApp

I am trying to deploy Virtual Machines from a template into a vApp using the vCloud rest API. I feel that there should be a way to configure a vm as I am spawning it (Since the UI seems to do that) but haven't found a way.
I've been focusing my efforts on recomposing a vApp to add a vm to it. The below example will add a vm but I haven't figured out to configure the vm until after it has been created. Specifically I want to set the VM Name, host name, and IP settings of the vm.
<?xml version="1.0" encoding="UTF-8"?>
<RecomposeVAppParams
xmlns="http://www.vmware.com/vcloud/v1.5"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
<SourcedItem sourceDelete="false">
<Source href="templateUri" />
</SourcedItem>
<AllEULAsAccepted>true</AllEULAsAccepted>
</RecomposeVAppParams>
After the vm is created I can reconfigure it but neither the network settings or host name actually change. The vCloud Director UI tells me they have changed but looking on the guest os shows that the settings have not changed.
Change host name example (doesn't work):
<vcloud:GuestCustomizationSection
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
xmlns:vcloud="http://www.vmware.com/vcloud/v1.5"
href="vmUri/guestCustomizationSection/"
ovf:required="false"
type="application/vnd.vmware.vcloud.guestCustomizationSection+xml">
<ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
<vcloud:ComputerName>newName</vcloud:ComputerName>
</vcloud:GuestCustomizationSection>
Has anyone been able to configure a VM as you deploy it. Otherwise does anyone know how to effectively configure settings of a VM after it has been deployed. Working XML examples would be amazing but I would still appreciate help in other forms.
The closest I have been able to come to this is to deploy a vApp from a catalog somewhat customizing it in the process. This is not exactly what you asked for, but I hope it helps.
<?xml version="1.0" encoding="UTF-8"?>
<InstantiateVAppTemplateParams
xmlns="http://www.vmware.com/vcloud/v1.5"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
name="<MyVappName"
deploy="false"
powerOn="false">
<Description>vApp I deployed through REST API...</Description>
<InstantiationParams>
<NetworkConfigSection>
<ovf:Info>Configuration parameters for logical networks</ovf:Info>
<NetworkConfig networkName="App-Network-1">
<Configuration>
<ParentNetwork href="https://vcd-url/api/network/331a8ee3-33fd-4e4a-878e-1a6dce772fea" />
<FenceMode>bridged</FenceMode>
</Configuration>
</NetworkConfig>
</NetworkConfigSection>
</InstantiationParams>
<Source
href="https://vcd-url/api/vAppTemplate/vappTemplate-d11de298-3041-2ae2-5e81-3ac2b4255423" />
</InstantiateVAppTemplateParams>
Just use the SDK for this task. Download the example and the library. Add the library to proj and call function from there. The SDK has already and Utility library that handle the http communication with the vcloud creating the requests and serve the answers using serialization.
If you really want to do the request by yourself you just run the example in SDK put Fiddler to spy the communication and get the exact request and reproduce it.
I know because first time I have started making http request using the documentation and get in trouble.

XPages and Apache CXF: what's the best place for WSDL files?

I am currently testing Apache CXF (2.7.11). Purpose is to build a Web Service client. I am roughly following Martin Vereecken's blog post (http://www.bizzybee.be/2013/01/23/creating-a-java-webservice-client-in-domino-using-apache-cxf/#more-451). I have a WSDL file and I created sample code with the wsdl2java tool.
My first thought was to store the wsdl file in the NSF (e.g. WebContent\WEB-INF\resources\wsdl). However, the code generated does not seem to find the WSDL file. Code looks something like this (class name Session comes form the WSDL):
Session.java:
URL url = Session.class.getResource("WEB-INF/wsdl/twinfield/session.wsdl");
if (url == null) {
url = Session.class.getClassLoader().getResource("WEB-INF/wsdl/twinfield/session.wsdl");
}
I tried both WEB-INF and /WEB-INF but neither seem to work.
If I put the WSDL file on the web (e.g. domino/html/wsdl folder) the url above works, but the code breaks later (it seems that it uses java.io.File trying to load the WSDL).
Local reference (e.g. C:\temp\wsdl) could work but does not really sound like a robust option.
The final java code will be in WebContent\WEB-INF\src, not in Code\Java.
So, what is the "best practice" for storing and referencing WSDL files in Domino environment?
UPDATE
I went with #stwissel's proposal and noticed that the wsdl2java tool can actually create the whole jar for you. Just specify option -clientJar and the resulting JAR file will contain all class files + the wsdl file.
When you generate the Java classes from the WSDL, you should pack them into a JAR file. Put the WSDL into the Jar file, so it never gets lost. This blog article and the comments explain it.
A potential issue could be the access rights (Java execution permissions) when you keep that jar inside the NSF.
The blog entry contains the sample code, so check it out!

Multiple Jira instances on a single Tomcat 6 server?

I have a feeling this is a stupid question but I can't find the answer anywhere...
I need to deploy 2 Jira instances on asingle Tomcat server, I can't figure out how to pass in the jira.home property
The documentation says I need to:-
Add a web context property called 'jira.home' — this property is set in different files depending on your application server. For example, for Tomcat (and therefore for JIRA Standalone), you will need to configure the server.xml file. For other application servers you may need to configure the web.xml file, or set 'Context parameter' options on the deployment UI of the application server, etc. Note that If you have specified a JIRA home in jira-application.properties (ie. the recommended method), it will override your web context property.
I was hoping something like this would work.
<Context jira.home="d:/jira/data" path="" docBase="D:\Jira\atlassian-jira-enterprise-4.1\dist-tomcat\tomcat-6\atlassian-jira-4.1.war" debug="0">
<Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"
username="sa"
password="*****"
driverClassName="net.sourceforge.jtds.jdbc.Driver"
url="jdbc:jtds:sqlserver://*****:1433/jira41_519;user=****;password=****"
/>
<Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
<Manager pathname=""/>
</Context>
Any ideas??
ah ha!
This is what I was looking for!
<Parameter name="jira.home" value="d:/jira/dataResearch" override="false"/>

dotnetnuke up and running error

I developed a DotNetNuke application and hosted it on a web server. When I browse the site, I am getting the following error:
Server Error in '/' Application.
Runtime Error Description: An
application error occurred on the
server. The current custom error
settings for this application prevent
the details of the application error
from being viewed remotely (for
security reasons). It could, however,
be viewed by browsers running on the
local server machine.
Details: To enable the details of this
specific error message to be viewable
on remote machines, please create a
<customErrors> tag within a
"web.config" configuration file
located in the root directory of the
current web application. This
<customErrors> tag should then have
its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web> </configuration>
Notes: The current error page you are
seeing can be replaced by a custom
error page by modifying the
"defaultRedirect" attribute of the
application's <customErrors>
configuration tag to point to a custom
error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly"
defaultRedirect="mycustompage.htm"/>
</system.web> </configuration>
Can any one tell me how to resolve the problem...
The main problem here is that you aren't getting any detail about what the error. Any success achieved while troubleshooting this without exposing some more detail (or knowledge of your setup) is going to be pretty close to pure luck.
I would suggest following the instructions that this default error message is giving you and editing the web. config file. The file is named "web.config" and it lives in the root of the website.
Open the file and search for "RemoteOnly", you should see something that says customErrors mode="RemoteOnly". Change the "RemoteOnly" to "Off" and save the file. The next time you browse to the site you should see a more detailed error message. Please share that with us here in the form of an update to your current post or as a new question (which I recommend, as it technically will be a different question).
Also, I recommend making a backup copy of the web.config file first before making any changes.
You need to check if your ASP.NET is functional. Since you didnt post any details on your web server, i would recommend you check if you have .NET 2.0 installed and your web server is configured to use it.
You can run aspnet_regiis -i in the c:\WINDOWS\Microsoft.NET\Framework\v2.x.x.x. directory to re-register the aspnet modules.
You might also want to check if your virtual directories have the execute permission enabled.
When you say you "developed a DotNetNuke application" I need more information.
Did you develop a DotNetNuke MODULE?
If so, did you install it on a DotNetNuke site that was working before, but isn't now?

Resources