Build.xml for jsf 2.0 with weblogic 12c - jsf-2

I am new to jsf and jsp.
I know weblogic 12 c comes with jsf 2.0 but when ever i try to deloy my application, i got an stack error., i guess this is due to my build.xml which can not get my jars and wars from weblogic server,
Below is the code of build.xml,please help me asap, will be very thankful.
<property name="weblogic.home" value="/bea/wlserver_12.1/"/>
<path id="WebLogic System Libraries.libraryclasspath">
<pathelement location="../../../../bea/wlserver_12.1/server/lib/api.jar"/>
<pathelement location="../../../../bea/wlserver_12.1/server/lib/wls-api.jar"/>
<pathelement location="../../../../bea/wlserver_12.1/common/deployable-libraries/jsf-2.0.war"/>
<pathelement location="../../../../bea/wlserver_12.1/common/deployable-libraries/jstl-1.2.war"/>
</path>
<path id="Security_Search.classpath">
<pathelement location="build/classes"/>
<path refid="WebLogic System Libraries.libraryclasspath"/>
</path>
<target name="init">
<mkdir dir="build/classes"/>
<mkdir dir="dist" />
</target>
<path id="compile.classpath">
<fileset dir="${weblogic.home}/common/deployable-libraries">
<include name="*.war"/>
</fileset>
<pathelement location="../../../../bea/wlserver_12.1/common/deployable-libraries/jsf-2.0.war"/>
</path>
<target name="compile" depends="init" >
<javac destdir="build/classes" debug="true" srcdir="src">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="war" depends="compile">
<war destfile="dist/security_Search_JSF.war" webxml="WebContent/WEB-INF/web.xml">
<fileset dir="WebContent">
<exclude name="*.jar"/>
</fileset>
<classes dir="build/classes"/>
</war>
</target>
<target name="clean">
<delete dir="dist" />
<delete dir="build/classes"/>
</target>
<target name="build"/>
</project>
TTP:101064][WebAppModule(security_Search_JSF:security_Search_JSF.war)] Error parsing descriptor in Web appplication "C:\bea_deploy\security_Search_JSF.war" weblogic.application.ModuleException: VALIDATION PROBLEMS WERE FOUND problem: cvc-complex-type.2.3: Element 'weblogic-web-app#http://xmlns.oracle.com/weblogic/weblogic-web-app' with element-only content type cannot have text content.: at weblogic.servlet.internal.WebAppModule.loadDescriptor(WebAppModule.java:1494) at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:253) at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:636) at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162) at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:74) at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84) at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:312) at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:325) at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:378) at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:35) at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237) at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:48) at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158) at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:96) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:229) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747) at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216) at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545) a
now i am getting this error.. please help,,,,
Its error in weblogic.. please

About the original error, it states that your weblogic.xml file has an invalid format.
Here's a sample of a valid weblogic.xml that references the JSF 2.0 shared library you want to use:
<?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>store</wls:context-root>
<wls:library-ref>
<wls:library-name>jsf</wls:library-name>
<wls:specification-version>2.0</wls:specification-version>
<wls:exact-match>true</wls:exact-match>
</wls:library-ref>
If you already solved this error, please provide details on the next one - is it happening during deployment? Can you print the whole stacktrace?
Cheers,
Fabio

Related

XJC with Krasa Plugin

Hello i get a build error when i execute the following ant-script. Can somebody help me to resolve the problem?
ANT output:
Buildfile: D:\workspace\Webformular2\WebContent\WEB-INF\XSD-Pfad.ant
[delete] Deleting directory D:\workspace\Webformular2\WebContent\WEB-INF\src
[mkdir] Created dir: D:\workspace\Webformular2\WebContent\WEB-INF\src xjc:
[xjc] Consider using <depends>/<produces> so that XJC won't do unnecessary compilation
[xjc] Compiling file:/D:/workspace/Webformular2/WebCo ntent/WEB-INF/jaxb/antragsdaten.xsd and others
BUILD FAILED D:\workspace\Webformular2\WebContent\WEB-INF\XSD-Pfad.ant:11: java.lang.NoClassDefFoundError: javax/validation/constraints/NotNull
Ant script
<project default="xjc">
<delete dir="src"/>
<mkdir dir="src" />
<target name="xjc" description="JAXB Generation">
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath>
<fileset dir="lib" includes="*.jar" />
</classpath>
</taskdef>`
`
<xjc destdir="src" extension="true">
<schema dir="jaxb" includes="*.xsd"/>
<arg line="
-XJsr303Annotations
-XReplacePrimitives"/>
</xjc>
</target>
</project>`
------- Ant-Skript ---------
<project default="xjc">
<delete dir="src"/>
<mkdir dir="src" />
<target name="xjc" description="JAXB Generation">
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath>
<fileset dir="lib" includes="*.jar" />
</classpath>
</taskdef>
<xjc destdir="src" extension="true">
<schema dir="jaxb" includes="*.xsd"/>
<arg line="
-XJsr303Annotations
-XReplacePrimitives"/>
</xjc>
</target>
</project>
You're missing the "validation-api.jar" in your lib directory.
Reference:
Maven Central search for missing class "javax/validation/constraints/NotNull"

ant build generating same class files while packaging the war file

Below is the Ant script i am trying in GAE project but when i look into the war file i see two class for each java file.
Just a fyi, WAR file created i open in winrar but even when i extract it winrar keeps on asking me to either replace existing file message. Not sure how even same file name & extension is present in one folder. Also i checked the "dist" & "classes" folder i does not have duplicate file.
<?xml version="1.0" ?>
<project name="AntExample1" default="war">
<path id="compile.classpath">
<fileset dir="war/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="init">
<mkdir dir="build/classes"/>
<mkdir dir="dist" />
</target>
<target name="compile" depends="init" >
<javac destdir="build/classes" debug="true" srcdir="src">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="war" depends="compile">
<war destfile="dist/AntExample.war" webxml="war/WEB-INF/web.xml">
<fileset dir="war"/>
<lib dir="war/WEB-INF/lib"/>
<classes dir="build/classes"/>
</war>
</target>
<target name="clean">
<delete dir="dist" />
<delete dir="build" />
</target>
</project>

Creating Ant classpath out of project names

In an ant build script I have a list of projects we are depending on. I need to create a classpath for compilation.
I have:
included.projects=ProjectA, ProjectB
and I need:
included.project.classpath=../ProjectA/bin, ../ProjectB/bin
current code:
<echo message="${included.projects}" />
<pathconvert property="included.projects.classpath" dirsep="," >
<map from="" to="../"/>
<path location="${included.projects}"/>
</pathconvert>
<echo message="${included.projects.classpath}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6">
<classpath>
<pathelement path="${classpath}" />
<dirset includes="${included.projects.classpath}" />
</classpath>
</javac>
I've tried it with explicit declaration too, but didn't work:
<path id="modules.classpath">
<fileset dir="../ModuleA/bin" />
<fileset dir="../ModuleB/bin"/>
</path>
<path id="libraries.classpath">
<fileset dir="lib" includes="*.jar"/>
</path>
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6">
<classpath refid="libraries.classpath" />
<classpath refid="modules.classpath" />
</javac>
I'm curious, what is the problem with explicit declaration code, and is it possible to solve with the comma-separated-string to classpath solution.
I think it would be simpler to explicity declare the classpath at the top of your build as follows:
<path id="compile.path">
<fileset dir="../ProjectA/bin" includes="*.jar"/>
<fileset dir="../ProjectB/bin" includes="*.jar"/>
</path>
Used as follows:
<javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6">
<classpath>
<path refid="compile.path"/>
<pathelement path="${classpath}" />
</classpath>
</javac>
Note:
I read your question again and just realised that you're not using jar files built by the other projects, are you? .... Not a great idea....

Build.xml issue

Selenium - ANT -TestNG
I have written a build.xml, where it produces a error stating " classname attribute of taskdef element is undefined "
Here is my build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name ="AutomationScripts" default="test" basedir=".">
<echo message ="Testing selenium server... Plz wait"/>
<target name="startServer">
<echo message ="Start selenium server... Plz wait"/>
<java jar="..\lib\selenium-server-standalone-2.19.0.jar" fork="true">
<jvmarg value="-Dhttp.proxyHost=192.168.0.200"/>
<jvmarg value="-Dhttp.proxyPort=3128"/> </java>
<echo message ="Started selenium server"/>
</target>
<target name="test" depends="startServer">
<echo message="Test run. Please wait"/>
<mkdir dir="out" />
<java classname="RosettastoneMain" classpath="..\AutomationScripts\bin"
dir="C:\Program Files\Java\jdk1.6.0_11\bin">
<classpath>
<fileset dir="..\AutomationScripts\lib" includes="*.*"/>
</classpatha></java>
<taskdef name="testng" classpath="org.testng.TestNG"> ---------> It produces
error in this stmt
<classpath>
<pathelement location="../lib/testng-6.2.jar"/>
</classpath>
</taskdef>
<property name="testng.output.dir" value="testngOutput"/>
<path id="classes">
<fileset dir="../lib">
<include name="*.jar"/>
</fileset>
<pathelement location="${bin.dir}"/>
</path>
<mkdir dir="${testng.output.dir}"/>
<testng outputdir="${testng.output.dir}" classpathref="classes">
<xmlfileset dir="." includes="testng.xml"/>
</testng> </target>
<target name="stopServer">
<echo message="stop selenium server. Plz wait"/>
<get taskname="selenium-shutdown"
src="http://localhost:4444/selenium-server-standalone-2.0rc2/driver/?cmd=shutDown"
dest="./out/sever.stop.status.txt" ignoreerrors="true"/>
</target>
</project>
Can any one help me out
thanks in advance
You need to specify the class implementing the data type in the 'classname' attribute.
According to the Ant taskdef documentation (and more specifically typedef), this task has two required attributes - 'name' and 'classname', unless 'file' or 'resource' have been specified. The attribute 'classpath' only defines the locations where the class specified in 'classname' can be found.

Generate manifest class-path from <classpath> in Ant

In the build file below, the jar target refers to the jar.class.path property for the manifest class-path. The compile target refers to project.class.path
There is redundancy here, because jar.class.path and project.class.path are very similar. They must be both updated when libraries are added, which can be a pain if the list of libraries gets very long. Is there a better way? Any solution must be cross-platform and always use relative paths.
Edit:
It should generate the JAR classpath from a fileset and not the other way around, so I can use wildcards to e.g. include all JAR files in a directory.
<?xml version="1.0"?>
<project name="Higgins" default="jar" basedir=".">
<property name="jar.class.path" value="lib/forms-1.2.0.jar lib/BrowserLauncher.jar"/>
<path id="project.class.path">
<pathelement location="build"/>
<fileset dir="lib">
<include name="forms-1.2.0.jar"/>
<include name="BrowserLauncher.jar"/>
</fileset>
</path>
<target name="prepare">
<mkdir dir="build"/>
</target>
<target name="compile" depends="prepare" description="Compile core sources">
<javac srcdir="src"
includes="**"
destdir="build"
debug="true"
source="1.5">
<classpath refid="project.class.path"/>
</javac>
</target>
<target name="jar" depends="compile" description="Generates executable jar file">
<jar jarfile="higgins.jar">
<manifest>
<attribute name="Main-Class" value="nl.helixsoft.higgins.Main"/>
<attribute name="Class-Path" value="${jar.class.path}"/>
</manifest>
<fileset dir="build" includes="**/*.class"/>
<fileset dir="src" includes="**/*.properties"/>
</jar>
</target>
</project>
<path id="build.classpath">
<fileset dir="${basedir}">
<include name="lib/*.jar"/>
</fileset>
</path>
<pathconvert property="manifest.classpath" pathsep=" ">
<path refid="build.classpath"/>
<mapper>
<chainedmapper>
<flattenmapper/>
<globmapper from="*.jar" to="lib/*.jar"/>
</chainedmapper>
</mapper>
</pathconvert>
<target depends="compile" name="buildjar">
<jar jarfile="${basedir}/${test.jar}">
<fileset dir="${build}" />
<manifest>
<attribute name="Main-Class" value="com.mycompany.TestMain"/>
<attribute name="Class-Path" value="${manifest.classpath}"/>
</manifest>
</jar>
</target>
For further information check out this article.
Assuming Ant 1.7 or above, you can use the manifestclasspath task.
<path id="dep.runtime">
<fileset dir="./lib">
<include name="**/*.jar" />
</fileset>
</path>
<property name="dep_cp" value="${toString:dep.runtime}" />
<target name="default">
<manifestclasspath property="manifest_cp" jarfile="myjar.jar">
<classpath refid="dep.runtime" />
</manifestclasspath>
<echo message="Build Classpath: ${dep_cp}" />
<echo message="Manifest Classpath: ${manifest_cp}" />
</target>
If you just want a common subpath shared between two (or more) paths, that is easy to do:
<path id="lib.path>
<fileset dir="lib">
<include name="forms-1.2.0.jar"/>
<include name="BrowserLauncher.jar"/>
</fileset>
</path>
<path id="project.class.path">
<pathelement location="build"/>
<path refid="lib.path"/>
</path>
<property name="jar.class.path" refid="lib.path"/>
EDIT Sorry, I misunderstood the question. Try this:
<property name="jar.class.path" value="lib/forms-1.2.0.jar lib/BrowserLauncher.jar"/>
<path id="project.class.path">
<pathelement location="build"/>
<fileset dir="." includes="${jar.class.path}"/>
</path>
You can use <pathconvert> to convert a path (which can contain a fileset) into a plain string. You'll likely need to <echo> that string to a file, use either <replace> or <replaceregexp> to chop the leading path bits, then finally use <loadfile> to load the manipulated string into the final property.
Implementation left as an exercise to the reader.

Resources