分类目录归档:开发

hosting-multiple-domains-with-jboss

转自:http://www.fusioncube.net/index.php/hosting-multiple-domains-with-jboss

After spending days trying to get it working, I felt kind of stupid after I learned how to have multiple domain names point to different web applications in my Jboss instances. I had read all of the documentation from the JBoss site and even some side blogs where people had set it up. However, as usual, the people writing these documents did so as people who have already done it and leave out key pieces of information, or fail to make subtle configuration changes clear.

Here we go, from scratch. I’ll give a simple sample scenario to make things easier.

You have one JBoss server running on your machine. You have two applications running under JBoss:

  1. widgets.war
  2. thingamabobs.war

You also have registered two domain names:

  1. widgets.biz
  2. thingamabobs.biz

You also have set up your DNS to have both domain names point to your server.

How do you get widgets.biz to point to widgets.war and thingamabobs.biz to point to thingamabobs.war? Let’s assume that you have widgets.war mapped as the root application and thingsmabobs.war mapped as thingamabobs.

widgets.war jboss-web.xml
———————————–

<jboss-web> <context-root>/</context-root> </jboss-web>

thingamabobs.war jboss-web.xml
———————————–

<jboss-web> <context-root>/thingamabobs</context-root> </jboss-web>

What you need to do is create a seperate Host configuration for the thingamabobs.war application in Tomcat’s server.xml file which is located at \jboss\server\default\deploy\jbossweb-tomcat55.sar\server.xml.

Open that file and you’ll see a Host configuration already for localhost. This is the default host meaning that all traffic directed via your web server port – which is 8080 by default, but I have mine set at 80 – will be directed to your root application. In our scenario, this is the widgets.war application.

Now let’s create a new Host designation that will direct requests for www.thingamabobs.biz to the thingamabobs.warapplication instead. Here’s what it would look like.

<Host name="thingies" autoDeploy="false" deployOnStartup="false" deployXML="false"> <Alias>www.thingamabobs.biz</Alias> <Valve className="org.apache.catalina.valves.AccessLogValve" prefix="things" suffix=".log" pattern="common" directory="${jboss.server.home.dir}/log"/> <DefaultContext cookies="true" crossContext="true" override="true"/> </Host>

The only things different about this Host entry is the name attribute and an additional Alias property. You can set theNAME attribute to whatever you like. The ALIAS property is the domain name that you want assigned to this Host designation. You can have multiple aliases per host. For example, if you want thigamabobs.widgets.biz to be redirected you could add that Alias in there as well (as long as you also set your DNS record for that domain as well).

We’re almost home and this is where the documentation wasn’t clear enough for me. The last step is to modify thejboss-web.xml file for thingamabobs.war. We’ve set up a brand new Host designation, so now thingamabobs.war can be set up as another root application, except now it sits in its own Host Space – called thingies – rather than in the one set up for localhost.

Here’s what the file should look like now.

<jboss-web> <context-root>/</context-root> <virtual-host>thingies</virtual-host> </jboss-web>

You can see now that the new Host name we set up in Tomcat’s server.xml file – “thingies” – is the virtual host for thethingamabobs.war application, and it is now the root for that Host.

Now just restart your JBoss instance, and if your DNS changes have been made live, going to www.thingamabobs.bizwill be redirected to the thingamabobs.war application, while www.widgets.biz will still be directed to the widgets.warapplication.

启动eclipse时报 no java virtual machine was found after searching the following location

这是一个JDK没有配置好的问题。解决办法如下:
运行CMD。

在里面输入java -version看有没有版本的提示?有的话说明你的JDK是对的,那么就是Eclipse的问题了。没有参考其他方法。

1)如果没有的话:

依次点击:“我的电脑”-(右键)“属性”-“高级”-“环境变量”,弹出Windows的“环境变量”配置卡。
在“系统变量”栏下执行三项操作:
①新建“Java_Home”,值:JDK所在的绝对路径(例如 D:\Program Files\Java\jdk1.5.0_04\)。
②新建“Classpath”(如果已有,则直接编辑),值: .;%Java_Home%\lib (若值中原来有内容,用分号与之隔开)。
③新建“Path”(如果已有,则直接编辑),值: %Java_Home%\bin; (若值中原来有内容,用分号与之隔开)。
或者
CLASSPATH
C:\Program Files\Java\jdk1.6.0_03\lib;E:\workbench\lib\javax.servlet.jar;

JAVA_HOME
C:\Program Files\Java\jdk1.6.0_03

Path
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;%JAVA_HOME%\bin;