Saturday, February 23, 2013

Load application configuration using CDI on Weblogic 12c

Testing this solution on Weblogic 12c
http://weblogs.java.net/blog/jjviana/archive/2010/05/18/applicaction-configuration-java-ee-6-using-cdi-simple-example

Deployed EJB module requires beans.xml file on META-INF
<?xml version="1.0" encoding="UTF-8"?>
<beans 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/beans_1_0.xsd">
</beans>


Annotation Config
package dave;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.inject.Qualifier;

@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
public @interface Config {
 
}

Configuration factory
package dave;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;

public class ConfigurationFactory {

    private volatile static Properties configProperties;
    public static final String propertiesFilePath = "/application.properties";

    public synchronized static Properties getProperties() {

        if (configProperties == null) {
            configProperties = new Properties();
            try {
                InputStream is = ConfigurationFactory.class.getResourceAsStream(propertiesFilePath);
                System.out.println("Found resource file" + (is != null));
                configProperties.load(is);
            } catch (IOException ex) {
                Logger.getLogger(ConfigurationFactory.class.getName()).log(
                        Level.SEVERE, null, ex);
                throw new RuntimeException(ex);
            }

        }

        return configProperties;
    }

    public @Produces
    @Config
    String getConfiguration(InjectionPoint p) {

        String configKey = p.getMember().getDeclaringClass().getName() + "."
                + p.getMember().getName();
        Properties config = getProperties();
        if (config.getProperty(configKey) == null) {
            configKey = p.getMember().getDeclaringClass().getSimpleName() + "."
                    + p.getMember().getName();
            if (config.getProperty(configKey) == null)
                configKey = p.getMember().getName();
        }
        System.err.println("Config key= " + configKey + " value = "
                + config.getProperty(configKey));

        return config.getProperty(configKey);
    }

    public @Produces
    @Config
    Double getConfigurationDouble(InjectionPoint p) {

        String val = getConfiguration(p);
        return Double.parseDouble(val);

    }

}


Test Facade
package dave;

import javax.ejb.EJB;
import javax.ejb.Stateless;

/**
 * Session Bean implementation class TestFacade
 */
@Stateless(mappedName = "TestFacade")
public class TestFacade implements TestFacadeRemote {

    @EJB
    TestStateless stateless;

    public String getServerAddress() {
        return stateless.getServerAddress();
    }

}

Facade Remote interface
package dave;

import javax.ejb.Remote;

@Remote
public interface TestFacadeRemote {
    
    public String getServerAddress();

}


EJB client calling facade
Client requires  /opt/weblogic/wlserver_12.1/server/lib/wlthint3client.jar on CLASSPATH
package dave;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class TestEJBClient {

    /**
     * @param args
     */
    public static void main(String[] args) {
        
        try {
            Properties props = new Properties();
            props.put(Context.PROVIDER_URL, "t3://localhost:7001");
            props.put(Context.INITIAL_CONTEXT_FACTORY,
                    "weblogic.jndi.WLInitialContextFactory");
            Context ctx = new InitialContext(props);
            TestFacadeRemote facade = (TestFacadeRemote) ctx.lookup("TestFacade#dave.TestFacadeRemote");
            
            System.out.println(facade.getServerAddress());
            
        } catch (NamingException e) {
            e.printStackTrace();
        }

    }

}



Loading configuration value in application class
package dave;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.inject.Inject;

/**
 * Session Bean implementation class TestStateless
 */
@Stateless(mappedName = "TestStateless")
@LocalBean
public class TestStateless {

    @Inject @Config
    private String serverAddress;
    
    public String getServerAddress() {
        return serverAddress;
    }
    

}


Output in Weblogic server log
Found resource filetrue
Config key= serverAddress value = dave

Test with plain Java class
package dave;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;


@ApplicationScoped
public class TestBean {
    
    @Inject @Config
    private String serverAddress;
    
    public String getServerAddress() {
        return serverAddress;
    }

}

Added call to plain class
package dave;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.inject.Inject;

/**
 * Session Bean implementation class TestFacade
 */
@Stateless(mappedName = "TestFacade")
public class TestFacade implements TestFacadeRemote {

    @EJB
    TestStateless stateless;
    
    @Inject
    TestBean testBean;

    public String getServerAddress() {
        
        System.out.println("get value from testbean " + testBean.getServerAddress());
        
        System.out.println("get value from testbean " + testBean.getServerAddress());
        
        System.out.println("get value from stateless " + stateless.getServerAddress());
        
        System.out.println("get value from stateless " + stateless.getServerAddress());
        
        return stateless.getServerAddress();
    }

}


Output in Weblogic log
Found resource filetrue
Config key= serverAddress value = dave
get value from testbean dave
get value from testbean dave
Config key= serverAddress value = dave
get value from stateless dave
get value from stateless dave



Exception when config file is not found
Exception in thread "main" javax.ejb.EJBTransactionRolledbackException: EJB Exception: 
    at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:453)
    at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:166)
    at weblogic.ejb.container.internal.BaseLocalObject.preInvoke(BaseLocalObject.java:103)
    at weblogic.ejb.container.internal.BaseLocalObject.__WL_preInvoke(BaseLocalObject.java:67)
    at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:20)
    at dave.TestStateless_954dmo_NoIntfViewImpl.getServerAddress(Unknown Source)
    at dave.TestFacade.getServerAddress(TestFacade.java:16)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.bea.core.repackaged.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
    at com.oracle.pitchfork.intercept.MethodInvocationInvocationContext.proceed(MethodInvocationInvocationContext.java:103)
    at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.oracle.pitchfork.intercept.JeeInterceptorInterceptor.invoke(JeeInterceptorInterceptor.java:108)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at com.bea.core.repackaged.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at com.bea.core.repackaged.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
    at com.bea.core.repackaged.springframework.aop.framework.JdkDynamicAopProxy.invoke(Unknown Source)
    at $Proxy111.getServerAddress(Unknown Source)
    at dave.TestFacade_23kp48_TestFacadeRemoteImpl.__WL_invoke(Unknown Source)
    at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:32)
    at dave.TestFacade_23kp48_TestFacadeRemoteImpl.getServerAddress(Unknown Source)
    at dave.TestFacade_23kp48_TestFacadeRemoteImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:695)
    at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:520)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:516)
    at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: java.lang.NullPointerException
    at java.util.Properties$LineReader.readLine(Properties.java:418)
    at java.util.Properties.load0(Properties.java:337)
    at java.util.Properties.load(Properties.java:325)
    at dave.ConfigurationFactory.getProperties(ConfigurationFactory.java:22)
    at dave.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
    at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260)
    at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170)
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:137)
    at org.jboss.weld.bean.ProducerMethod$1.produce(ProducerMethod.java:132)
    at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:299)
    at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:61)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:630)
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:691)
    at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:118)
    at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:691)
    at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:700)
    at org.jboss.weld.bean.SessionBean$1$1.proceed(SessionBean.java:175)
    at com.oracle.injection.provider.weld.WeldInjectionServicesAdapter.aroundInject(WeldInjectionServicesAdapter.java:88)
    at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:45)
    at org.jboss.weld.bean.SessionBean$1.inject(SessionBean.java:172)
    at com.oracle.injection.provider.weld.WeldEjbBeanManager$ExtendedInjectionTarget.inject(WeldEjbBeanManager.java:119)
    at com.oracle.injection.provider.weld.WeldEjbBeanManager.newBeanInstance(WeldEjbBeanManager.java:82)
    at weblogic.ejb.container.injection.InjectionBasedEjbComponentCreator.getBean(InjectionBasedEjbComponentCreator.java:75)
    at weblogic.ejb.container.manager.BaseEJBManager.createNewBeanInstance(BaseEJBManager.java:209)
    at weblogic.ejb.container.manager.BaseEJBManager.allocateBean(BaseEJBManager.java:235)
    at weblogic.ejb.container.manager.StatelessManager.createBean(StatelessManager.java:293)
    at weblogic.ejb.container.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:185)
    at weblogic.ejb.container.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:114)
    at weblogic.ejb.container.manager.StatelessManager.preInvoke(StatelessManager.java:174)
    at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:146)
    ... 38 more

Saturday, February 9, 2013

Weblogic 12c - Java EE 6 decriptors

Java EE 6 descriptors

 

HOWTO

Web Project 3.0 


web.xml 


<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>testJSF2</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
</web-app>

weblogic.xml http://docs.oracle.com/cd/E24329_01/web.1211/e21049/weblogic_xml.htm



<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" 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 http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
    <wls:weblogic-version>12.1.1</wls:weblogic-version>
    <wls:context-root>testJSF2</wls:context-root>
    <wls:container-descriptor>
        <wls:prefer-application-packages>
            <wls:package-name>com.dave.*</wls:package-name>
        </wls:prefer-application-packages>
        <wls:prefer-application-resources>
            <wls:resource-name>com.dave.*</wls:resource-name>
        </wls:prefer-application-resources>
    </wls:container-descriptor>
    <wls:security-role-assignment>
        <wls:role-name>daverole</wls:role-name>
        <wls:principal-name>dave</wls:principal-name>
    </wls:security-role-assignment>
    <wls:run-as-role-assignment>
        <wls:role-name>daverole</wls:role-name>
        <wls:run-as-principal-name>dave</wls:run-as-principal-name>
    </wls:run-as-role-assignment>
</wls:weblogic-web-app>

EJB 3.1 project


ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.1" 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_1.xsd">
  <display-name>testDaveEJB31 </display-name> 
 </ejb-jar>

weblogic-ejb-jar   http://docs.oracle.com/cd/E24329_01/web.1211/e24973/ejb_jar_ref.htm#autoId0


<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-ejb-jar xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar" 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_1.xsd http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.3/weblogic-ejb-jar.xsd">
    <!--weblogic-version:12.1.1-->
    <wls:security-role-assignment>
        <wls:role-name>daverole</wls:role-name>
        <wls:principal-name>dave</wls:principal-name>
    </wls:security-role-assignment>
    <wls:run-as-role-assignment>
        <wls:role-name>daverole</wls:role-name>
        <wls:run-as-principal-name>dave</wls:run-as-principal-name>
    </wls:run-as-role-assignment>
</wls:weblogic-ejb-jar>

Enterprise Application Project 6 (EAR)


application.xml


<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:application="http://java.sun.com/xml/ns/javaee/application_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd"
 id="Application_ID" version="6">
  <display-name>testDaveEAR6</display-name>
  <module>
    <ejb>testDaveEJB31.jar</ejb>
  </module>
  <module>
    <web>
      <web-uri>testJSF2.war</web-uri>
      <context-root>testJSF2</context-root>
    </web>
  </module>
</application>

weblogic-application.xml


<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application" 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/javaee_5.xsd http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.4/weblogic-application.xsd">
    <!--weblogic-version:12.1.1-->
    <wls:security>
        <wls:security-role-assignment>
            <wls:role-name>daverole</wls:role-name>
            <wls:principal-name>dave</wls:principal-name>
        </wls:security-role-assignment>
    </wls:security>
    <wls:application-param>
        <wls:param-name>webapp.encoding.default</wls:param-name>
        <wls:param-value>UTF-8</wls:param-value>
    </wls:application-param>
    <wls:prefer-application-packages>
        <wls:package-name>com.dave.*</wls:package-name>
    </wls:prefer-application-packages>
    <wls:prefer-application-resources>
        <wls:resource-name>com.dave.*</wls:resource-name>
    </wls:prefer-application-resources>
</wls:weblogic-application>


Declaring security roles 

http://docs.oracle.com/javaee/5/tutorial/doc/bncav.html

http://docs.oracle.com/cd/E19226-01/820-7627/gjgdi/index.html

@DeclareRoles("employee")
public class CalculatorServlet {
    //...
}

Specifying @DeclareRoles("employee") is equivalent to defining the following in the web.xml:

<security-role>
    <role-name>employee</role-name>
</security-role>

http://docs.oracle.com/cd/E24329_01/web.1211/e24421/secejbwar.htm#autoId1

Deployment Descriptor Only (Java EE standard)
The web.xml, weblogic.xml and ejb-jar.xml, weblogic-ejb-jar.xml deployment descriptors.
If roles have been defined for the application that contains the Web application or EJB, all roles are combined using a logical OR operation.

The following security-related annotations are available:

Eclipse OEPE project facets


 EJB 3.1


 Web 3.0 

 

Thursday, February 7, 2013

Precompile JSF 1.1 pages on Weblogic 12c

Even after adding only JSF 1.1 jars  on compile classpath of wlappc the generated java classes are not running correctly on Weblogic 12c. There seems to be problem with classpath of wlappc which is not respecting filtering classloader of weblogic.xml descriptor.

Problem can be solved by adding precompile to jsp-descriptor element of weblogic.xml 


precompile
 
When set to true, WebLogic Server automatically precompiles all modified JSPs when the Web application is deployed or re-deployed or when starting WebLogic Server


precompile-continue
 
When set to true, WebLogic Server continues precompiling all modified JSPs even if some of those JSPs fail during compilation. Only takes effect when precompile is set to true.



Weblogic appc
http://docs.oracle.com/cd/E24329_01/web.1211/e24973/appc_ejbc.htm

Add option to check class loading
 http://docs.oracle.com/javase/7/docs/technotes/tools/solaris/java.html

-verbose:class
Display information about each class loaded.


JSP page
<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<f:view>
<f:loadBundle basename="resources.application" var="msg"/>
<html>
<head>
  <title><h:outputText value="#{msg.welcomeTitle}" /></title>
</head>
<body>

<h3><h:outputText value="#{msg.welcomeHeading}" /></h3>

<p><h:outputText value="#{msg.welcomeMessage}" /></p>

</body>
</html>
</f:view>



Compile using MyFaces libs in WEB-INF/lib
[dave@dave config]$ java weblogic.appc -verboseJavac -verbose ~/workspace/testFSF11/WebContent/
[JspcInvoker]Checking web app for compliance.
<Feb 6, 2013 11:39:24 PM CET> <Info> <HTTP> <BEA-101047> <[ComplianceChecker] Validating the servlet element with servlet-name named "Faces Servlet".> 
<Feb 6, 2013 11:39:24 PM CET> <Info> <HTTP> <BEA-101047> <[ComplianceChecker] Checking servlet-mapping for servlet name : "Faces Servlet".> 
[jspc]  -webapp specified, searching . for JSPs
[jspc] Compiling /index.jsp
<Feb 6, 2013 11:39:29 PM CET> <Info> <J2EE> <BEA-160220> <Compilation completed successfully.> 

Alternative ant script

<project name="Appc" default="appc" basedir="./">

    <property environment="env"/>

    <target name="appc" description="Packages the WAR file">
        <!-- Precompile JSP pages using appc -->
        <echo message="Precompile JSP pages using appc in WebContent" />
        <path id="wlappc.classpath">
            <fileset dir="${env.WL_HOME}/server/lib">
                <include name="weblogic.jar" />
            </fileset>
        </path>
        <path id="compile.classpath">
            <fileset dir="WebContent/WEB-INF/lib">
                <include name="*.jar" />
            </fileset>
        </path>

        <echo message="${toString:wlappc.classpath}" />
        <echo message="${toString:compile.classpath}" />
        <taskdef name="wlappc" classname="weblogic.ant.taskdefs.j2ee.Appc"
            classpathref="wlappc.classpath" />
        <wlappc verbose="true" keepGenerated="true" source="WebContent"
            verboseJavac="true"
            classpathref="compile.classpath">

        </wlappc>

    </target>


[dave@dave testFSF11]$ ant 
Buildfile: build.xml

appc:
     [echo] Precompile JSP pages using appc in WebContent
     [echo] /opt/weblogic/wlserver_12.1/server/lib/weblogic.jar
     [echo] /home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-beanutils-1.7.0.jar:/home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-collections-3.1.jar:/home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-digester-1.8.jar:/home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-el-1.0.jar:/home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-lang-2.1.jar:/home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar:/home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/jstl-1.1.0.jar:/home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/myfaces-api-1.1.10.jar:/home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/myfaces-impl-1.1.10.jar
   [wlappc] [JspcInvoker]Checking web app for compliance.
   [wlappc] <Feb 6, 2013 11:51:12 PM CET> <Info> <HTTP> <BEA-101047> <[ComplianceChecker] Validating the servlet element with servlet-name named "Faces Servlet".> 
   [wlappc] <Feb 6, 2013 11:51:12 PM CET> <Info> <HTTP> <BEA-101047> <[ComplianceChecker] Checking servlet-mapping for servlet name : "Faces Servlet".> 
   [wlappc] [jspc] Overriding descriptor option 'keepgenerated' with value specified on command-line 'true' 
   [wlappc] [jspc]  -webapp specified, searching . for JSPs
   [wlappc] [jspc] Compiling /index.jsp
   [wlappc] <Feb 6, 2013 11:51:18 PM CET> <Info> <J2EE> <BEA-160220> <Compilation completed successfully.> 

BUILD SUCCESSFUL
Total time: 10 seconds



Compile using JSF 1.2 deployable library

[dave@dave testJSF1]$ java weblogic.appc -keepGenerated  -verboseJavac -verbose -library /opt/weblogic/wlserver_12.1/common/deployable-libraries/jsf-1.2.war  WebContent/
<Feb 7, 2013 12:52:28 AM CET> <Info> <J2EE> <BEA-160151> <Registered library Extension-Name: jsf, Specification-Version: 1.2, Implementation-Version: 1.2.9.0 (WAR).> 
Unresolved WebApp library references defined in weblogic.xml, of module 'WebContent' [Extension-Name: jstl, Specification-Version: 1.2, exact-match: true]
[dave@dave testJSF1]$ java weblogic.appc -keepGenerated  -verboseJavac -verbose -library /opt/weblogic/wlserver_12.1/common/deployable-libraries/jsf-1.2.war,/opt/weblogic/wlserver_12.1/common/deployable-libraries/jstl-1.2.war  WebContent/
<Feb 7, 2013 12:53:07 AM CET> <Info> <J2EE> <BEA-160151> <Registered library Extension-Name: jsf, Specification-Version: 1.2, Implementation-Version: 1.2.9.0 (WAR).> 
<Feb 7, 2013 12:53:07 AM CET> <Info> <J2EE> <BEA-160151> <Registered library Extension-Name: jstl, Specification-Version: 1.2, Implementation-Version: 1.2.0.2 (WAR).> 
[JspcInvoker]Checking web app for compliance.
<Feb 7, 2013 12:53:10 AM CET> <Info> <HTTP> <BEA-101047> <[ComplianceChecker] Validating the servlet element with servlet-name named "Faces Servlet".> 
<Feb 7, 2013 12:53:10 AM CET> <Info> <HTTP> <BEA-101047> <[ComplianceChecker] Checking servlet-mapping for servlet name : "Faces Servlet".> 
[jspc] Overriding descriptor option 'keepgenerated' with value specified on command-line 'true' 
[jspc]  -webapp specified, searching . for JSPs
[jspc] Compiling /index.jsp
<Feb 7, 2013 12:53:14 AM CET> <Info> <J2EE> <BEA-160220> <Compilation completed successfully.> 

Difference between MyFaces and JSF 1.2 compilation

[dave@dave workspace]$ diff testJSF1/WebContent/WEB-INF/classes/jsp_servlet/__index.java testFSF11/WebContent/WEB-INF/classes/jsp_servlet/__index.java
32c32
<         if (sci.isResourceStale("/index.jsp", 1359883373000L ,"12.1.1.0","Europe/Bratislava")) return true;
---
>         if (sci.isResourceStale("/index.jsp", 1359886357000L ,"12.1.1.0","Europe/Bratislava")) return true;
105c105
<          com.sun.faces.taglib.jsf_core.ViewTag __tag0 = null ;
---
>          org.apache.myfaces.taglib.core.ViewTag __tag0 = null ;
109c109
<             __tag0 = new  com.sun.faces.taglib.jsf_core.ViewTag ();
---
>             __tag0 = new  org.apache.myfaces.taglib.core.ViewTag ();
116d115
<         __tag0.setJspId("id0");
165c164
<     private boolean _jsp__tag1(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.jsp.PageContext pageContext, javax.servlet.jsp.tagext.JspTag activeTag, com.sun.faces.taglib.jsf_core.ViewTag parent) throws java.lang.Throwable
---
>     private boolean _jsp__tag1(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.jsp.PageContext pageContext, javax.servlet.jsp.tagext.JspTag activeTag, org.apache.myfaces.taglib.core.ViewTag parent) throws java.lang.Throwable
170c169
<          com.sun.faces.taglib.jsf_core.LoadBundleTag __tag1 = null ;
---
>          org.apache.myfaces.taglib.core.LoadBundleTag __tag1 = null ;
174c173
<             __tag1 = new  com.sun.faces.taglib.jsf_core.LoadBundleTag ();
---
>             __tag1 = new  org.apache.myfaces.taglib.core.LoadBundleTag ();
179c178
<         __tag1.setBasename( weblogic.servlet.jsp.ELHelper.createValueExpression("resources.application",java.lang.String.class,pageContext,_jspx_fnmap));
---
>         __tag1.setBasename(( java.lang.String) weblogic.jsp.internal.jsp.utils.JspRuntimeUtils.convertType("resources.application", java.lang.String.class,"basename"));
186c185
<                  throw  new  javax.servlet.jsp.JspTagException("Since tag class com.sun.faces.taglib.jsf_core.LoadBundleTag does not implement BodyTag, it cannot return BodyTag.EVAL_BODY_BUFFERED");
---
>                  throw  new  javax.servlet.jsp.JspTagException("Since tag class org.apache.myfaces.taglib.core.LoadBundleTag does not implement BodyTag, it cannot return BodyTag.EVAL_BODY_BUFFERED");
200c199
<     private boolean _jsp__tag2(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.jsp.PageContext pageContext, javax.servlet.jsp.tagext.JspTag activeTag, com.sun.faces.taglib.jsf_core.ViewTag parent) throws java.lang.Throwable
---
>     private boolean _jsp__tag2(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.jsp.PageContext pageContext, javax.servlet.jsp.tagext.JspTag activeTag, org.apache.myfaces.taglib.core.ViewTag parent) throws java.lang.Throwable
205c204
<          com.sun.faces.taglib.html_basic.OutputTextTag __tag2 = null ;
---
>          org.apache.myfaces.taglib.html.HtmlOutputTextTag __tag2 = null ;
209c208
<             __tag2 = new  com.sun.faces.taglib.html_basic.OutputTextTag ();
---
>             __tag2 = new  org.apache.myfaces.taglib.html.HtmlOutputTextTag ();
214,215c213
<         __tag2.setJspId("id2");
<         __tag2.setValue( weblogic.servlet.jsp.ELHelper.createValueExpression("#{msg.welcomeTitle}",java.lang.Object.class,pageContext,_jspx_fnmap));
---
>         __tag2.setValue(( java.lang.String) weblogic.jsp.internal.jsp.utils.JspRuntimeUtils.convertType("#{msg.welcomeTitle}", java.lang.String.class,"value"));
220a219
>                  throw  new  javax.servlet.jsp.JspTagException("Since tag class org.apache.myfaces.taglib.html.HtmlOutputTextTag does not implement BodyTag, it cannot return BodyTag.EVAL_BODY_BUFFERED");
234c233
<     private boolean _jsp__tag3(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.jsp.PageContext pageContext, javax.servlet.jsp.tagext.JspTag activeTag, com.sun.faces.taglib.jsf_core.ViewTag parent) throws java.lang.Throwable
---
>     private boolean _jsp__tag3(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.jsp.PageContext pageContext, javax.servlet.jsp.tagext.JspTag activeTag, org.apache.myfaces.taglib.core.ViewTag parent) throws java.lang.Throwable
239c238
<          com.sun.faces.taglib.html_basic.OutputTextTag __tag3 = null ;
---
>          org.apache.myfaces.taglib.html.HtmlOutputTextTag __tag3 = null ;
243c242
<             __tag3 = new  com.sun.faces.taglib.html_basic.OutputTextTag ();
---
>             __tag3 = new  org.apache.myfaces.taglib.html.HtmlOutputTextTag ();
248,249c247
<         __tag3.setJspId("id3");
<         __tag3.setValue( weblogic.servlet.jsp.ELHelper.createValueExpression("#{msg.welcomeHeading}",java.lang.Object.class,pageContext,_jspx_fnmap));
---
>         __tag3.setValue(( java.lang.String) weblogic.jsp.internal.jsp.utils.JspRuntimeUtils.convertType("#{msg.welcomeHeading}", java.lang.String.class,"value"));
254a253
>                  throw  new  javax.servlet.jsp.JspTagException("Since tag class org.apache.myfaces.taglib.html.HtmlOutputTextTag does not implement BodyTag, it cannot return BodyTag.EVAL_BODY_BUFFERED");
268c267
<     private boolean _jsp__tag4(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.jsp.PageContext pageContext, javax.servlet.jsp.tagext.JspTag activeTag, com.sun.faces.taglib.jsf_core.ViewTag parent) throws java.lang.Throwable
---
>     private boolean _jsp__tag4(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.jsp.PageContext pageContext, javax.servlet.jsp.tagext.JspTag activeTag, org.apache.myfaces.taglib.core.ViewTag parent) throws java.lang.Throwable
273c272
<          com.sun.faces.taglib.html_basic.OutputTextTag __tag4 = null ;
---
>          org.apache.myfaces.taglib.html.HtmlOutputTextTag __tag4 = null ;
277c276
<             __tag4 = new  com.sun.faces.taglib.html_basic.OutputTextTag ();
---
>             __tag4 = new  org.apache.myfaces.taglib.html.HtmlOutputTextTag ();
282,283c281
<         __tag4.setJspId("id4");
<         __tag4.setValue( weblogic.servlet.jsp.ELHelper.createValueExpression("#{msg.welcomeMessage}",java.lang.Object.class,pageContext,_jspx_fnmap));
---
>         __tag4.setValue(( java.lang.String) weblogic.jsp.internal.jsp.utils.JspRuntimeUtils.convertType("#{msg.welcomeMessage}", java.lang.String.class,"value"));
288a287
>                  throw  new  javax.servlet.jsp.JspTagException("Since tag class org.apache.myfaces.taglib.html.HtmlOutputTextTag does not implement BodyTag, it cannot return BodyTag.EVAL_BODY_BUFFERED");


Check from where are classed loaded
[dave@dave jsf-blank-myfaces]$ java -verbose:class weblogic.appc -keepGenerated  -verboseJavac -verbose -library /opt/weblogic/wlserver_12.1/common/deployable-libraries/jsf-1.2.war,/opt/weblogic/wlserver_12.1/common/deployable-libraries/jstl-1.2.war  WebContent/ > classloader.log


weblogic.appc
[dave@dave jsf-blank-myfaces]$ grep appc classloader.log 
[Loaded weblogic.appc from file:/opt/weblogic/wlserver_12.1/server/lib/weblogic.jar]


myfaces
[Loaded javax.faces.webapp.FacesServlet from file:/home/dave/app/jsf-blank-myfaces/WebContent/WEB-INF/lib/myfaces-api-1.1.5.jar]


Extract appc class

[dave@dave jsf-blank-myfaces]$ jar tvf /opt/weblogic/wlserver_12.1/server/lib/weblogic.jar |grep -i appc
  2091 Wed Dec 07 08:42:12 CET 2011 weblogic/management/configuration/WebAppContainerMBean.class
 19320 Wed Dec 07 08:45:18 CET 2011 weblogic/management/configuration/WebAppContainerMBeanImpl.class
 13336 Wed Dec 07 08:45:18 CET 2011 weblogic/management/configuration/WebAppContainerMBeanImpl$Helper.class
  9673 Wed Dec 07 08:47:18 CET 2011 weblogic/ant/taskdefs/j2ee/Appc.class
   479 Wed Dec 07 08:43:08 CET 2011 weblogic/appc.class

[dave@dave jsf-blank-myfaces]$ jar xvf /opt/weblogic/wlserver_12.1/server/lib/weblogic.jar weblogic/ant/taskdefs/j2ee/Appc.class
 inflated: weblogic/ant/taskdefs/j2ee/Appc.class

Disassemble class files using javap
 

[dave@dave jsf-blank-myfaces]$ javap  weblogic/ant/taskdefs/j2ee/Appc.class
Compiled from "Appc.java"
public class weblogic.ant.taskdefs.j2ee.Appc extends weblogic.ant.taskdefs.j2ee.CompilerTask {
  public weblogic.ant.taskdefs.j2ee.Appc();
  public void setClasspath(java.lang.String);
  public void setSource(java.lang.String);
  public void setOutput(java.lang.String);
  public void setForceGeneration(boolean);
  public void setLineNumbers(boolean);
  public void setBasicClientJar(boolean);
  public void setContinueCompilation(boolean);
  public void setVerbose(boolean);
  public void setEnableHotCodeGen(boolean);
  public void setIiopDirectory(java.lang.String);
  public void setIdlDirectory(java.lang.String);
  public void setIdl(boolean);
  public void setIdlOverwrite(boolean);
  public void setIdlVerbose(boolean);
  public void setIdlNoValueTypes(boolean);
  public void setIdlNoAbstractInterfaces(boolean);
  public void setIdlFactories(boolean);
  public void setIdlVisibroker(boolean);
  public void setIdlOrbix(boolean);
  public void setIiop(boolean);
  public void setIdlMethodSignatures(java.lang.String);
  public void setlibraryDir(java.lang.String);
  public void setPlan(java.lang.String);
  public void setClientJarOutputDir(java.lang.String);
  public void addConfiguredLibrary(weblogic.ant.taskdefs.utils.LibraryElement);
  public void execute();
}

Sunday, February 3, 2013

Deploy JSF 1.1 application on Weblogic 12.1.1

Deploy JSF 1.1 application on Weblogic 12.1.1

http://docs.oracle.com/cd/E24329_01/web.1211/e21049/configurejsfandjtsl.htm

Classloading: Making Hibernate work on WebLogic


If your application includes JSF JARs that you want to reference instead of the WebLogic Server bundled JSF shared libraries, you can configure a filtering classloader in weblogic-application.xml (.ear) as shown below.
http://docs.oracle.com/cd/E24329_01/web.1211/e24368/app_xml.htm

WLS 12.1.1 docs says it can be used also in war it seems to be ignored when only war is deployed.
Note that in order to use prefer-application-packages or prefer-application-resources, prefer-web-inf-classes must be set to false.

http://docs.oracle.com/cd/E24329_01/web.1211/e21049/weblogic_xml.htm

weblogic.xml 

List of schema versions for http://xmlns.oracle.com/weblogic/weblogic-web-app
1.0 : Released with WLS v10.3.1.0
1.1 : Released with WLS v10.3.3.0
1.2 : Released with WLS v10.3.4.0
1.3 : Released with WLS v10.3.6.0
1.4 : Released with WLS v12.1.1.0

 

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
  <container-descriptor>
    <prefer-web-inf-classes>false</prefer-web-inf-classes>
    <prefer-application-packages>
      <package-name>javax.faces.*</package-name>
      <package-name>com.sun.faces.*</package-name>
      <package-name>com.bea.faces.*</package-name>
    </prefer-application-packages>
 
    <prefer-application-resources>
      <resource-name>javax.faces.*</resource-name>
      <resource-name>com.sun.faces.*</resource-name>
      <resource-name>com.bea.faces.*</resource-name>
      <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
      </prefer-application-resources>
  </container-descriptor>
</weblogic-web-app>

weblogic-application.xml 

List of schema versions for http://xmlns.oracle.com/weblogic/weblogic-application
1.0 : Released with WLS v10.3.1.0
1.1 : Released with WLS v10.3.3.0
1.2 : Released with WLS v10.3.4.0
1.3 : Released with WLS v10.3.6.0
1.4 : Released with WLS v12.1.1.0

 

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application" 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/javaee_5.xsd http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.4/weblogic-application.xsd">
    <!--weblogic-version:12.1.1-->
    <wls:application-param>
        <wls:param-name>webapp.encoding.default</wls:param-name>
        <wls:param-value>UTF-8</wls:param-value>
    </wls:application-param>
    <wls:prefer-application-packages> 
       <wls:package-name>javax.faces.*</wls:package-name> 
        <wls:package-name>com.sun.faces.*</wls:package-name> 
        <wls:package-name>com.bea.faces.*</wls:package-name> 
    </wls:prefer-application-packages> 
 
    <wls:prefer-application-resources> 
       <wls:resource-name>javax.faces.*</wls:resource-name> 
       <wls:resource-name>com.sun.faces.*</wls:resource-name> 
       <wls:resource-name>com.bea.faces.*</wls:resource-name> 
 
       <wls:resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</wls:resource-name>
    </wls:prefer-application-resources>
</wls:weblogic-application>


https://forums.oracle.com/forums/thread.jspa?messageID=10101558&tstart=0

In WLS 12.1.1  release, the weblogic.xml file in jsf-1.2.war configures a filtering classloader for your application's JSF classes and resources.

Which basically means that we have provided a pre-configured filtering classloader definition so that the server will load classes from the specified packages from libraries supplied or referenced by the application. Without this, you'll always get the JSF 2.x implementation that is now provided on the direct WLS classpath (a change in WLS 12c to make using JSF easier).

Is there a reason you're using that older "jsf-myfaces 1.1.7" library? This won't have the filtering classloader definition. If you want to use that, then in addition to making the library reference to it, you'll also need to add a filtering classloader defininition. Take a look at the weblogic.xml file inside the jsf-1.2.war and copy the stanzas to your own configuration file.




JSF 1.1 tutorial

http://www.coreservlets.com/JSF-Tutorial/jsf1/

Blank JSF 1.1 project 
http://www.coreservlets.com/JSF-Tutorial/jsf1/code/jsf-blank-myfaces.zip


JSF versions

  • JSF 1.1 requires java 1.3 or later, JSP 1.2, JSTL 1.0, and a Java Servlet 2.3 implementation.
  • JSF 1.2 requires java 1.5 or later, JSP 2.1, JSTL 1.2 and a Java Servlet 2.5 implementation (Java EE 5)
  •  JSF 2.0 requires java 1.5 or later, JSP 2.1, JSTL 1.2 and a Java Servlet 2.5 implementation (Java EE 6)
  •  JSF 2.1 requires java 1.5 or later, JSP 2.1, JSTL 1.2 and a Java Servlet 2.5 implementation.
Create OEPE project

JSF 1.1 OEPE project libs ( optional - it is enough to put all libs into WEB-INF/lib )
http://myfaces.apache.org/core11/index.html



JSF 1.1 project configuration
 
JSF 1.1 faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE faces-config PUBLIC
    "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
    "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<faces-config>
    <application>
        <message-bundle>resources.application</message-bundle>
        <locale-config>
            <default-locale>en</default-locale>
        </locale-config>
    </application>

</faces-config>

weblogic.xml  using filtering classloader

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
    xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
    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 http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
    <wls:weblogic-version>12.1.1</wls:weblogic-version>
    <wls:context-root>testJSF11</wls:context-root>
    <wls:container-descriptor>

        <wls:prefer-application-packages>
            <wls:package-name>org.apache.*</wls:package-name>
            <wls:package-name>javax.faces.*</wls:package-name>
            <wls:package-name>com.sun.faces.*</wls:package-name>
            <wls:package-name>com.bea.faces.*</wls:package-name>
        </wls:prefer-application-packages>

        <wls:prefer-application-resources>
            <wls:resource-name>javax.faces.*</wls:resource-name>
            <wls:resource-name>com.sun.faces.*</wls:resource-name>
            <wls:resource-name>com.bea.faces.*</wls:resource-name>
            <wls:resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</wls:resource-name>
        </wls:prefer-application-resources>

    </wls:container-descriptor>

</wls:weblogic-web-app>

JSF 1.1 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>testFSF11</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <description>
    This parameter tells MyFaces if javascript code should be allowed in
    the rendered HTML output.
    If javascript is allowed, command_link anchors will have javascript code
    that submits the corresponding form.
    If javascript is not allowed, the state saving info and nested parameters
    will be added as url parameters.
    Default is 'true'</description>
    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <description>
    If true, rendered HTML code will be formatted, so that it is 'human-readable'
    i.e. additional line separators and whitespace will be written, that do not
    influence the HTML code.
    Default is 'true'</description>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
    <param-value>false</param-value>
  </context-param>
  <context-param>
    <description>
    If true, a javascript function will be rendered that is able to restore the
    former vertical scroll on every request. Convenient feature if you have pages
    with long lists and you do not want the browser page to always jump to the top
    if you trigger a link or button action that stays on the same page.
    Default is 'false'
</description>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>true</param-value>
  </context-param>
  <listener>
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
  </listener>
</web-app>

Add JSF 1.1 libraries into WEB-INF/lib
[dave@dave testFSF11]$ ls -lR
.:
total 12
drwxrwxr-x. 3 dave dave 4096 Feb  3 11:12 build
drwxrwxr-x. 3 dave dave 4096 Feb  3 11:12 src
drwxrwxr-x. 4 dave dave 4096 Feb  3 11:12 WebContent

./build:
total 4
drwxrwxr-x. 3 dave dave 4096 Feb  3 11:13 classes

./build/classes:
total 4
drwxrwxr-x. 2 dave dave 4096 Feb  3 11:13 resources

./build/classes/resources:
total 4
-rw-rw-r--. 1 dave dave 227 Feb  3 11:12 application.properties

./src:
total 4
drwxrwxr-x. 2 dave dave 4096 Feb  3 11:12 resources

./src/resources:
total 4
-rw-rw-r--. 1 dave dave 227 Feb  3 11:12 application.properties

./WebContent:
total 12
-rw-rw-r--. 1 dave dave  505 Feb  3 11:12 index.jsp
drwxrwxr-x. 2 dave dave 4096 Feb  3 11:12 META-INF
drwxrwxr-x. 3 dave dave 4096 Feb  3 11:17 WEB-INF

./WebContent/META-INF:
total 4
-rw-rw-r--. 1 dave dave 39 Feb  3 11:12 MANIFEST.MF

./WebContent/WEB-INF:
total 16
-rw-rw-r--. 1 dave dave  391 Feb  3 11:12 faces-config.xml
drwxrwxr-x. 2 dave dave 4096 Feb  3 11:34 lib
-rw-rw-r--. 1 dave dave 1406 Feb  3 11:33 weblogic.xml
-rw-rw-r--. 1 dave dave 3050 Feb  3 11:12 web.xml

./WebContent/WEB-INF/lib:
total 2300
-rw-rw-r--. 1 dave dave 188671 Oct  5  2009 commons-beanutils-1.7.0.jar
-rw-rw-r--. 1 dave dave 559366 Oct  5  2009 commons-collections-3.1.jar
-rw-rw-r--. 1 dave dave 143602 Oct  5  2009 commons-digester-1.8.jar
-rw-rw-r--. 1 dave dave 112341 Nov 17  2009 commons-el-1.0.jar
-rw-rw-r--. 1 dave dave 207723 Oct  5  2009 commons-lang-2.1.jar
-rw-rw-r--. 1 dave dave  60686 Oct  5  2009 commons-logging-1.1.1.jar
-rw-rw-r--. 1 dave dave  16923 Nov 28  2009 jstl-1.1.0.jar
-rw-rw-r--. 1 dave dave 350460 Apr  4  2012 myfaces-api-1.1.10.jar
-rw-rw-r--. 1 dave dave 693804 Apr  4  2012 myfaces-impl-1.1.10.jar
[dave@dave testFSF11]$ 


Application is accessed http://localhost:7001/testJSF11/faces/index.jsp

To use faces/index.jsp URL  redirect filter is required
/testFSF11/src/coreservlets/FacesRedirectFilter.java ( see CoreServlets tutorial)

Analyze classloading conficts using Weblogic CAT
 (Classloader Analysis Tool)

Conflicts Summary

There are potential conflicts detected and they do not seem to have been resolved. Please review the potential solutions below.

    18 classes are in conflict
    Those classes are found in the following main packages:
        javax.servlet.jsp.*

Suggested Solution

<prefer-application-packages>
   <package-name>javax.servlet.jsp.*</package-name>
</prefer-application-packages>



Conflicts
Resource: <select below>

Below is a list of classes that are marked as potential conflicts. By clicking on a class, further information about this class will be shown in this space. This information includes the alternative locations this class may be found and which classloader actually will load this class.
Classes:

    javax.servlet.jsp.jstl.core.ConditionalTagSupport
    javax.servlet.jsp.jstl.core.Config
    javax.servlet.jsp.jstl.core.LoopTag
    javax.servlet.jsp.jstl.core.LoopTagStatus
    javax.servlet.jsp.jstl.core.LoopTagSupport
    javax.servlet.jsp.jstl.core.LoopTagSupport$1Status
    javax.servlet.jsp.jstl.fmt.LocaleSupport
    javax.servlet.jsp.jstl.fmt.LocalizationContext
    javax.servlet.jsp.jstl.sql.Result
    javax.servlet.jsp.jstl.sql.ResultImpl
    javax.servlet.jsp.jstl.sql.ResultSupport
    javax.servlet.jsp.jstl.sql.SQLExecutionTag
    javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV
    javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV$1
    javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV$PermittedTaglibsHandler
    javax.servlet.jsp.jstl.tlv.ScriptFreeTLV
    javax.servlet.jsp.jstl.tlv.ScriptFreeTLV$1
    javax.servlet.jsp.jstl.tlv.ScriptFreeTLV$MyContentHandler



Classloader tree summary

Application Info

    Application: testJSF11
    Version: <Not Set>
    Module: testJSF11
    Annotation: _auto_generated_ear_@testJSF11


System Classloaders
Type: sun.misc.Launcher$ExtClassLoader
HashCode: 27355241
Classpath:

    /opt/weblogic/jdk160_29/jre/lib/ext/dnsns.jar
    /opt/weblogic/jdk160_29/jre/lib/ext/localedata.jar
    /opt/weblogic/jdk160_29/jre/lib/ext/sunjce_provider.jar
    /opt/weblogic/jdk160_29/jre/lib/ext/sunpkcs11.jar

Type: sun.misc.Launcher$AppClassLoader
HashCode: 13288040
Classpath:

    /opt/weblogic/jdk160_29/lib/tools.jar
    /opt/weblogic/modules/features/weblogic.server.modules_12.1.1.0.jar
    /opt/weblogic/modules/net.sf.antcontrib_1.1.0.0_1-0b2/lib/ant-contrib.jar
    /opt/weblogic/modules/org.apache.ant_1.7.1/lib/ant-all.jar
    /opt/weblogic/patch_ocp371/profiles/default/sys_manifest_classpath/weblogic_patch.jar
    /opt/weblogic/patch_oepe101/profiles/default/sys_manifest_classpath/weblogic_patch.jar
    /opt/weblogic/patch_wls1211/profiles/default/sys_manifest_classpath/weblogic_patch.jar
    /opt/weblogic/wlserver_12.1/common/derby/lib/derbyclient.jar
    /opt/weblogic/wlserver_12.1/server/lib/weblogic.jar
    /opt/weblogic/wlserver_12.1/server/lib/weblogic_sp.jar
    /opt/weblogic/wlserver_12.1/server/lib/webservices.jar
    /opt/weblogic/wlserver_12.1/server/lib/xqrl.jar

Type: weblogic.utils.classloaders.GenericClassLoader
HashCode: 33228044
Classpath:

Application Classloaders
Type: weblogic.utils.classloaders.FilteringClassLoader
HashCode: 8915459
Filter: []
Classpath: empty
Type: weblogic.utils.classloaders.GenericClassLoader
HashCode: 10340792
Classpath:

Type: weblogic.utils.classloaders.FilteringClassLoader
HashCode: 12859001
Filter: [org.apache.*, javax.faces.*, com.sun.faces.*, com.bea.faces.*]
Classpath: empty
Type: weblogic.utils.classloaders.ChangeAwareClassLoader
HashCode: 12896305
Classpath:

    /home/dave/app/myfaces-core-1.1.10-bin/lib/commons-beanutils-1.7.0.jar
    /home/dave/app/myfaces-core-1.1.10-bin/lib/commons-collections-3.1.jar
    /home/dave/app/myfaces-core-1.1.10-bin/lib/commons-digester-1.8.jar
    /home/dave/app/myfaces-core-1.1.10-bin/lib/commons-el-1.0.jar
    /home/dave/app/myfaces-core-1.1.10-bin/lib/commons-lang-2.1.jar
    /home/dave/app/myfaces-core-1.1.10-bin/lib/commons-logging-1.1.1.jar
    /home/dave/app/myfaces-core-1.1.10-bin/lib/jstl-1.1.0.jar
    /home/dave/app/myfaces-core-1.1.10-bin/lib/myfaces-api-1.1.10.jar
    /home/dave/app/myfaces-core-1.1.10-bin/lib/myfaces-impl-1.1.10.jar
    /home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-beanutils-1.7.0.jar
    /home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-collections-3.1.jar
    /home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-digester-1.8.jar
    /home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-el-1.0.jar
    /home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-lang-2.1.jar
    /home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/commons-logging-1.1.1.jar
    /home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/jstl-1.1.0.jar
    /home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/myfaces-api-1.1.10.jar
    /home/dave/workspace/testFSF11/WebContent/WEB-INF/lib/myfaces-impl-1.1.10.jar
    /home/dave/workspace/testFSF11/build/classes



Application start log- using MyFaces

Feb 3, 2013 11:45:31 AM org.apache.myfaces.config.FacesConfigurator feedStandardConfig
INFO: Reading standard config org/apache/myfaces/resource/standard-faces-config.xml
Feb 3, 2013 11:45:31 AM org.apache.myfaces.config.FacesConfigurator feedWebAppConfig
INFO: Reading config /WEB-INF/faces-config.xml
Feb 3, 2013 11:45:31 AM org.apache.myfaces.config.FacesConfigurator logMetaInf
INFO: Artifact 'myfaces-api' was not found.
Feb 3, 2013 11:45:31 AM org.apache.myfaces.config.FacesConfigurator logMetaInf
INFO: Artifact 'myfaces-impl' was not found.
Feb 3, 2013 11:45:31 AM org.apache.myfaces.config.FacesConfigurator logMetaInf
INFO: Artifact 'tomahawk-sandbox' was not found.
Feb 3, 2013 11:45:31 AM org.apache.myfaces.config.FacesConfigurator logMetaInf
INFO: Artifact 'tomahawk' was not found.
Feb 3, 2013 11:45:31 AM org.apache.myfaces.config.FacesConfigurator logMetaInf
INFO: Artifact 'tobago-core' was not found.
Feb 3, 2013 11:45:31 AM org.apache.myfaces.config.FacesConfigurator handleSerialFactory
INFO: Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
Feb 3, 2013 11:45:31 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS' found, using default value true
Feb 3, 2013 11:45:31 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.RENDER_VIEWSTATE_ID' found, using default value true
Feb 3, 2013 11:45:31 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getBooleanInitParameter
INFO: No context init parameter 'org.apache.myfaces.STRICT_XHTML_LINKS' found, using default value true
Feb 3, 2013 11:45:31 AM org.apache.myfaces.shared_impl.config.MyfacesConfig getLongInitParameter
INFO: No context init parameter 'org.apache.myfaces.CONFIG_REFRESH_PERIOD' found, using default value 2
Feb 3, 2013 11:45:31 AM org.apache.myfaces.shared_impl.config.MyfacesConfig createAndInitializeMyFacesConfig
INFO: Tomahawk jar not available. Autoscrolling, DetectJavascript, AddResourceClass and CheckExtensionsFilter are disabled now.
Feb 3, 2013 11:45:31 AM org.apache.myfaces.shared_impl.config.MyfacesConfig createAndInitializeMyFacesConfig
INFO: Starting up Tomahawk on the MyFaces-JSF-Implementation
Feb 3, 2013 11:45:31 AM org.apache.myfaces.webapp.StartupServletContextListener initFaces
INFO: ServletContext '/home/dave/workspace/testFSF11/WebContent' initialized.
Feb 3, 2013 11:45:31 AM org.apache.myfaces.webapp.StartupServletContextListener initFaces
INFO: MyFaces already initialized
Feb 3, 2013 11:45:31 AM org.apache.myfaces.webapp.StartupServletContextListener initFaces
INFO: ServletContext '/home/dave/workspace/testFSF11/WebContent' initialized.


 

Force precompilation of JSP  in weblogic.xml descriptor

 
    <jsp-descriptor>
         <precompile>true</precompile> 
        <precompile-continue>true</precompile-continue>
        <keepgenerated>true</keepgenerated>
        <page-check-seconds>-1</page-check-seconds>
        <verbose>true</verbose>
    </jsp-descriptor>

 

JSP files precompilation with wlappc

Requires separate classpath for libs in WEB-INF/lib
<project name="Appc" default="appc" basedir="./">

    <target name="appc" description="Packages the WAR file">
        <!-- Precompile JSP pages using appc -->
        <echo message="Precompile JSP pages using appc in ${assemble.war}" />
        <path id="wlappc.classpath">
            <fileset dir="${env.WL_HOME}/server/lib">
                <include name="weblogic.jar" />
            </fileset>
        </path>
        <path id="compile.classpath">
            <fileset dir="${assemble.war}/WEB-INF/lib">
                <include name="*.jar" />
            </fileset>
        </path>

        <echo message="${toString:wlappc.classpath}" />
        <taskdef name="wlappc" classname="weblogic.ant.taskdefs.j2ee.Appc"
            classpathref="wlappc.classpath" />
        <wlappc verbose="true" forcegeneration="true" source="${assemble.war}"
            classpathref="compile.classpath">

        </wlappc>

    </target>


</project>

wlappc Ant Task Options

http://docs.oracle.com/cd/E13222_01/wls/docs81/programming/topics.html
 Ant task options specific to wlappc. For the most part, these options are the same as weblogic.appc options. However, there are a few differences.




          
Option



        

          
Description



        

          
print



        

          
Prints the standard usage message.



        

          
version



        

          
Prints appc version information.



        

          
output <file>



        

          
Specifies an alternate output archive or directory. If not set, the output is placed in the source archive or directory.



        

          
forceGeneration



        

          
Forces generation of EJB and JSP classes. Without this flag, the classes will not be regenerated unless a checksum indicates that it is necessary.



        

          
lineNumbers



        

          
Adds line numbers to generated class files to aid in debugging.



        

          
basicClientJar



        

          
Does not include deployment descriptors in client JARs generated for EJBs.



        

          
idl



        

          
Generates IDL for EJB remote interfaces.



        

          
idlOverwrite



        

          
Always overwrites existing IDL files.



        

          
idlVerbose



        

          
Displays verbose information for IDL generation.



        

          
idlNoValueTypes



        

          
Does not generate valuetypes and the methods/attributes that contain them.



        

          
idlNoAbstractInterfaces



        

          
Does not generate abstract interfaces and methods/attributes that contain them.



        

          
idlFactories



        

          
Generates factory methods for valuetypes.



        

          
idlVisibroker



        

          
Generates IDL somewhat compatible with Visibroker 4.5 C++.



        

          
idlOrbix



        

          
Generates IDL somewhat compatible with Orbix 2000 2.0 C++.



        

          
idlDirectory <dir>



        

          
Specifies the directory where IDL files will be created (default: target directory or JAR)



        

          
idlMethodSignatures <>



        

          
Specifies the method signatures used to trigger IDL code generation.



        

          
iiop



        

          
Generates CORBA stubs for EJBs.



        

          
iiopDirectory <dir>



        

          
Specifies the directory where IIOP stub files will be written (default: target directory or JAR)



        

          
keepgenerated



        

          
Keeps the generated .java files.



        

          
compiler <javac>



        

          
Selects the Java compiler to use.



        

          
debug



        

          
Compiles debugging information into a class file.



        

          
optimize



        

          
Compiles with optimization on.



        

          
nowarn



        

          
Compiles without warnings.



        

          
verbose



        

          
Compiles with verbose output.



        

          
deprecation



        

          
Warns about deprecated calls.



        

          
normi



        

          
Passes flags through to Symantec's sj.



        

          
runtimeflags



        

          
Passes flags through to Java runtime



        

          
classpath <path>



        

          
Selects the classpath to use during compilation.



        

          
advanced



        

          
Prints advanced usage options.