We help IT Professionals succeed at work.

errors while trying to build the application

gkmadhav asked
i have application in struts for which i have created a build file, when i am trying to run build.xml i am getting this error messsage.

 Launching(Error: Specified VM install not found: type standard VM, name jre1.6.0_01)

 help me fix this problem and any further problems relating to this after.
Watch Question

Are you running ant from inside Eclipse? If so, try this:

  * Right-click on the build.xml file and select Run as -> Ant build ... (note the three dots!)
  * This displays a dialog -select the "JRE" tab.
  * Click on "Run in the same JRE as the workspace"

Alternatively, try playing with the JRE settings to get one that works for you - this depends on which JRE's you have installed on your machine.


i was able to run it following your procedure but now i got this compile error after running it

[javac] bad class file: C:\Program Files\Java\jre1.6.0_01\lib\rt.jar(java/lang/Object.class)
       [javac] class file has wrong version 49.0, should be 48.0

OK, sounds like you're mixing JREs. Eclipse has probably one and ant is being executed using another. Check your environment variables - do you have JAVA_HOME pointing to the correct JRE? Do you have your JRE directory on the PATH? What's your CLASSPATH set to? These should all match what's in Eclipse, or you should change the properties of your project to use the other JRE (Preferences->Java).


I am not able quite understand what you are saying but to some extent and here is my classpath set to in the environment variable and there is no JAVA_HOME set in there

CLASSPATH     .;C:\Program Files\Java\jre1.6.0_01\lib\ext\QTJava

QTJava     C:\Program Files\Java\jre1.6.0_01\lib\ext

if you want i will even let you know what preferences i have set in eclipse, i mean installed JRES and also properties of the application like the java build path
>> class file has wrong version 49.0, should be 48.0

This error will come, when there is mismatch in the libraries being read by eclipse, and the version of compiler being used..

The compiler versions should be consistent(should be same) in all the following places...

1) Window > Preferences > JAVA >  BuildPath > Classpath Variable > 
   a) value of JAVA_HOME variable should point to correct compiler..
   b) value of JRE_LIB variable should point to correct rt.jar (which will be inside jre\lib)
2) Window > Preferences > JAVA > Compiler
   a) Value of Compiler Compliance level should be correct.
3) Right-click on the build.xml file > Run as > (Ant build ...) > JRE
   a) Run time jre should point to correct JRE.

I think.. by updating

"JRE_LIB" to whatever "JAVA_HOME" is pointing..

your problem should be solved.

Set your CLASSPATH variable to nothing.


Thank you cmalakar and bpmurray,

now  i am getting this error, i have included ejb.jar and weblogic-ejb.jar in META_INF of the build file but still i am getting this error. if its needed i will post even my build file.

BUILD FAILED: C:\Kalyan\Java_Eclipse\Struts\TaskManager\build\build.xml:74: weblogic.utils.compiler.ToolFailureException: [J2EE:160119]Appc is unable to process the file 'C:\Kalyan\Java_Eclipse\Struts\TaskManager\build\TaskManager.jar'. The following error occurred:
weblogic.utils.compiler.ToolFailureException: [J2EE:160113]Error: The source file, 'C:\Kalyan\Java_Eclipse\Struts\TaskManager\build\TaskManager.jar', is not a valid ejb-jar file. To be valid, it must contain a META-INF/ejb-jar.xml file.
      at weblogic.appc.compileInput(appc.java:424)
      at weblogic.appc.runBody(appc.java:186)
      at weblogic.utils.compiler.Tool.run(Tool.java:192)
      at weblogic.utils.compiler.Tool.run(Tool.java:147)
      at weblogic.appc.main(appc.java:1037)
      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:324)
      at weblogic.ant.taskdefs.j2ee.CompilerTask.invokeMain(CompilerTask.java:278)
      at weblogic.ant.taskdefs.j2ee.Appc.privateExecute(Appc.java:199)
      at weblogic.ant.taskdefs.j2ee.Appc.execute(Appc.java:124)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
      at org.apache.tools.ant.Task.perform(Task.java:364)
      at org.apache.tools.ant.Target.execute(Target.java:341)
      at org.apache.tools.ant.Target.performTasks(Target.java:369)
      at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
      at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:385)
      at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:136)
 - with nested exception:
[weblogic.utils.compiler.ToolFailureException: [J2EE:160113]Error: The source file, 'C:\Kalyan\Java_Eclipse\Struts\TaskManager\build\TaskManager.jar', is not a valid ejb-jar file. To be valid, it must contain a META-INF/ejb-jar.xml file.]


heres my build file

<?xml version="1.0" encoding="UTF-8"?>
<project name="TaskManager" default="deploy" basedir=".">
<property name="src" value="../src"/>
<property name="tld" value="../tld"/>
<property name="build" value="build"/>
<property name="jsp" value="../JSP"/>
<property name="web" value="${build}/web"/>
<property name="ejb" value="${build}/ejb"/>
<property name="app" value="${build}/app"/>
<property name="deployDir" value="C:\MyProject"/>
<target name="all" depends="clean,init,copy, web,ejb,app"/>
 <target name="clean">
        <delete dir="${build}" />
 <target name="init">
      <taskdef name="wlappc"
  <mkdir dir="${web}"/>
  <mkdir dir="${web}/WEB-INF"/>
  <mkdir dir="${web}/WEB-INF/classes"/>
  <mkdir dir="${web}/WEB-INF/src"/>
  <mkdir dir="${web}/WEB-INF/lib"/>
  <mkdir dir="${ejb}/META-INF"/>
  <mkdir dir="${app}/META-INF"/>
<target name="copy">
      <copy todir="${web}">
            <fileset dir="${jsp}">
                  <include name="**/*.jsp"/>
    <copy todir="${web}/WEB-INF">
           <fileset dir="../XML">
                 <include name="*.xml"/>
                 <exclude name = "application.xml"/>
      <copy todir="${web}/WEB-INF/lib">
                  <fileset dir="../LIB">
                              <include name="*.jar"/>
      <copy todir="${web}/WEB-INF/src">
                  <fileset dir="${src}">
                              <include name="*.*"/>
      <copy todir="${app}/META-INF">
            <fileset dir="../XML">
                  <include name="application.xml"/>
      <copy todir="${ejb}/META-INF">
            <fileset dir="../XML">
                  <include name="ejb-jar.xml"/>
                  <include name="weblogic-ejb-jar.xml"/>
                  <include name="weblogic-cmp-rdbms-jar.xml"/>
<target name="web" >
      <javac srcdir="${src}"  destdir="${web}/WEB-INF/classes" includes="**/action/**/*.java, **/connection/**/*.java, **/form/**/*.java, **/helper/**/*.java " excludes="**/ejb/**/*.java"/>
      <jar basedir="${web}" jarfile="${app}/TaskManager.war"/>
      <delete dir="${web}"/>      
<target name="ejb">
            <javac srcdir="${src}" destdir="${ejb}" includes="**/ejb/**/*.java" />
          <jar jarfile="TaskManager.jar" basedir="${ejb}" update="yes"/>
    <wlappc source="TaskManager.jar"
            <pathelement location= "C:\bea\weblogic81\server\lib\weblogic.jar"/>
      <delete dir="${ejb}"/>
<target name="app" >
      <jar basedir="${app}" jarfile="TaskManager.ear"/>
      <delete dir="${build}"/>
 <target name="deploy" depends="all">
            <delete dir="${deployDir}\MyApp"/>
            <mkdir dir="${deployDir}\MyApp"/>
            <mkdir dir="${deployDir}\MyApp\TaskManager"/>
            <unjar src="TaskManager.ear"
            <unwar src="${deployDir}\MyApp\TaskManager.war"
             <delete file="${deployDir}\MyApp\TaskManager.war"/>

Well, you have all the correct copy and setup stuff all laid out correctly. The only issue is what is in the generated file. Dump the jar file:
     jar tvf TaskManager.jar

to see if the xml file has been included. Interestingly, the copy looks right:
      <copy todir="${ejb}/META-INF">
            <fileset dir="../XML">
                  <include name="ejb-jar.xml"/>
                  <include name="weblogic-ejb-jar.xml"/>
                  <include name="weblogic-cmp-rdbms-jar.xml"/>
 so that should be OK, but the Appc call seems not to see it after the jar