Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] JSF Project with AspectJ in Tomcat 5

#: Paulo Alexandre Corigo Zenida changed the world a bit at a time by saying on  9/28/2005 10:52 AM :#
Hello,

I added the path for the aspectjrt.jar in the environment variable PATH and
I added both aspectjrt.jar and aspectjtools.jar in the lib directory, inside
the WEB-INF folder of my project.


I hope you mean: WEB-INF/lib folder ;-).

./alex
--
.the_mindstorm.

    Here's the code for my jsp file:

<%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f" %>
<f:view>
        <html>
                <head>
                        <title></title>
                </head>
                <body>
<h:outputLabel value="Name:" for="name"></h:outputLabel>
                        <h:inputText id="name" value="#{myBean.name}" />
<h:commandButton action="#{myBean.hello}" value="Hello" />
                </body>
        </html>
</f:view>

    Here's the code for my java class (the bean I use in the project):

package pt.iscte.ciiscte.aspectj;

public class MyBean {

        public String name;

        public MyBean() {
                System.out.println("Got into the constructor");
        }

        /**
         * @return Returns the name.
         */
        public String getName() {
                return name;
        }

        /**
         * @param name
         *            The name to set.
         */
        public void setName(String name) {
                this.name = name;
        }

        public String hello() {
                return auxHello();
        }

        public String auxHello() {
                return "hello";
        }
}

    Here's the code for my aspect:

package pt.iscte.ciiscte.aspectj;

public aspect MyBeanAdvice {

        pointcut advice() : call (* MyBean.auxHello());

        before() : advice() {
                throw new NullPointerException();
        }
}


    Here's the code for my web.xml file:

<?xml version="1.0"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd";>

    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>

        <context-param>
                <param-name>javax.faces.CONFIG_FILES</param-name>
                <param-value>/WEB-INF/faces-config.xml</param-value>
        </context-param>

    <listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
    </listener>

    <!-- Faces Servlet -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <init-param>
                <param-name>compiler</param-name>

<param-value>org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter</param-value>
                </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Faces Servlet Mapping -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

</web-app>

    And here's the code for my ant file:

<project name="ProjectoJSFComAspectJ" default="deploy" basedir=".">

        <!-- Project settings -->
        <property name="project.distname" value="ProjectoJSFComAspectJ" />

        <target name="init" depends="init.variables,init.taskdefs" />

        <target name="init.variables" description="init variables">
<property name="webroot.dir" location="${basedir}/../WebContent" />
                <property name="webinf.dir" value="${webroot.dir}/WEB-INF" />
<property name="compile.dir" location="${webinf.dir}/classes" />
                <property name="lib.dir" location="${webinf.dir}/lib" />
                <property name="build.dir" value="${basedir}/../build" />
<property name="plugins.dir" location="${basedir}/../../plugins" /> <property name="deploy.dir" location="C:\Program Files\Apache Software
Foundation\Tomcat 5.5\webapps" />
<property name="aspectjrt.jar" location="${lib.dir}/aspectjrt.jar" /> <property name="aspectjtools.jar" location="${lib.dir}/aspectjtools.jar" />
        </target>

<target name="init.taskdefs" depends="init.variables" unless="taskdefs.init">
                <taskdef
resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
                        <classpath>
                                <pathelement path="${aspectjtools.jar}" />
                        </classpath>
                </taskdef>
                <property name="taskdefs.init" value="true" />
        </target>

        <target name="compile" depends="init" description="build example">
<iajc destDir="${compile.dir}" classpath="${aspectjrt.jar}" fork="true">
                        <forkclasspath>
<pathelement path="${plugins.dir}/org.eclipse.core.boot_3.1.0.jar" /> <pathelement path="${plugins.dir}/org.eclipse.core.resources_3.1.0.jar" /> <pathelement path="${plugins.dir}/org.eclipse.core.runtime_3.1.0.jar" />
                                <pathelement
path="${plugins.dir}/org.eclipse.core.runtime.compatibility_3.1.0.jar" />
<pathelement path="${plugins.dir}/org.apache.ant_1.6.5/lib/ant.jar" />
                                <pathelement path="${aspectjtools.jar}" />
                        </forkclasspath>
                        <srcdir>
                                <pathelement path="../JavaSource/" />
                        </srcdir>
                </iajc>
        </target>

        <!-- Check timestamp on files -->
        <target name="prepare">
                <tstamp />
        </target>

        <!-- Remove classes directory for clean build -->
        <target name="clean" description="Prepare for clean build">
                <delete dir="${compile.dir}" />
                <mkdir dir="${compile.dir}" />
        </target>

        <!-- Build entire project -->
        <target name="build" depends="prepare,compile" />
        <target name="rebuild" depends="clean,prepare,compile" />

        <!-- Create binary distribution -->
        <target name="war" depends="build">
                <mkdir dir="${build.dir}" />
<war basedir="${webroot.dir}" warfile="${build.dir}/${project.distname}.war"
webxml="${webinf.dir}/web.xml">
                        <exclude name="WEB-INF/${build.dir}/**" />
                        <exclude name="WEB-INF/src/**" />
                        <exclude name="WEB-INF/web.xml" />
                </war>

        </target>

        <target name="deploy" depends="war">
                <delete file="${deploy.dir}/${project.distname}.war" />
                <delete dir="${deploy.dir}/${project.distname}" />
<copy file="${build.dir}/${project.distname}.war" todir="${deploy.dir}" />
        </target>

</project>


     Thanks for your answers,

         Paulo Zenida

Have you put the aspectj runtime library, aspectjrt.jar on the
classpath anywhere?

On 26/09/05, Paulo Alexandre Corigo Zenida <paulo.zenida@xxxxxxxx> wrote:
Hello,

 I'm new in AspectJ and I was trying to create a JSF project with Aspect J
capabilities, for example, for logging purporses in my project.

I'm using the latest version of AJDT in Eclipse 3.1 and trying to use it
in
Tomcat 5.x.

 I was able to compile the project in ant but it seems not to be working in
Tomcat. Can anybody tell me what can I do to make it work? Is it
necessary to
add anything to the Tomcat lib or change its configuration?

 A little help would be great. Thanks in advance,

  Paulo Zenida
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



--
-- Adrian
adrian.colyer@xxxxxxxxx
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users




----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



----- End forwarded message -----


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


------------------------------------------------------------------------

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top