Jboss Seam: Enabling Debug page on WebLogic 10.3.2 (11g)

后端 未结 3 1189
甜味超标
甜味超标 2020-12-03 23:25

SKIP TO UPDATE 3

I want to enable the Seam debug page on Weblogic 10.3.2 (11g). So, I have done the following:

I have the jboss-seam and jbo

相关标签:
3条回答
  • 2020-12-03 23:48

    You get the following exception

    No phase id bound to current thread (make sure you do not have two SeamPhaseListener instances installed)

    But you said you have installed an ejb and web maven project. Maybe both includes a SeamPhaseListener when you deploy your application. It, maybe, explains why you get your exception (Two SeamPhaseListener instances installed).

    My advice is (And if you want to avoid a lot of headache)

    Always generate your project by using Seam-gem

    See here why

    A nice article, besides Seam in Action book, about JSF/Seam can be found here

    Added to original answer

    See what Seam in Action book talks about it

    In Seam 2.0, the Seam phase listener is declared in a facesconfig.xml descriptor that is included in the core Seam JAR file, jboss-seam.jar. Thus, the phase listener is available as soon as you include this JAR file in your application.

    So, you do not have to worry about SeamPhaseListener. Seam will.

    UPDATE

    First of all, you have a ear application. Before going on

    Each EJB and war module should be declared in application.xml (The file that describes your ear)

    So your ear application should looks like this one (Let's call your ear application pureCharger)

    pureCharger.ear
    
        META-INF
            application.xml
        pureCharger-ejb.jar
            META-INF
                ejb-jar.xml
                persistence.xml
            lib
                // libraries ONLY USED by your EJB module goes here
        pureCharger-war.war
            WEB-INF
                web.xml
                components.xml
                faces-config.xml
                pages.xml
            lib
                // Here is what you want
                jboss-seam-debug.jar 
                jboss-seam-ui.jar
                jsf-facelets.jar
                // other libraries ONLY USED by your war module goes here
        jboss-seam.jar
        lib
            // JBoss Expression Language is used by both EJB and war module
            jboss-el.jar
            // libraries SHARED by all of your modules goes here
    

    ejb-jar.xml is shown as follows (It enables @In-jection by your EJB components)

    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0">
        <interceptors>
            <interceptor>
                <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
            </interceptor>
        </interceptors>
        <assembly-descriptor>
            <interceptor-binding>
                <ejb-name>*</ejb-name>
                <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
            </interceptor-binding>
        </assembly-descriptor>
    </ejb-jar>
    

    jboss-seam.jar is an EJB module

    So it should also be declared in application.xml file. And more, as said above, you do not have to define SeamPhaseListener because of jboss-seam.jar includes SeamPhaseListener. So avoid to see this nice message

    Two SeamPhaseListener instances installed

    So your ear application.xml should looks like this one

    <?xml version="1.0" encoding="UTF-8"?>
    <application version="5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd">
        <display-name>pureCharger</display-name>
        <module>
            <ejb>pureCharger-ejb.jar</ejb>
        </module>
        <module>
            <ejb>jboss-seam.jar</ejb>
        </module>
        <module>
            <web>
                <web-uri>pureCharger-war.war</web-uri>
                <context-root>pureCharger</context-root>
            </web>
        </module>
    </application>
    

    ok. Let's go

    You want to enable debug page

    The Seam debug page will be available if this jar is deployed in WEB-INF/lib, along with the Facelets, and if you set the debug property of the init component

    So your components.xml should looks like this one

    <?xml version="1.0" encoding="UTF-8"?>
    <components xmlns="http://jboss.com/products/seam/components"
        xmlns:core="http://jboss.com/products/seam/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
        http://jboss.com/products/seam/core
        http://jboss.com/products/seam/core-2.2.xsd
        http://jboss.com/products/seam/components
        http://jboss.com/products/seam/components-2.2.xsd">
        <core:init jndi-pattern="pureCharger/#{ejbName}/local" debug="true"/>
        <core:manager concurrent-request-timeout="500" conversation-timeout="120000" conversation-id-parameter="cid" />
    </components>
    

    See as shown above i have defined global JNDI address (I suppose you are using JBoss and your ear application is called pureCharger) in order to Seam retrieve its EJB component

    And finally, our web.xml file

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <context-param>
            <param-name>facelets.DEVELOPMENT</param-name>
            <param-value>true</param-value>
        </context-param>
        <context-param>
            <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
            <param-value>.xhtml</param-value>
        </context-param>
        <context-param>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>server</param-value>
        </context-param>
        <!--It must be the first-->
        <filter>
            <filter-name>Seam Filter</filter-name>
            <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>Seam Filter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        <!--It must be the first-->
        <listener>
            <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
        </listener>
        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.xhtml</url-pattern>
        </servlet-mapping>
        <!--specified in minutes-->
        <session-config>
            <session-timeout>30</session-timeout>
        </session-config>
    </web-app>
    

    And our faces-config.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config 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-facesconfig_1_2.xsd" version="1.2">
    <application>
        <locale-config>
            <default-locale>en</default-locale>
            <supported-locale>en</supported-locale>
        </locale-config>
        <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
        <resource-bundle>
            <base-name>XX.XXXX.XXX.prs.web.messages.messages</base-name>
            <var>msgs</var>
        </resource-bundle>
        <resource-bundle>
            <base-name>XX.XXXX.XXX.prs.web.messages.validation</base-name>
            <var>val</var>
        </resource-bundle>
    </application>
    </faces-config>
    

    A couple of notes

    You do not need to declare org.jboss.seam.el.SeamELResolver in faces-config.xml because it is bundled with jboss-seam.jar.

    Now, what is missed ?

    We need to call our debug page (Do not forget starting up JBoss and deploy your ear application)

    http://127.0.0.1:8080/pureCharger/debug.xhtml

    And again

    If you really want to avoid a lot of headache, use seam-gem

    UPDATE

    Is your ear project AS SHOWN ABOVE ??? MAKE SURE your war lib folder DOES NOT CONTAIN any jboss-seam.jar file. You said

    I opened the .ear and the following jboss jars are in:

    • jboss-seam-debug-2.2.0.GA.jar (wrong) It must be placed inside war file WEB-INF/lib folder
    • jboss-el-1.0_02.CR4.jar (wrong) It must be placed inside ear file lib folder
    • jboss-seam-2.2.0.GA.jar (right) But it must be declared in ear META-INF/application.xml file

    Here you can see a nice Tutorial about EJB 2.0 and 3.0 provided by me

    Helpful links about Seam Maven Integration

    http://www.seamframework.org/Community/MavenWithSeam

    http://www.seamframework.org/Documentation/SeamWithMavenOverview

    http://www.seamframework.org/Community/SeamInActionChapter2345And6Mavenized

    http://www.seamframework.org/Community/MavenSeamArchetype

    regards,

    0 讨论(0)
  • 2020-12-03 23:53

    What do you mean debug page? Do you mean the default Seam debug page? Which is debug.seam? Typically http://localhost:8080/debug.seam ?

    It is not enough to put in web.xml. You also need to put in components.xml

    <core:init debug="true" jndi-pattern="myApp/#{ejbName}/local"/>
    

    You also need to make sure that the jboss-seam-debug.jar is in classpath. Seam's interceptor should pick this up automatically.

    If you are using Facelets, to get its debug page you will need to put this in web.xml

    <context-param>
      <param-name>facelets.DEVELOPMENT</param-name>
      <param-value>true</param-value>
    </context-param>
    

    The tip from Arthur about always using seam-gen to generate your project is a very good idea.

    I also see that Arthur is saying you need to make sure jboss-seam-debug.jar shouldnt be in your lib in your war. That is not necessarily correct. I have mine in

    myapp.war/WEB-INF/lib/jboss-seam-debug.jar
    
    0 讨论(0)
  • 2020-12-03 23:57

    The reason Seam the debug page did not appear is unbelievable (for me).

    I packaged my application with Apache Maven. Traditionally, the filenames of jar files managed by maven also contain the version number. The jar for Seam is jboss-seam -2.2.0.GA.jar. Because Seam is an EJB module in the application, I declared its dependency as such. And indeed, the EAR contained it as an EJB module (located in the root of the EAR) and also declared it in the META-INF/application.xml.

    I don't know if the specification defines naming restrictions for the EJB modules in an EAR, but the version part of the filename was what WebLogic did not like (if modified, the war works fine on JBoss).

    I changed the setting in the maven-ear-plugin from this:

    <ejbModule>
        <groupId>org.jboss.seam</groupId>
        <artifactId>jboss-seam</artifactId>
    </ejbModule>
    

    to this:

    <ejbModule>
        <groupId>org.jboss.seam</groupId>
        <artifactId>jboss-seam</artifactId>
        <bundleFileName>jboss-seam.jar</bundleFileName>
    </ejbModule>
    

    And now I can see BOTH my application AND the Debug page.

    0 讨论(0)
提交回复
热议问题