in spring boot application , build.gradle :
compile("org.springframework.boot:spring-boot-devtools")
compile('org.grails:gorm-hibernate5-spring-boot:6.1.2.RELEASE')
compile('org.grails:grails-datastore-gorm:6.1.2.RELEASE')
compile('org.grails:grails-datastore-gorm-support:6.1.2.RELEASE')
compile('org.grails:grails-datastore-gorm-validation:6.1.2.RELEASE')
application would throw exception at runtime.
Error performing load command : org.hibernate.HibernateException: Javassist Enhancement failed
why?help?
find Alternatives way.
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("org.springframework:springloaded:1.2.7")
}
After change code, click Build-》Build project .
Related
I have a problem with running Cucumber tests in a khipster project (I can reproduce it with jhipster as well) when I configure it to use oauth2.
I create the project with the following configuration file (I call it mono.jdl):
application {
config {
applicationType monolith
authenticationType oauth2
baseName helloworld
buildTool maven
packageName com.example.helloworld
testFrameworks [cucumber]
}
entities *
}
I generate the project with a command: khipster import-jdl mono.jdl.
I create a very simple Cucumber test. I create a feature file (src/test/features/kuku/kuku.feature):
Feature: just a test
Scenario: my scenario
And one two three
and a file with steps (src/test/kotlin/com/example/helloworld/cucumber/stepdefs/KukuStepDefs.kt):
package com.example.helloworld.cucumber.stepdefs
import io.cucumber.java.en.When
class KukuStepDefs : StepDefs() {
#When("one two three")
fun magic() {
println("four five six")
}
}
I try to run the integration test with a command ./mvnw integration-test. However, it fails with a following error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.example.helloworld.web.rest.LogoutResource required a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' that could not be found.
The following candidates were found but could not be injected:
- Bean method 'clientRegistrationRepository' in 'OAuth2ClientRegistrationRepositoryConfiguration' not loaded because OAuth2 Clients Configured Condition registered clients is not available
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' in your configuration.
How can I fix this problem?
The solution is to find CucumberContextConfiguration class. It contains such annotation:
#ContextConfiguration(classes = [HelloworldApp::class])
We must change it to:
import com.example.helloworld.config.TestSecurityConfiguration
(...)
#ContextConfiguration(classes = [HelloworldApp::class, TestSecurityConfiguration::class])
I recently added database-migration-plugin to my grails 3.0.11 app. The problem is when I try to run-app I get a following error:
ERROR grails.boot.GrailsApp - Application startup failed
Exception in thread "main" org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'springLiquibase_dataSource':
Invocation of init method failed; nested exception is liquibase.exception.ChangeLogParseException:
java.lang.IllegalArgumentException: Script text to compile cannot be null!
Looks like it can't find changelog.xml in my grails-app/migrations folder. My build.gradle file contains:
buildscript {
dependencies {
classpath "org.grails.plugins:database-migration:2.0.0.RC1"
}
}
and
sourceSets {
main {
resources {
srcDir 'grails-app/migrations'
}
}
}
I also added the following lines in my application.groovy file:
grails.plugin.databasemigration.updateOnStart = true
grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.xml']
I would by very gratefull for any advice how to make database-migration-plugin work properly.
Edit:
I created changelog.xml file using $grails dbm-create-changelog command
I also added to build.gradle (as suggested by $grails plugin-info database-migration command):
dependencies {
compile "org.grails.plugins:database-migration:2.0.0.RC1"
}
then I changed it to (following official documentation):
dependencies {
runtime "org.grails.plugins:database-migration:2.0.0.RC1"
}
and then (as suggested by manual for startup error) I forced liquibase:
dependencies {
compile 'org.liquibase:liquibase-core:3.3.2'
runtime 'org.grails.plugins:database-migration:2.0.0.RC1'
}
and
dependencies {
compile 'org.liquibase:liquibase-core:3.3.2'
compile 'org.grails.plugins:database-migration:2.0.0.RC1'
}
The problem still remains: java.lang.IllegalArgumentException: Script text to compile cannot be null!
We ran into the same problem when upgrading to Grails 3.
A look into the code of the grails-database-migration plugin made clear that the configuration parameter is changed from a list updateOnStartFileNames to a single value updateOnStartFileName.
So when you change your config from
grails.plugin.databasemigration.updateOnStartFileNames = ['changelog.xml']
to
grails.plugin.databasemigration.updateOnStartFileName = 'changelog.xml'
it should work again.
I ran into a similar error. In my case we had some lookup tables where we were populating using a hand crafted script which was included into the main changelog.groovy like:
include file: 'data/001-tablex-data.groovy'
except the file name was incorrect - it should have been 002-... instead. The error is basically the same, but there is no reporting to indicate which included file is not being found/parsed, which is a pain. So if you have manually included files, then look for incorrectly named ones in addition to checking the top-level changelog.groovy or changelog.xml
Ok, I finally found a solution. Maybe it will help someone someday. So what I did was simply delete changelog.groovy (i switched from XML to Groovy) file. Then I generated a new one with $grails dbm-create-changelog changelog.groovycommand. As a final step I run $grails dbm-changelog-sync and everything started to work just fine.
I was facing this issue too and in my case, the problem was the order of that block in build.gradoe
sourceSets {
main {
resources {
srcDir 'grails-app/migrations'
}
}
}
It MUST be before the bootRun, like the below code.
sourceSets {
main {
resources {
srcDir 'grails-app/migrations'
}
}
}
bootRun {
jvmArgs(
'-Dspring.output.ansi.enabled=always',
'-noverify',
'-XX:TieredStopAtLevel=1',
'-Xmx1024m')
sourceResources sourceSets.main
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}
If you put sourceSets after bootRun your application will not find the migrations file.
Make sure:
You have set up the changelog, i.e., the file grails-app/migrations/changelog.xml exists and is valid.
How you do this depends on your situation. The plugin's documentation has a section for how to create the file initially.
Your datasource is set up to use the database that changelog.xml applies to.
Another potential cause for this problem that we had run into was incorrect capitalization. If changelog.groovy references path/someFile.groovy but the actual name is path/somefile.groovy then you will get this error. Make sure the path name capitalization matches.
I decided to return to Dropwizard after a very long affair with Spring. I quickly got the absolute barebones REST service built, and it runs without any problems.
Using Dropwizard 0.7.1 and Java 1.8, only POM entries are the dropwizard-core dependency and the maven compiler plugin to enforce Java 1.8, as recommended by the Dropwizard user manual
However, as soon as I try to add an Optional QueryParam to the basic controller, the application fails to start with the following error (cut for brevity):
INFO [2015-01-03 17:44:58,059] io.dropwizard.jersey.DropwizardResourceConfig: The following paths were found for the configured resources:
GET / (edge.dw.sample.controllers.IndexController)
ERROR [2015-01-03 17:44:58,158] com.sun.jersey.spi.inject.Errors: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Missing dependency for method public java.lang.String edge.dw.sample.controllers.IndexController.index(java.util.Optional) at parameter at index 0
Exception in thread "main" javax.servlet.ServletException: com.sun.jersey.spi.container.servlet.ServletContainer-6c2ed0cd#330103b7==com.sun.jersey.spi.container.servlet.ServletContainer,1,false
The code for the controller is as follows:
#Path("/")
public class IndexController {
#GET
#Timed
public String index(#QueryParam("name") Optional<String> name) {
String saying = "Hi";
if(name != null && name.isPresent()) {
saying += " " + name.get();
}
return saying;
}
}
If I remove Optional from the mix, the application runs just fine. I replace the Optional-specific code with null checks and it works perfectly.
Am I missing something fundamental here? Both Google Guava Optional and java.util.Optional fail with the same error. (And yes, I did narrow it down to the Optional object)
A quick Google/SO search yielded nothing useful, but feel free to point me to a resource I may have missed
Thanks in advance!
Moments after posting this, I found that the issue was my use of Java 1.8. If using Java 1.8, I have to add the Java8Bundle to my app:
POM Entry:
<dependency>
<groupId>io.dropwizard.modules</groupId>
<artifactId>dropwizard-java8</artifactId>
<version>0.7.0-1</version>
</dependency>
And code in the Application class:
#Override
public void initialize(Bootstrap<SampleConfiguration> bootstrap) {
bootstrap.addBundle(new Java8Bundle());
}
See: https://github.com/dropwizard/dropwizard-java8
This enables both Google Guava Optional and java.util.Optional to work just fine.
If I revert to Java 1.7 and use the Google Guava Optional, it works just fine as well and I don't have to include the Java8Bundle. I'll opt for the Java8Bundle for now, though, as using Java8 features is lucrative for me :)
Cheers!
I need some help, I am trying to make an controller using Google Analytics API, but using:
statsController.groovy
/**************************************************************/
import com.google.gdata.client.analytics.AnalyticsService
class StatsController {
def myService
def stats(){
myService = new AnalyticsService("example-App");
}
}
/************************************************************/
error Message:
ClassNotFoundException occurred when processing request: [...]
com.google.common.collect.Maps
I ve tryed adding to the buildpath the "gdata.analytics*.jar", "google-collect-1.0.jar", "guava.jar" and "jsr305.jar" but without results, the error always says that i described or NotDefClassError ocurred when processing request: [...] com.google.gdata.client.analytics.AnalyticsService.
I need to solve.
The handling of JARs is kept pretty easy in grails. If you don't use stuff like maven you can just copy your JARs into the lib folder in the root directory of your grails application.
Try to put them there and see if it solves the problem.
Further: what IDE do you use? IntelliJ for instance recognize JARs within the lib folder instantly. So you should see the effects in your IDE already.
I use grails 2.0.0.rc3, when I install PayPal plugin I have this error:
Error Compilation error: startup failed:
/Users/sartre/.grails/2.0.0.M1/projects/testapp/plugins/paypal-0.6.4/grails-app/controllers/org/grails/paypal/PaypalController.groovy: -1: The return type of java.lang.Object notify() in org.grails.paypal.PaypalController is incompatible with void notify() in java.lang.Object
. At [-1:-1] # line -1, column -1.
1 error
How can I fix it?
Many thanks for any idea
Incompatibility change in grails 2.0!!
It seems that it is related to a small change in grails 2.0.
It is now possible to define controller actions as methods instead of using closures as in previous versions of Grails. (from official doc : http://grails.org/doc/2.0.x/guide/introduction.html#webFeatures)
It behaves like the closure notify in PaypalController overrides the Object.notify method.
If you rename notify in notifyPaypal, it should work.