Ant Build Script Java Config Web project - java

I am using spring 4 in my dynamic web project which is fully annotation based java config (there is no web.xml). When I try to package with my ant build. It's giving error webapp\WEB-INF\web.xml does not exist.
My build script is like bellow:
<war destfile="${maven.build.dir}/${maven.build.finalName}.war"
compress="true"
needxmlfile="false"
>
......
......
</war>
What is the way to solve this error?

Add 'needxmlfile' attribute and set it to false.
For further reference Ant War Task

Related

How to read Config in vertx 4.3.1?

I am upgrading vertx.version 3.8.1 to 4.3.1
In this procress after building the jar and trying to run it, I am getting the error
groovy.lang.MissingPropertyException: No such property
For running the jar I am using the syntax
java -jar <jar path> -conf <conf-path.json>
This syntax is working for 3.8.1 but not for 4.3.1
My current config file is in /conf/config.json path
In the code I am trying to read the config as
def serverConfig = vertx.getOrCreateContext().config()["serverConfig"]
The config fie contains the property serverConfig and works fine for 3.8.1
The code is in Groovy.
Could you please help me to understand what needs to change here?

WebLogic Scripting Tool - Ant Task Error: java.lang.RuntimeException: Could not find the OffLine WLST class

The goal here is to connect to our dev instance and restart a managed server in the WebLogic console. I've attempted to reboot the managed server using the wlserver task but ran into a number of issues when attempting to start the server. I'm now attempting to use the wlst tool which I'm able to successfully reboot via command line. For some reason, the following ant task is unable to find the weblogic.jar file located in my weblogic server directory. I could use a fresh set of eyes to see where the issue is coming from. I'm currently receiving the following error:
"Could not find the OffLine WLST class"
Here is a snippet of my ant task:
<property name="weblogic.home" value="C:\wls12210"/>
<target name="Restart OACore">
<path id="weblogic.lib.path">
<fileset dir="${weblogic.home}\wlserver\server\lib\">
<include name="web*.jar"/>
</fileset>
</path>
<taskdef name="wlst" classname="weblogic.ant.taskdefs.management.WLSTTask" classpathref="weblogic.lib.path"/>
<wlst debug="true" executeScriptBeforeFile="false" failOnError="true">
<script>
connect('username','password','t3://usnowebldev01:7001')
shutdown('StandardRods')
start('StandardRods')
</script>
</wlst>
</target>
Any suggestions?
The reason for the error was a dependency conflict in the ant scripts property settings. Issue resolved.

adding a Main JSF project's Classes to another JSF project's Properties/Libraries

I am new with JSFUnit testing (with Netbeans7.3, JSF2.1, JDK7) and I was wondering if there a way where I can add the classes from my Main project into my JSFUnit project, well I was told to separate my JSFUnit project from the main one.
I have tried Properties/Libraries/Add Project, but it cause an error stating that the project cannot be added since it's not created using an Ant Script.
I have added the Main's classes into the properties->Libraries->Add Jar/Folder of JSFUnit project, but during the runtime the classes cannot be found which resulted to this error in the localhost ServletTestRun:
biz/dtit/geenie/controller/AccountController
java.lang.NoClassDefFoundError:
ebiz/dtit/geenie/controller/AccountController
.
.
.
Caused by: java.lang.ClassNotFoundException: biz.dtit.geenie.controller.AccountController
.
.
.
.
.
.
Caused by: java.lang.ClassNotFoundException: biz.dtit.geenie.controller.AccountController
.
.
.
I have just found a way to add classes to another web project and it worked on my side.
First, is to create a .jar file of your main project's classes and add it to your JSFUnit's project properties. You can't create a .jar file for a web project using netbeans IDE, so locate your build.xml from your project's folder and add this:
<target name="-post-compile">
<jar destfile="${basedir}/dist/my_web_app.jar">
<fileset dir="${basedir}/build/web/WEB-INF/classes">
</fileset>
</jar>

How to enable debug info in ant4eclipse build using buildJdtProject?

I have tried setting different properties and attributes (debug="true"), but it didn't work.
This is from our build.xml (just showing the parts relating to the build step):
<!-- Environment holen -->
<property environment="env" />
<!-- Target: all -->
<target name="all" depends="build, test, export">
</target>
<!-- Target: build -->
<target name="build">
<ant4eclipse:executeProjectSet workspaceDirectory="${env.WORKSPACE}" teamprojectset="${env.WORKSPACE}\${env.JOB_NAME}\projectSet.psf">
<ant4eclipse:forEachProject filter="(executeProjectSet.org.eclipse.jdt.core.javanature=*)">
<buildJdtProject workspaceDirectory="${env.WORKSPACE}" projectName="${executeProjectSet.project.name}" targetLevel="1.6" />
</ant4eclipse:forEachProject>
</ant4eclipse:executeProjectSet>
</target>
Detailed description:
An internal project consists of a large number of classes and some applications, all written in Java.Everything runs just fine when started from within Eclipse.
After each commit to our SVN repository, the project is built using ant4eclipse on our Hudson installation and if tests pass, a zip is automatically created and copied to a file server to be used by simply unpacking and starting the supplied startup batch script.
Now last week a colleague informed me that the version from the file server doesn't work for him. I checked and am able to reproduce the problem - loading data from a database doesn't work. No exception is shown in the log/console and I have no idea what goes wrong. Everything works when started from within eclipse (same vmargs, same JVM etc.).
When trying to connect the debugger, it seems like no debug info is present ("line numbers missing" etc.). So I now need to find out how to convince ant4eclipse to include debug infos.
In the meantime, I found out how to do this myself: I added a default compiler options file like this (attribute defaultCompilerOptionsFile):
<!-- Target: build -->
<target name="build">
<ant4eclipse:executeProjectSet workspaceDirectory="${env.WORKSPACE}" teamprojectset="${env.WORKSPACE}\${env.JOB_NAME}\projectSet.psf">
<ant4eclipse:forEachProject filter="(executeProjectSet.org.eclipse.jdt.core.javanature=*)">
<buildJdtProject
workspaceDirectory="${env.WORKSPACE}"
projectName="${executeProjectSet.project.name}"
targetLevel="1.6"
defaultCompilerOptionsFile="compilerOptions.prefs"/>
</ant4eclipse:forEachProject>
</ant4eclipse:executeProjectSet>
</target>
compiler options file is just a copy of .metadata\.plugins\org.eclipse.core.runtime\.settings\org.eclipse.jdt.core.prefs inside the workspace. Make sure to set the desired options inside the file:
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
I haven't tested if it works if you create a compiler options file that just contains the 3 lines above.

Adding classpath to jetty running in maven integration-test

I'm trying to set up integration tests for a Maven project that produces a war file. (As seen here http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin/.) However I the war file requires a bunch of .properties files on the classpath, that I don't want to bundle in the war.
Is there a way (preferably through plugin configuration) to add a folder to the classpath used by jetty?
I Googled this and found http://markmail.org/message/awtqrgxxttra3uxx but this, as far as I can tell, does not actually work at all. The .properties files are not found.
This should be possible using the webAppConfig configuration element (sample below taken from this thread):
<webAppConfig>
<contextPath>/nportal</contextPath>
<!-- All I want to do here is add in the /etc/jetty/classes for runtime files. For some reason I have to also add back in the /target/classes directory -->
<extraClasspath>${basedir}/target/classes/;${basedir}/etc/jetty/classes/</extraClasspath>
</webAppConfig>
If you find that the above solution doesn't work for you, consider including the test classpath into your Jetty configuration.
<configuration>
<useTestClasspath>true</useTestClasspath>
...
</configuration>
This will then allow you to place all manner of resources/classes on the test classpath and have them visible to the Jetty server without them creeping into the production code.
You can place your additional configuration files under /src/test/resources and set a property <useTestScope>true</useTestScope> in the plugin configuration as specified here:
useTestScope
If true, the classes from testClassesDirectory and dependencies of scope "test" are placed first on the classpath. By default this is false.

Categories

Resources