Changelog changelog.groovy not found - java

I've created new Grails project in IntellijIDEA 11.1.3 and try to run it.
When I open http://localhost:8080/application/dbdoc (accessing default action of controller grails.plugin.databasemigration.DbdocController), I keep getting message:
Changelog changelog.groovy not found
Although, file changelog.groovy exists in file system of my project in folder ./grails-app/migrations. I've generated it, using command:
grails dbm-create-changelog changelog.groovy
And now it has the following content:
databaseChangeLog = {
changeSet(author: "Edward (generated)", id: "changelog") {
// TODO add changes and preconditions here
}
}
What I need to do to make it work?

I am running IntelliJ 11.1.3 as well. I am working with Grails 2.1 and database-migration:1.1.
The database-migration plugin is used to create changelog Groovy Scripts that can be used to migrate a Database at point X in time to be compatible with new code changes you have made to your Grails App.
For instance, if your Grails App is in production today, with your Domain Classes, tables, etc. and you run grails dbm-create-changelog changelog.groovy, this will give you a baseline changelog.groovy script. Then you should run grails dbm-changelog-sync to indicate that you are up-to-date.
Let's say that you have added new Domain Classes and modified fields on existing ones. If you have been keeping up your changesets and you run grails dbm-update, the Database Migration plugin will update your database schema based on those changesets.
Here is an excellent tutorial (not mine) that I am reading/following to learn more about the database-migration plugin: Grails DB-Migration Plugin Tutorial

Related

how to add new azure function via maven plugin at intellij IDE

I want to use timerTrigger in azure functions.
I created function according this guide:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-maven-intellij
it is generated by default httpTrigger. I tried command of azure-functions:add.
I succeeded adding timerTrigger but I encountered with a lot of errors
How I can delete httpTrigger and declaring only timerTrigger?
before I run the azure-functions:add:
after running the command:
I guess it is related to azure plugin and maven plugin conflict but not sure and I don't know how to handle such this situation
any help will be appreciated
thanks
For now, I suppose it doesn't support create java function with default timer trigger. However you could delete the HTTP one then create the timer, cause you don't provide much information so maybe you could refer to my steps.
Create the function with maven.(I'm using the 1.22 version)
Delete the HTTP function, and delete the test folder.
Create the Timer Trigger function.
After this the project will be like this.(Before packaging remember set the storage connection string in the local.settings.json)
Package it.(Use the package method in the Lifecycle.)
Run it with azure-functions:run under azure-functions plugin.

How to use maven dbunit plugin to write data(sample-data.xml) to database by code but not by pom.xml?

I have a problem with maven-dbunit-plugin.
The common use of maven-dbunit-plugin is running a command like mvn dbunit:operation in the shell.
But now, I have a spring batch job. The work of this job is writing data by sample-data.xml file to the database.
The command mvn dbunit:operation depends on the maven project with the pom.xml. This is not the style what I want.
How to write code using maven-dbunit-plugin lib to resolve this problem?
There is no straight anwser to your question, or there is at least some misunderstanding.
Even if it's not really impossible, you try to use a tool for another goal that why it was designed.
Maven : build tool
As per doc, maven a build and "project comprehension tool", aimed toleverage the management of softwares. In a few words : it's related to Build phase (development).
So, maven-dbunit-plugin provided features to help you during test / dev of your program : batch, webapp, .... or wathever you want.
Loading data
You are (or you seem) looking for a library that read data from an xml file, during Run Phase (production) and load them into a database.
There hopefully is a lot of way to achieve that, depending on your needs : do you have to make some operation on data before ? Which database are you using.
Here a few list of ideas :
Import Data into MySQL
http://www.mssqltips.com/sqlservertip/2899/importing-and-processing-data-from-xml-files-into-sql-server-tables/
INSERT INTO XMLwithOpenXML(XMLData, LoadedDateTime)
SELECT CONVERT(XML, BulkColumn) AS BulkColumn, GETDATE()
FROM OPENROWSET(BULK 'D:\OpenXMLTesting.xml', SINGLE_BLOB) AS x;
Import Data into SQL Server
Import XML file into SQL Server without BULK
SELECT *
FROM OPENROWSET('MSDASQL',
'Driver={Microsoft Text Driver (*.xml)};DefaultDir=C:\Radu\test.xml;',
'SELECT * FROM [test.xml];' )
As a last solution, you may use dbunit, as a dependency, and call internal method, but once again, this is not the main usage of this library.

play framework 2.1 junit test not working from eclipse

im following the zentask tutorial and wrote a junit test,
the test wont run from the eclipse IDE its giving the following exception
javax.persistence.PersistenceException: java.lang.IllegalStateException: Class [class play.db.ebean.Model] is enhanced and [class models.User] is not - (you can not mix!!)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setEntityBeanClass(BeanDescriptorManager.java:1475)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(BeanDescriptorManager.java:1138)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1058)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:565)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:252)
at com.avaje.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:124)
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:210)
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:64)
I read a bit and found that for some people
editing the buils.scala adding the following line inside main helped : ebeanEnabled := true
to me it didnt nither closeing the ide running play clean compile
any ideas???
There is blog post about setting up unit tests to run in IDEs. It suggests to add following command-line to java used when running tests:
-javaagent:/path/to/ebean/ebean-2.7.3-agent.jar
Seems that Play not ships with ebean agent, it should be downloaded from Ebean website first (in main ebean package).
I not tried it.
Ebean user guide also mentions it (15.5.2 javaagent section), there is even example for configuring Eclipse.
Also, to speed up enhancement maybe this will be better:
-javaagent:/path/to/ebean/ebean-2.7.3-agent.jar;packages=models.*
So it will only look into models.* (default package for ORM models in Play).
You can use the Avaje Ebean Eclipse Plugin:
http://www.avaje.org/eclipseupdate/site.xml
After the installation, activate Ebean enhancement by right clicking on your project and selecting Enable Ebean Enhancement.
i got this error when i tried to remove the public modifier from the declaration of one of classes extending Model.
i was using a model to make a "through" table (a many to many relationship with additional information), so protected access makes sense. perhaps there's another way to do this, but the play javadoc is pretty sparse.

org.apache.axiom.om.util.AXIOMUtil cannot be resolved

I'm trying to generate some stubs for a WSDL (using xmlbeans) and keep running into some issues. I'm using the following page:
http://axis.apache.org/axis2/java/core/docs/userguide-creatingclients-xmlbeans.html
The only part of these steps that I'm skipping is the "client.java" part because I already have another project ready I want to plug the resulting jars into. A quick run down of my steps are as follows:
My WSDL is a crmonline instance, so I run something like this:
C:\Work\aaa2>WSDL2Java -uri
https://mycrmorgname.crm.dynamics.com/XRMServices/2011/Organization.svc?wsdl
-p crmsdk -d xmlbeans -s -o c:\mystubfolder
I build the project using "ant"
In my "client" project I reference the 2 jars created in .\build\lib
My project builds fine once I add all my axis2 / apache references etc, but when I launch it through playframework I get errors when I hit the first page. The first error seems to be:
17:48:45,289 ERROR ~ Error in ControllersEnhancer.
controllers.ProfileController.editProfile has not been properly enhanced
(fieldAccess javassist.expr.FieldAccess#212ca458).
or something similar to that. Scrolling down through the error I can see that I'm getting this:
The file /app/models/MyDynamicsClient.java could not be compiled.
Error raised is : org.apache.axiom.om.util.AXIOMUtil cannot be resolved
Now, I haven't even hit any of my web services yet, or even instantiated any of my classes ... I'm at a loss as to why this is happening. Or to be more accurate, what exactly am I messing up! Am I missing a reference to something? Doing a search on AXIOMUtil tells me this should be in Axiom-api (version I have is Axiom-api-1.2.10.jar). I have this referenced and doesn't seem to help. Or maybe I'm doing something else wrong someplace?
Some details on versions:
Axis2 1.5.4
Apache-ant 1.8.3
Any help would be very much appreciated!!
Ok, after trying a lot of different things and rereading the sites/instructions I realised what I was doing wrong. Or at least I figured out a couple of things that I started to do differently that fixed the problem.
Firstly, I was using jar files from another sample project for the apache http components. I don't know if this had an impact, but I downloaded a fresh version of this anyway and referenced those JARS instead.
Also, instead of creating jars in my "stub" project and referencing those I copied all the generated stubs/classes directly into the existing client project. I have a feeling this might have been what fixed my problem. Or maybe a mix of this and the previous step I did!
So my new steps are as follows:
Ensure you have all the correct versions downloaded for required components. In my case I have the following:
Apache Axis 2 v 1.5.4
Apache HTTP components client 4.1.3
Apache-ant 1.8.3
Copy all the JARS from the Axis2 and HTTP Components libs into your client project and reference them.
Use WSDL2Java to create your stubs and classes within it's own project.
Ensure the project builds using Ant
Copy all the generated class files within the src folder into the source folder of your client.
Fix any other reference isssues and Build
Thankfully this got me going.

Running tests in a Seam project which was not generated by seam-gen

I've got a project firstly written using EJB 2, then migrated to Spring and after all migrated to JBoss Seam 2.2.0 (which is the situation I'm dealing with). It will run over Tomcat but for now it is executed over JBoss 4.2 (although I believe this fact is irrelevant). My task is to run all tests written before the last migration.
After a lot of googling, I wrote something like this:
public class CustomUserDAOTest extends SeamTest {
#Test
public void f() throws Exception {
new ComponentTest() {
#Override
protected void testComponents() throws Exception {
CustomUserDAO customUserDAO = (CustomUserDAO) Component.getInstance(CustomUserDAOBean.class);
List<CustomUser> users = customUserDAO.getAll();
assertNotNull(users);
}
}.run();
}
}
That is good because I managed to get instances of CustomUserDAOBean and its dependencies, but when I run the test I get another problem:
java.lang.RuntimeException: exception invoking: getTransaction
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:154)
at org.jboss.seam.Component.callComponentMethod(Component.java:2249)
at org.jboss.seam.Component.unwrap(Component.java:2275)
at org.jboss.seam.Component.getInstance(Component.java:2041)
[OMITTED]
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
at br.com.visent.sicorp.server.dao.impl.CustomUserDAOBean_$$_javassist_seam_1.listAll(CustomUserDAOBean_$$_javassist_seam_1.java)
at br.com.visent.sicorp.server.dao.test.CustomUserDAOTest$1.testComponents(CustomUserDAOTest.java:24)
at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:162)
[OMITTED]
at org.testng.TestNG.run(TestNG.java:856)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174)
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
[OMITTED]
at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
... 45 more
I found some comments about it on the Web but no solution. What should I do? Has someone any ideas?
Thanks in advance!
I've followed the suggestion of Shervin above and got a solution. Actually, when we create a project using seam-gen the src/test directory will contain a readme.txt with the following content:
If you want to run tests using the Eclipse TestNG plugin, you'll need to add
these jars to the top of your TestNG classpath. Using the Run Dialog, select the
XML suite to run, and select these entries from the project tree:
/lib/test/jboss-embedded-all.jar
/lib/test/hibernate-all.jar
/lib/test/thirdparty-all.jar
/lib/jboss-embedded-api.jar
/lib/jboss-deployers-client-spi.jar
/lib/jboss-deployers-core-spi.jar
You also need to add the Embedded JBoss bootstrap folder, which you can do by
clicking on the Advanced... button.
/bootstrap
Seam uses JBoss Embedded in its unit and integration testing. This has an
additional requirement when using JDK 6. Add the following VM argument to the VM
args tab in the TestNG launch configuration for your suite.
-Dsun.lang.ClassLoader.allowArraySyntax=true
Please be sure to use JDK 6 Update 4 or better (>= 1.6.0_04) if you are using
JDK 6. The Update 4 release upgraded to JAXB 2.1 which removes a problem with
earlier versions of Sun's JDK 6 which required overriding the JAXB libraries
using the endorsed directory.
To add tests to your project create a TestNG xml descriptor called *Test.xml
(e.g. FooTest.xml) next to your test classes and run ant test.
I opened the "Run Configurations" of the test (which can be made through the button "Run" on the toolbar, clicking in the little black down arrow and selecting "Run Configurations"), added the jars listed above in the "Classpath" tab (except for jboss-deployers-client-spi.jar, which was problematic) and added -Dsun.lang.ClassLoader.allowArraySyntax=true to the "VM Arguments" in the "Arguments" tab because I am using Java 6.
I still have some problems but this specific one is solved.

Categories