WebSphere and Java 1.8 Upgrade causes java.lang.AssertionError - ant

Recently I upgraded my WAS application to use JDK 1.8 provided by IBM. But when I try to build my application using Ant. I see the error
BUILD FAILED
C:\Workspace\trunk\APPInstallation\build.xml:1132: The following error occurred while executing this line:
java.lang.AssertionError: org.xml.sax.SAXParseException: Failed to read external schema document "jar:file:/C:/IBM/WebSphere/AppServer/plugins/com.ibm.jaxb.tools.jar!/com/ibm/jtc/jax/tools/xjc/reader/xmlschema/bindinfo/xjc.xsd", because "jar" access is not allowed.
Total time: 29 seconds
I Googled a bit about it, and found that i have to create a jaxp.properties file in the jre/lib folder, which I did, with the value:
javax.xml.accessExternalSchema=all
but it still doesn't work. Any help with this would be welcome! This is area of the ant file where the error comes from:
<wsimport wsdl="${build.dir}/src/${wsdl.file}" destdir="build" wsdlLocation="file:/WEB-INF/wsdl/${wsdl.file}" failonerror="true">
<depends dir="${build.dir}/src" includes="*.xsd" />
<produces dir="${lib.dir}" includes="${webservice.name}${webservice.component}WSBeans.jar"/>
</wsimport>

Do nesting any of these inside your wsimport task resolve it?
<xjcarg value="-Djavax.xml.accessExternalSchema=all"/>
<arg value="-Djavax.xml.accessExternalSchema=all"/>
<arg value="-J-Djavax.xml.accessExternalSchema=all"/>

Related

log4j.ConfigurationFile configuration in ant build for jetty

We trigger jetty through ant target as below
<target name="jettysh" depends="init">
<exec executable="${JETTY_HOME}/bin/jetty.sh" failonerror="true">
<env key="JAVA_OPTIONS"
value="-server -d64 ${x} ${y} ${z} ${l} -Dsettings.path=${p.path} -Dlog4j.configuration=file:///${dpath}/conf/sample.xml -Djetty.secure.port=${JETTY_SECURE_PORT} -Dapp.dir=${app.dir}"/>
</exec>
</target>
In this we pass -Dlog4j.configuration path in the older log4j 1.X version as we are migrating to newer version we are passing the new configuration -Dlog4j2.configurationFile but the logs are not getting generated .
And also we are not seeing any log files getting generated that means that log configuration itself is not picked
Help is very much appreciated as it is a time bound one.
Jetty Hightide 7.x does not have support for log4j2 at the server level.
Using that ancient EOL version of Jetty, you only have support for log4j2 within your webapps.
That means you have to put the log4j2 jars and it's configuration files in your WAR file.

com/ibm/etools/ejbdeploy/EjbDeploy error websphere 7

I got the build working by adding user.install.root and set up the profile value in taskdef,
<taskdef name="wasejbjar" classname="com.ibm.websphere.ant.tasks.WsEjbDeploy" classpath="D:\IBM\WebSphere\AppServer\plugins\com.ibm.ws.runtime.jar;D:\IBM\WebSphere\AppServer\profiles\AppSrv01\;" >
</taskdef>
<wasejbjar inputJar="${build.root.dir}/ejbtemp/${undeployed.ejb.name}-TMP.jar" wasHome="D:\IBM\WebSphere\AppServer\profiles\AppSrv01\" workingDirectory="${build.root.dir}/ejbtemp" outputJar="${build.lib.dir}/${undeployed.ejb.name}.jar" classpathref="all.ejb.path" noValidate="false" noWarnings="false" noInform="true" trace="false" quiet="false"/>
But even now I get the following error as:
[wsejbdeploy] java.lang.NoClassDefFoundError: com/ibm/etools/ejbdeploy/EJBDeploy [wsejbdeploy] Caused by: java.lang.ClassNotFoundException: com.ibm.etools.ejbdeploy.EJBDeploy
Can anybody tell me why this is happening?
Referencing arbitrary JARs from WAS_HOME/plugins is not supported. I believe the supported use of the Ant task is to use the WAS_HOME/bin/ws_ant script. (Unfortunately, it's a quite old version of Ant.)
I found the issue and resolved it. I marked the jar file as _old, which resolved the issue.
The path is as follows, D:\IBM\WebSphere\AppServer\java\lib\ibmorbtools_old.jar.
This is because in one of the forum, i read that the ibmorbtools.jar in Java conflict with websphere.
Thanks for all.

Ant deploy to tomcat 7

I have changed my Tomcat Server from version 6 to 7 and now my ant deploy fails.
At first i had my ant build like the following and got a 403 error
<taskdef resource="org/apache/catalina/ant/catalina.tasks" classpathref="x.classpath" />
<target name="tomcatdeploy" depends="tomcatundeploy,war">
<deploy url="http://localhost/manager/html" username="x" password="x" path="/xx" war="file:x.war"/>
</target>
I found several sources on the internet an changed the manager/html to manager/text and added the roles manager-script and admin-script in the tomcat-user file.
The error I am getting now is
java.net.HttpRetryException: cannot retry due to server authentication, in streaming mode
I found that this may be because of the size of the .war file which i deploy which is about 250M, but i didn't find a solution how to deploy it to tomcat 7 from ant.
I finally found a comprehensive post about this Problem:
http://paulgrenyer.blogspot.co.at/2011/11/catalina-ant-for-tomcat-7.html

Could not create task or type: getProjectData from Ant

I am trying to run an Ant task from within IBM RSA IDE using Ant build ...
I get the following error message:
BUILD FAILED
build.xml:21: Could
not create task or type of type: getProjectData.
Ant could not find the task or a class this task relies upon.
This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
- You have misspelt 'getProjectData'.
Fix: check your spelling.
- The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
- The task is an Ant optional task and the JAR file and/or libraries
implementing the functionality were not found at the time you
yourself built your installation of Ant from the Ant sources.
Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
task and make sure it contains more than merely a META-INF/MANIFEST.MF.
If all it contains is the manifest, then rebuild Ant with the needed
libraries present in ${ant.home}/lib/optional/ , or alternatively,
download a pre-built release version from apache.org
- The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
- The task is not an Ant core or optional task
and needs to be declared using <taskdef>.
- You are attempting to use a task defined using
<presetdef> or <macrodef> but have spelt wrong or not
defined it at the point of use
Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the
classpath
Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.
Here's the Ant buildfile:
<!-- Get property locationName. -->
<target name="config">
<echo message="${ear.project.name}" />
<getProjectData projectName="${ear.project.name}" />
</target>
I am not quite sure what the problem is here because the error message seems not helpful. Any suggestions?
I believe getProjectData is an IBM extension to ant. Like you, I had a similar error, but I was able to get it working after ensuring the Run in the same JRE as the workspace option was enabled (which you can find by right-clicking the build file, run-as, Ant Build..., and selecting the option on the JRE tab).
I discovered the solution on the IBM info center:
The Run in the same JRE as the workspace option enables the classpath
of the workbench to access the additional Ant tasks that perform
operations that are specific to the workbench, such as projectImport,
projectBuild, workspaceBuild, ejbDeploy, or earExport. If your Ant
build script uses any Ant tasks that perform workbench operations,
verify that you selected the Run in the same JRE as the workspace
option; otherwise you might get the following error message in the
Console view:
Problem: failed to create task or type <Ant task> Cause:
The name is undefined.
The build file I used looked like this:
<?xml version="1.0"?>
<project name="Test" default="config" basedir=".">
<target name="config">
<getProjectData Basedir="${basedir}" />
<echo message="getProjectData: projectName=${projectName}
nature=${natureName}
workspace=${workspaceName}
basedir=${basedir}" />
</target>
</project>
And output:
Buildfile: C:\DATA\java\workspace\test-java\build.xml
config:
[getProjectData] Setting projectName=test-java
[getProjectData] Retrieved following Project Data :
[getProjectData] workspaceName=C:\DATA\java\workspace
[getProjectData] natureName=Java
[echo] getProjectData: projectName=test-java
nature=Java
workspace=C:\DATA\java\workspace
basedir=C:\DATA\java\workspace\test-java
BUILD SUCCESSFUL
Total time: 78 milliseconds

Ant fails with liquibase path

I am trying to get phing to work nice with liquibase. But pPing gives this illustrous error (which I honestly can't find online)
Execution of target "update-database" failed for the following reason: PathElement (unknown) doesn't support the 'location' attribute.
BUILD FAILED
PathElement (unknown) doesn't support the 'location' attribute.
Total time: 0.1206 seconds
the specific commands for that are:
<path id="liquibasepath">
<pathelement location="${basedir}/install/lib/liquibase.jar" />
<pathelement location="${basedir}/install/lib/jdbc-mysql.jar" />
</path>
I tried searching online but there is no good documentation for using phing with liquibase. and the error's neither turn up decent results.
Try using the "path" attribute in pathelement instead of location
The correct answer should be: This is ant, not phing. I was trying to run it with the wrong program. (there really should be some indication of this in build files ;)).
The person who commented got me on hte right track, can't accept that as an answer tho.

Resources