Link to home
Start Free TrialLog in
Avatar of gkmadhav
gkmadhavFlag for United States of America

asked on

errors while trying to build the application

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.
Avatar of bpmurray
bpmurray
Flag of Ireland image

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.
Avatar of gkmadhav

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of cmalakar
cmalakar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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>
 <target name="init">
      <taskdef name="wlappc"
            classname="weblogic.ant.taskdefs.j2ee.Appc"
            classpath="C:\bea\weblogic81\server\lib\weblogic.jar"/>
  <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>
<target name="copy">
      <copy todir="${web}">
            <fileset dir="${jsp}">
                  <include name="**/*.jsp"/>
            </fileset>
      </copy>
    <copy todir="${web}/WEB-INF">
           <fileset dir="../XML">
                 <include name="*.xml"/>
                 <exclude name = "application.xml"/>
           </fileset>
    </copy>
      <copy todir="${web}/WEB-INF/lib">
                  <fileset dir="../LIB">
                              <include name="*.jar"/>
                  </fileset>
      </copy>      
      <copy todir="${web}/WEB-INF/src">
                  <fileset dir="${src}">
                              <include name="*.*"/>
                  </fileset>
      </copy>      
      <copy todir="${app}/META-INF">
            <fileset dir="../XML">
                  <include name="application.xml"/>
            </fileset>
      </copy>
      <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"/>
            </fileset>
      </copy>
</target>
<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>
<target name="ejb">
            <javac srcdir="${src}" destdir="${ejb}" includes="**/ejb/**/*.java" />
          <jar jarfile="TaskManager.jar" basedir="${ejb}" update="yes"/>
    <wlappc source="TaskManager.jar"
                  output="${app}/TaskManager.jar"
            forceGeneration="true"
            verbose="true"
            deprecation="true">
        <classpath>
            <pathelement location= "C:\bea\weblogic81\server\lib\weblogic.jar"/>
        </classpath>
    </wlappc>
      
      <delete dir="${ejb}"/>
</target>
<target name="app" >
      <jar basedir="${app}" jarfile="TaskManager.ear"/>
      <delete dir="${build}"/>
</target>
 <target name="deploy" depends="all">
            <delete dir="${deployDir}\MyApp"/>
            <mkdir dir="${deployDir}\MyApp"/>
            <mkdir dir="${deployDir}\MyApp\TaskManager"/>
            <unjar src="TaskManager.ear"
                    dest="${deployDir}\MyApp">
            </unjar>
            <unwar src="${deployDir}\MyApp\TaskManager.war"
                    dest="${deployDir}\MyApp\TaskManager">
            </unwar>
             <delete file="${deployDir}\MyApp\TaskManager.war"/>
  </target>
</project>

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial