-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Error while trying to invoke hib ant task from java
PostPosted: Tue Dec 06, 2011 8:24 am 
Newbie

Joined: Tue Dec 06, 2011 7:48 am
Posts: 2
Hi ,

I have written a reveng ant task and executed it via ant tool. It works perfect. The same task i tried invoking from java code using ant api's. It causing an Security Exception. Please look into this matter and see whether any help can be suggested .

Ant script :

Code:
<project name="sgfhibernate" basedir="C:\\Test\\Hibernate" default="gen_hibernate">

   <taskdef name="hibernatetool"
         classname="org.hibernate.tool.ant.HibernateToolTask">
         <classpath>
            <fileset dir="lib">
               <include name="**/*.jar"/>
            </fileset>
         </classpath>
   </taskdef>

   <target name="gen_hibernate"
         description="generate hibernate classes">
         <echo message="Base Dir : {basedir}"/>
         <echo message="The Project name is: ${ant.project.name}"/>

      <hibernatetool>
         <jdbcconfiguration
            configurationfile="hibernate.cfg.xml"
            packagename="com.hp.hibernate"
            revengfile="tables.reveng.xml"   
            detectmanytomany="true"
         />
         <hbm2java  destdir="src" />
         <hbm2hbmxml destdir="src" /> 
      </hibernatetool>
      
      

   </target>

</project>





And the java class to invoke the script is :
Code:
import java.io.File;

import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectHelper;


public class InvokeAntScript {

   /**
    * @param args
    */
   public static void main(String[] args) {
      File buildFile = new File("C:\\Test\\Hibernate\\build.xml");
      Project p = new Project();
      p.setUserProperty("ant.file", buildFile.getAbsolutePath());
      
      p.init();
      ProjectHelper helper = ProjectHelper.getProjectHelper();
      p.addReference("ant.projectHelper", helper);
      
      helper.parse(p, buildFile);
      DefaultLogger consoleLogger = new DefaultLogger();
      consoleLogger.setErrorPrintStream(System.err);
      consoleLogger.setOutputPrintStream(System.out);
      consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
      p.addBuildListener(consoleLogger);
      p.executeTarget(p.getDefaultTarget());

   }

}



and the error log is as follows

Code:
[hibernatetool] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
Exception in thread "main" C:\Test\Hibernate\build.xml:24: java.lang.ExceptionInInitializerError
   at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
   at org.apache.tools.ant.Task.perform(Task.java:348)
   at org.apache.tools.ant.Target.execute(Target.java:390)
   at org.apache.tools.ant.Target.performTasks(Target.java:411)
   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
   at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
   at InvokeAntScript.main(InvokeAntScript.java:28)
Caused by: java.lang.ExceptionInInitializerError
   at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:59)
   at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
   at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
   at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
   at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
   at org.hibernate.tool.ant.Hbm2JavaExporterTask.configureExporter(Hbm2JavaExporterTask.java:34)
   at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
   at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
   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:597)
   at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
   ... 6 more
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
   at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
   at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
   at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
   at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
   at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
   at org.hibernate.cfg.reveng.OverrideRepository.<clinit>(OverrideRepository.java:589)
   ... 20 more
Caused by: java.lang.reflect.InvocationTargetException
   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:597)
   at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
   at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
   ... 25 more
Caused by: java.lang.SecurityException: class "org.hibernate.cfg.reveng.OverrideRepository$TableColumnKeyFactory$$KeyFactoryByCGLIB$$12c34424"'s signer information does not match signer information of other classes in the same package
   at java.lang.ClassLoader.checkCerts(ClassLoader.java:806)
   at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487)
   at java.lang.ClassLoader.defineClassCond(ClassLoader.java:625)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
   ... 31 more




I am using hibernate3 for this.

Thanks

Deepak


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.