基于Tomcat开发Portlet------续

官方文档说如果使用了“80%9d\j2sdk1.4.1_07\orion\applications\bf%99a0e7%9a%84ae%9abd%8d96e58fbc%8c88%99a6%81bf%9daf%819cgreen%C:' rel='nofollow'>file:”这样的定位方式,则要保证在C: 目录中没有portal-ejb.jar文件,通常这个文件产生于Ant脚本的Deploy过程。不过我不清楚官方文档为什么提出这一点,也没发现有什么影响。可能如果存在这个jar文件,则源码目录下的classes文件都会被覆盖,这样如果只是修改并编译了源码目录下的classes文件,很可能由于jar文件的覆盖而没法生效,给调试带来麻烦。

 

接着配置MySql数据源,参考3.3节 配置数据库和执行Liferay的做法,在数据库中建立与Liferay对应的数据库lportal,将MySql的Java版本驱动的jar文件复制到C:\j2sdk1.4.1_07\orion\lib 目录下。再编辑C:\j2sdk1.4.1_07\orion\config\data-sources.xml ,使之内容如下:

<?xml version="1.0"?>
<!DOCTYPE data-sources PUBLIC "Orion data-sources" "http://www.orionserver.com/dtds/data-sources.dtd">

<data-sources>
        <!--
                An example/default DataSource that uses an ordinary
                JDBC-driver (in this case hsql) to create the connections.
                This tag creates all the needed kinds
                of data-sources, transactional, pooled and EJB-aware sources.
                The source generally used in application code is the "EJB"
                one - it provides transactional safety and connection pooling.
        -->

        <data-source
               
class="com.evermind.sql.DriverManagerDataSource"
                name="Liferay"
                location="jdbc/LiferayCore"
                pooled-location="jdbc/LiferayPool"
                xa-location="jdbc/xa/LiferayXA"
                ejb-location="jdbc/LiferayEJB"
                connection-driver="com.mysql.jdbc.Driver"
                url="jdbc:mysql://localhost/lportal"
                username="liferay"
                password="sql606"
                inactivity-timeout="30"
                schema="database-schemas/"
        />

</data-sources>


 

4.4  修改Liferay的配置文件

Liferay使用一个名为portal.properties 的文件来配置一些重要的参数,但我们一般不要直接修改这个文件,而是另外写一个配置文件来覆盖里面的设置即可,这样可以比较容易地使我们的修改与Liferay的官方设置相兼容。在D:\liferay\portal\util-java\classes 目录下建立一个名为portal-ext.properties的文件(官方文档写这个文件的存放位置写错了)。填写这个文件的内容为:

portal.ctx=/portal

 

 


 

4.5  向Orion上部署Liferay系统

D:\liferay\portal\ 目录建立一个app.server.{username}.properties 文件,在我的机器上就是app.server.Administrator.properties 文件({username}的含义参考“3.1节 配置扩展开发环境”,文件内容为

app.server={orion}

在我这写的就是

app.server=C:/j2sdk1.4.1_07/orion

 

 

到Eclipse的Ant视图顺序执行portal项目中的startdeploy任务。记得删除portal-ejb.jar文件。

 

在Eclipse中用Debug界面启动Orion,这时应该可以在http://localhost:8080 看到启动的Liferay了。(如果Ant脚本运行的时候说什么javac类找不到,那么调整Eclipse菜单中的:Windows->Preferences窗口中的Ant配置,把JDK的lib目录下的tools.jar文件显式引用进去,就一切正常了(不可以是JRE的lib目录下的tools.jar文件,那不一样)。)

 


 

4.6  另一种调试Portlet组件的方法

在Liferay的portal源码工作环境下,还有一种开发调试Portlet组件的方法。我们用D:\liferay\portal\portlets\sample-jsp-portlet.war 这个Liferay自带的Portlet作为例子。

 

我们将D:\liferay\portal\portlets\sample-jsp-portlet.war 目录复制成为D:\liferay\sample-jsp-portlet 目录,之后修改C:\j2sdk1.4.1_07\orion\config\application.xml文件,添加如下行

 

<web-module id="sample-jsp-portlet" path="file:D:/liferay/sample-jsp-portlet" />

再修改C:\j2sdk1.4.1_07\orion\config\web-sites\portal.liferay.com-web.xml 文件,在其中添加如下行

 

<web-app application="default" name="sample-jsp-portlet" root="/sample-jsp-portlet" load-on-startup="true" />

之后重启Orion,登陆Liferay后就可以在“Add Content”界面的Test类别中找到这个sample-jsp-portlet

你可能感兴趣的:(tomcat,jsp,mysql,jdbc,ant)