Some issue with AntBuilder? - grails

When i am deploying grails application, it's show classnotfound Exception in AntBuilder class?. Do i need to add any jar files to project? Thanks in advance.
java.lang.ClassNotFoundException: org.apache.tools.ant.launch.AntMain
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at org.apache.tools.ant.Project.initProperties(Project.java:308)
at org.apache.tools.ant.Project.init(Project.java:295)
at com.cabot.reader.BookController$_closure5.doCall(BookController.groovy:109)
at com.cabot.reader.BookController$_closure5.doCall(BookController.groovy)
at java.lang.Thread.run(Unknown Source)

The Ant jars are available in run-app because they're needed to run the scripts. But the jars aren't included in a war because in general Ant isn't used by the web app. But you can include them by declaring a dependency in grails-app/conf/BuildConfig.groovy:
dependencies {
compile 'org.apache.ant:ant:1.7.1'
compile 'org.apache.ant:ant-launcher:1.7.1'
}

You might want to check out http://grails.org/plugin/grails-ant.
It does what Burt suggests, plus adds an ant dynamic property to your controller and other artifacts.

Related

Not able to generate Partner.jar

I want to integrate java with salesforce for that I'm trying to generate partner.jar, I'm following this link
Introduction to the Force.com Web Services Connector
I'm using Partner WSDL API. I'm stuck with generating Partner.jar file,
need some help here ..!!
I'm using command my command is **java -classpath J:\Practice\force-wsc-36.1.1.jar com.sforce.ws.tools.wsdlc J:\Practice\Partner.wsdl .\Partner.jar
now the exception is
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/stringtemplate/v4
/STGroupDir
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.stringtemplate.v4.STGroupDir
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
You are trying to generate partner.jar using WSDL file and you are using "force-wsc-36.1.1.jar" (File as Web Service Connector).
As of WSC-36 connector required an additional framework to generate "partner.jar" call "StringTemplate engine framework".
Download latest "StringTemplate binary" jar file using below link: String Template jar file
Put that String template jar, wsc jar and WSDL files in one location.
Open CMD
Go to the directory where you put your all files.
Fire below command to generate a partner.jar file.
java -classpath force-wsc-36.1.1.jar;ST-4.0.8.jar com.sforce.ws.tools.wsdlc partner.wsdl partner.jar
Syntax: Java -classpath [WSC jar file];[String template jar file] com.sforce.ws.tools.wsdlc [Partner.wsdl file] [Ouput file name with .jar extation]
Create a folder named wsdl in your C:\ drive and copy following jars in to it:
force-wsc-54.0.0.jar ST-4.3.1.jar rhino-1.7.14.jar antlr-4.0-complete.jar
Open cmd and run:
java -classpath C:\wsdl\force-wsc-54.0.0.jar;C:\wsdl\ST-4.3.1.jar;C:\wsdl\rhino-1.7.14.jar;C:\wsdl\antlr-4.0-complete.jar com.sforce.ws.tools.wsdlc partner.wsdl.xml C:\wsdl\sf-partner.jar
Note: C:\wsdl\sf-partner.jar is a generated .jar stub file

Jenkins JBehave Plugin Installation failed ClassNotFoundException dtkit.. TestTypeDescriptor

i want to install jbehave plugin for jenkins, but i got following error:
Failed to scout org.jbehave.jenkins.JBehavePluginType$DescriptorImpl
java.lang.InstantiationException: java.lang.NoClassDefFoundError: com/thalesgroup/dtkit/metrics/hudson/api/descriptor/TestTypeDescriptor
at net.java.sezpoz.IndexItem.element(IndexItem.java:146)
at hudson.ExtensionFinder$Sezpoz.scout(ExtensionFinder.java:663)
at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:339)
at hudson.ExtensionList.load(ExtensionList.java:300)
at hudson.ExtensionList.ensureLoaded(ExtensionList.java:253)
at hudson.ExtensionList.iterator(ExtensionList.java:143)
at hudson.ClassicPluginStrategy.findComponents(ClassicPluginStrategy.java:338)
at hudson.ExtensionList.load(ExtensionList.java:300)
at hudson.ExtensionList.ensureLoaded(ExtensionList.java:253)
at hudson.ExtensionList.getComponents(ExtensionList.java:154)
at hudson.DescriptorExtensionList.load(DescriptorExtensionList.java:182)
at hudson.ExtensionList.ensureLoaded(ExtensionList.java:253)
at hudson.ExtensionList.iterator(ExtensionList.java:143)
at org.jenkinsci.plugins.xunit.AliasInitializer.addAliases(AliasInitializer.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at hudson.init.TaskMethodFinder.invoke(TaskMethodFinder.java:105)
at hudson.init.TaskMethodFinder$TaskImpl.run(TaskMethodFinder.java:169)
at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:282)
at jenkins.model.Jenkins$7.runTask(Jenkins.java:886)
at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:210)
at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/thalesgroup/dtkit/metrics/hudson/api/descriptor/TestTypeDescriptor
I installed latest xunit plugin. Try latest stable jbehave (3.9) from link! and latest beta (4.0-beta-11) unsuccessfully. Furthermore i tried to add dtkit plugin. Have Jenkins 1.588 installed. I looked into source code, seems that they used a package which doesnt exists anymore link! What to do?
JUnitReporter was no solution. It only was made for eclipse. Only Solution was to change plugin by hand. I modified pom: changed xunit-plugin version from 1.6 to 1.9 and adapt imports. if someone has same issue here is hpi file: jbehaveplugin-modified
Have you followed the order required by JBehave plugin installation as described here: https://github.com/jbehave/jbehave-core/tree/master/jbehave-jenkins-plugin? It requires to install XUnit BEFORE JBehave plugin.
Also, I'd suggest to try with and older version from Jenkins, the last LTS, for example (1.580.1).
I created PR 118 to fix this issue. See also JBEHAVE-1160 for the Jira issue I created for this.

Opentaps ERP- ClassNotFoundException error during running

Hi I am new to openTaps ERP development just a day before I started it.I have install a previously done project in my eclips.When I run it it gives me following error.I dont understand that error.
what should be done?
(I am using Postgresql database in it)
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152)
at org.opentaps.foundation.infrastructure.Infrastructure.getSessionFactory(Infrastructure.java:120)
at org.opentaps.common.container.HibernateContainer.start(HibernateContainer.java:109)
at org.ofbiz.base.container.ContainerLoader.start(ContainerLoader.java:102)
at org.ofbiz.base.start.Start.startStartLoaders(Start.java:264)
at org.ofbiz.base.start.Start.startServer(Start.java:313)
at org.ofbiz.base.start.Start.start(Start.java:317)
at org.ofbiz.base.start.Start.main(Start.java:400)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 8 more
Anyone knows how to resolve it??
try to download http://www.slf4j.org/download.html and extract it to some folder, then add the jar file (slf4j-api-1.6.4.jar) to your project build path (http://www.cs.duke.edu/courses/cps004g/fall05/assign/final/addlibrary.html)
or http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-%28Java%29
, if another exception appeared related to (slf4j) , try to add all jar files in the (slf4j-1.6.4) folder.
It seems that there is problem in Ehcache jar file or configuration.
ensure that (ehcache-1.6.1.jar) in the build classpath, if not, try to download ehcache-1.6.1.jar.zip from http://www.java2s.com/Code/Jar/e/Downloadehcache161jar.htm then extract it and add it to the build path. or download the last version from http://ehcache.org/downloads/catalog ,
It seems also that opentaps ERP uses the hibernate library that uses the ehcache cache provider , but you have to configure it properly based on the version of hibernate and ehcache as mentioned here (https://forum.hibernate.org/viewtopic.php?f=1&t=1003897&view=previous)
or
http://forums.terracotta.org/forums/posts/list/4932.page
or
http://www.bonitasoft.org/forum/viewtopic.php?id=4783

grails fails to build war

Anyone has seen this issue before? What's the cause here?
Error executing script War: loader constraint violation in interface
itable initialization: when resolving method
"groovy.util.XmlParser.setDocumentLocator(Lorg/xml/sax/Locator;)V"
the class loader (instance of
org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the
current class, groovy/util/XmlParser, and the class loader (instance
of ) for interface org/xml/sax/ContentHandler have
different Class objects for the type org/xml/sax/Locator used in the
signature
at java.lang.Class.forName0(Native Method) at
java.lang.Class.forName(Class.java:169) at
_GrailsWar_groovy$_run_closure4.class$(_GrailsWar_groovy) at
_GrailsWar_groovy$_run_closure4.$get$$class$groovy$util$XmlParser(_GrailsWar_groovy)
at _GrailsWar_groovy$_run_closure4.doCall(_GrailsWar_groovy:186) at
War$_run_closure1.doCall(War.groovy:38) at
gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381) at
gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415) at
gant.Gant$_dispatch_closure7.doCall(Gant.groovy) at
gant.Gant.withBuildListeners(Gant.groovy:427) at
gant.Gant.this$2$withBuildListeners(Gant.groovy) at
gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at
gant.Gant.dispatch(Gant.groovy:415) at
gant.Gant.this$2$dispatch(Gant.groovy) at
gant.Gant.invokeMethod(Gant.groovy) at
gant.Gant.executeTargets(Gant.groovy:590) at
gant.Gant.executeTargets(Gant.groovy:589)
EDIT: As answered by Tim and Peter below this issue is a typical xml-api lib getting in the way of classloader. After removing it from the ivy cache dir i was able to run the dependency-report and clearly see it being pulled in by hibernate->dom4j->xml-api . I ran the same report on another machine with the same code base and did not see this dependency being pulled in. So I am still trying to figure out what caused this issue in the first place. The quick fix for me was to add the following in the BuildConfig
inherits("global") {
excludes ( "xml-apis", "commons-digester")
}
Sounds like something has pulled the xml-apis module into your classpath.
GroovyWS is sometimes the culprit. Have you added anything to the dependencies recently?
I assume the project used to work...so it must be something someone has added recently
Looking back through your source control might help you see what it is...
Or it could be something someone stuck in JAVA_HOME/lib/ext?

Tests passing when run by ant but fail when run by maven?

Does anyone have any ideas why a test would pass when run with ant, but fail when run with maven?
I'm running my tests on windows and apparently there are some issues with surefire and windows? I've tried changing useSystemClassLoader=False and useManifestOnlyJar=true, but haven't been able to get them to work. The stack is below for the error I am getting when running the test with maven.
One thing I noticed is that there are $Proxy.someMethod calls in the stack, I have no idea where they are coming from.
Thanks for any help.
javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: cheetah.entities.businessdata.Attribute
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1153)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:678)
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.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at $Proxy27.persist(Unknown Source)
at cheetah.repositories.businessdata.jpa.JpaAttributeRepository.create(JpaAttributeRepository.java:28)
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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy29.create(Unknown Source)
at cheetah.tests.integration.util.BusinessDataLookupData.createAttributeLookupData(BusinessDataLookupData.java:19)
at cheetah.tests.integration.util.BusinessDataLookupData.create(BusinessDataLookupData.java:10)
at cheetah.tests.integration.util.LookupData.create(LookupData.java:7)
at cheetah.tests.integration.util.TestUtil.prepareData(TestUtil.java:23)
at cheetah.repositories.businessdata.tests.integration.AttributeRepositoryTest.setUpClass(AttributeRepositoryTest.java:23)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:120)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:103)
at org.apache.maven.surefire.Surefire.run(Surefire.java:169)
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.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)
Caused by: org.hibernate.PersistentObjectException: detached entity passed to persist: cheetah.entities.businessdata.Attribute
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:127)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:808)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:782)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:786)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:672)
... 43 more
The exception indicates an issue with a detached entity.
http://www.google.com.au/search?q=javax.persistence+detached+entity brings up a number of documents talking about detached entities.
From one of those documents - "Detached -- Detached entities have a persistent identity, but they are not currently actively managed within a persistence context."
From this I suspect that there is actually a problem with the code, rather than Ant or maven.
Most likely the ant build sets some sort of properties for the environment either via your ant script and properties files directly or via the ant task you are using and the Maven build does not do that.
That in turn leaves you with different test runtime configurations failing in Maven but not in Ant. Just a guess but I seen that before ;-)
If it's related to 'pre test code' not being ran then maybe check out Maven failsafe plugin and look into the pre and post integration test phases of the lifecycle.
Also, Maven is quite possibly using a different classpath to Ant - referring to JARS in it's own local repo. Something to watch out for.
Setting forkMode=never in the sure fire configuration resolved the issue. I'm not sure of the reasoning, but without this option maven wasn't running pre-test code that ant was.

Resources