ActiveJDBC (JavaLite) : Using "activejdbc.properties" does not work for test directory - activejdbc

I recently updated to ActiveJDBC 2.1 in order to use activejdbc.properties for the purpose of externalizing out the database property so we didn't have to check in the database username/password into SVN.
Putting the "activejdbc.property" file in src/main/resources for the main code works perfect. Now the goal is to replace the "database.property" file in the test directory src/test/resources with an "activejdbc.property" so it can point to the same database config file out on the file system.
After making this change in the test directory, we receive an error when performing the gradle build (gradle clean build). This is the exception we see:
`"org.javalite.activejdbc.InitException: java.io.FileNotFoundException: \database.properties (The system cannot find the file specified)"
Any ideas why this works for main directory but not for the tests?
Stacktrace:
es/main/com/brookdale/model/UnitOfMeasure.class
**************************** END INSTRUMENTATION ****************************
...
:assemble
:compileTestJava
:processTestResources
:testClasses
:test
com.brookdale.model.ActualChargeTest > unitQuantityMustBeGreaterThanZero FAILED
org.javalite.activejdbc.InitException: java.io.FileNotFoundException: \database.properties (The system cannot find the file specified)
Caused by:
java.io.FileNotFoundException: \database.properties (The system cannot find the file specified)
... more tests ...
com.brookdale.service.RelationshipServiceTest > updateContactRel_GivenValidInfo_
RecordIsInserted FAILED
org.javalite.activejdbc.InitException: java.io.FileNotFoundException: \datab
ase.properties (The system cannot find the file specified)
Caused by:
java.io.FileNotFoundException: \database.properties (The system cannot f
ind the file specified)
49 tests completed, 25 failed, 7 skipped
:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
BUILD FAILED`

It seems you did not name the file correctly: the name of the file is not activejdbc.property, it is activejdbc.properties.
Additionally, Java class loaders do not guarantee which file they will load first if it finds multiples on the classpath. If you want different JDBC properties in your test environment, please follow docs here: http://javalite.io/database_connection_management#multiple-environments-property-file-method
Here is a sample project with this implementation: https://github.com/javalite/simple-example/

Related

Gradle exception Failed to load native library native-platform.dll

I have just installed Gradle 2.11 on a Windows 7 machine and when I run gradle -v I get a failure message. Gradle is in the path and the dll is present.
$ gradle -v --stacktrace
FAILURE: Build failed with an exception.
* What went wrong:
Failed to load native library 'native-platform.dll' for Windows 7 amd64.
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
net.rubygrapefruit.platform.NativeException: Failed to load native library 'nati ve-platform.dll' for Windows 7 amd64.
at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeL ibraryLoader.java:49)
at net.rubygrapefruit.platform.Native.init(Native.java:55)
at org.gradle.internal.nativeintegration.services.NativeServices.initial ize(NativeServices.java:74)
at org.gradle.internal.nativeintegration.services.NativeServices.initial ize(NativeServices.java:60)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute( CommandLineActionFactory.java:203)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute( CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep ortingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionRep ortingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots trap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j ava:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:1012)
at net.rubygrapefruit.platform.internal.NativeLibraryLocator.find(Native LibraryLocator.java:39)
at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeL ibraryLoader.java:41)
... 16 more
This is cause by Windows configuration, probably through group policy. The file native-platform.dll is extracted from one of the JAR files, and probably placed in folder in the user home directory, such as c:\Users\%USERNAME%\Local Settings\Temp. For malware protection, loading of DLL's and execution of programs from TMP directories may be disabled.
I have a problem with the same symptoms, and I have been able to work around it in some cases by setting TEMP and TMP environment variables to point outside the user directory, such as c:\tmp. That has not been a universal solution and did not work for gradle. The location to which Gradle extracts DLL's can be overwritten by setting the GRADLE_OPTS to point to the desired location. This may work for you:
C:\ mkdir C:\tmp
C:\ set GRADLE_OPTS="-Dorg.gradle.native.dir=/tmp"
In adition, you have to put the set sentence in the gradle.bat located in the ../gradle-2.11/bin folder.
Example:
#rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%..
#rem agregado por marcgaso
set GRADLE_OPTS="-Dorg.gradle.native.dir=/tmp"
**strong text**
Further to user6823564 solution above, I also came across this issue after cleaning my temporary files.
The cause is a missing native folder. Beats me why Gradle just doesn't restore it like any other bit of missing temporary/cached data.
Answer:
md %GRADLE_USER_HOME%\native
Which is the default location. Or use the setting given by user6823564 and Marcos... using either
set GRADLE_OPTS="-Dorg.gradle.native.dir=%GRADLE_USER_HOME%\native"
or using
%GRADLE_USER_HOME%\gradle.properties
good luck.
1.Open the projects gradle.properties file in android studio
2.Added this line at end of file org.gradle.jvmargs=-Xmx1024m & Save the file
3.Close & reopen the project
And you just need to restart the android studio and your system. This is getting just because you have no enough free space in ROM

why i am getting these errors in cloud programming?

java.io.FileNotFoundException: simulation.properties (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at org.cloudbus.cloudsim.ex.mapreduce.Configuration.loadPropertiesFromFile(Configuration.java:35)
In Configuration.java file you must have a code to retrieve Properties From a File. There can be two problems
Either configuration file is missing
If you have configured a path any where in the project that path is invalid after you deploy from local host to cloud

IBM Worklight - Build failed

My environments are failing to build after restart, cleaning, exiting the eclipse, deleting native folders, also I am looking for a reason and perfect fix of this below error as any developer wont be deleting every time when this issue arises, please help
error log
windowsphone build failed: com.worklight.builder.exception.WorklightBuildRuntimeException: Resource Manager - Error while reading XML file: /Users/Desktop/16th July/30thJuly-Map/test_Login/apps/test/windowsphone/native/Properties/WMAppManifest.xml (No such file or directory) Nested exception: /Users/test/Desktop/16th July/30thJuly-Map/test_Login/apps/test/windowsphone/native/Properties/WMAppManifest.xml (No such file or directory)
[2013-07-30 17:39:20] FWLST1040E: ipad build failed: com.worklight.builder.exception.WorklightBuildRuntimeException: Resource Manager - Problem reading info.plist file /Users/test/Desktop/16th July/30thJuly-Map/test_Login/apps/test/ipad/native/testLogintestIpad-Info.plist (No such file or directory) Nested exception: /Users/test/Desktop/16th July/30thJuly-Map/test_Login/apps/test/ipad/native/testLogintestIpad-Info.plist (No such file or directory)
[2013-07-30 17:39:21] FWLST1040E: iphone build failed: com.worklight.builder.exception.WorklightBuildRuntimeException: Resource Manager - Problem reading info.plist file /Users/test/Desktop/16th July/30thJuly-Map/test_Login/apps/test/iphone/native/testLogintestIphone-Info.plist (No such file or directory) Nested exception: /Users/test/Desktop/16th July/30thJuly-Map/test_Login/apps/test/iphone/native/testLogintestIphone-Info.plist (No such file or directory)
[2013-07-30 17:39:21] FWLST1040E: windows8 build failed: com.worklight.builder.exception.WorklightBuildRuntimeException: Resource Manager - Error while reading XML file: /Users/test/Desktop/16th July/30thJuly-Map/test_Login/apps/test/windows8/native/package.appxmanifest (No such file or directory) Nested exception: /Users/test/Desktop/16th July/30thJuly-Map/test_Login/apps/test/windows8/native/package.appxmanifest (No such file or directory)
[2013-07-30 17:39:23] FWLST1040E: android build failed: com.worklight.builder.exception.WorklightBuildRuntimeException: Resource Manager - Error while reading XML file: /Users/test/Desktop/16th July/30thJuly-Map/test_Login/apps/test/android/native/AndroidManifest.xml (No such file or directory) Nested exception: /Users/test/Desktop/16th July/30thJuly-Map/test_Login/apps/test/android/native/AndroidManifest.xml (No such file or directory)
[2013-07-30 17:39:24] A core eclipse exception has occurred: Failed to read project description file from location '/Users/test/Desktop/16th July/30thJuly-Map/test_Login/apps/test/android/native/.project'.
Thanks
djrecker
I got the same error in my eclipse after changing the project name by using Refactor->Rename
The below fix is for iPhone environment. You can try the same for other environment also.
The error says it cant find the info.plist file.Try to move to that location in your computer and see wether the file is there or not.
in your case ESILoginESIIphone-Info.plist
if you cant find the file. just see the ***-Info.plist in the same path and note down the ****
worklight will always append your porject name twice in info.plist file ( dont know why). For example if you have project name as ESI then your plist file name would be ESIESI-Info.plist.
i guess in your project file you have changed the name to ESILogin
Try to rename the project with **** which you found in above step.
Thats all.
Happy Building.
Please look in the Error Log view in Eclipse; there should be an exception trace there which could help us in identifying the root cause.
Can you reproduce this? Does it happen only when you create a new project and add all Mobile environments at once, or even when you add only one Mobile environment?
What is your Worklight version?
Delete the bin folder contents in your project and restart the server.
Deploy all the adapters and application again

jar files are different from different maven (same version)?

The jar file generated from my local maven (2.0.8) is different from the jar file generated from the enterprise central build (maven 2.0.8). All the source code and pom files are the same, as well as the repository link. But when I ran a job using the jar from central build, here is the error message:
Exception in thread "main" java.lang.ExceptionInInitializerError
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:25)
at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:122)
at java.lang.reflect.Field.acquireFieldAccessor(Field.java:918)
at java.lang.reflect.Field.getFieldAccessor(Field.java:899)
at java.lang.reflect.Field.get(Field.java:358)
at org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(XmlBeans.java:770)
(deleted....)
... 15 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:501)
... 17 more
Caused by: org.apache.xmlbeans.SchemaTypeLoaderException: XML-BEANS compiled schema: Incompatible minor version - expecting up to 23, got 24 (schemaorg_apache_xmlbeans.system.s4260D8D66C8BD97BA7A1A374DB7D9EB0.index) - code 3
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl$XsbReader.<init>(SchemaTypeSystemImpl.java:1522)
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.initFromHeader(SchemaTypeSystemImpl.java:260)
at org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl.<init>(SchemaTypeSystemImpl.java:183)
... 21 more
But the job ran successfully using the jar file generated from my local maven.
Can you give me any suggestions that what I should look into in order to solve this problem?
First i would suggest to update your Maven installation at least to Maven 2.0.11 (which is the newest for 2.0 line) but better to Maven 3...
I would check if you are using the same java compiler for both areas

teamcity 5.1 maven proxy configuration

I created a new build configuration and tried to run the same. However I encounter errors saying the artifacts could not be found in the repository. If I run the maven build from command line for the same workspace, the build works well. The proxy configuration has been mentioned in ./m2/settings.xml and the settings file has been mentioned in the build configuration. I tried even placing the proxy configuration in TeamCity\buildAgent\plugins\maven\conf\settings.xml but it does not seem to help. Kindly let me know if you have any pointers.
Caused by: org.apache.maven.plugin.InvalidPluginException: Unable to build project for plugin 'org.apache.maven.plugins:maven-site-plugin': POM 'org.apache.maven.plugins:maven-site-plugin' not found in repository: Unable to download the artifact from any repository[16:59:48]: org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-7[16:59:48]: from the specified remote repositories:[16:59:48]: central (http://repo1.maven.org/maven2)[16:59:48]: for project org.apache.maven.plugins:maven-site-plugin[16:59:48]: at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:293)[16:59:48]: at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(DefaultPluginManager.java:205)[16:59:48]: at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(DefaultPluginManager.java:184)[16:59:48]: at org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor(DefaultPluginManager.java:1642)[16:59:48]: at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1540)[16:59:48]: ... 19 more[16:59:48]: Caused by: org.apache.maven.project.ProjectBuildingException: POM 'org.apache.maven.plugins:maven-site-plugin' not found in repository: Unable to download the artifact from any repository[16:59:48]: org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-7[16:59:48]: from the specified remote repositories:[16:59:48]: central (http://repo1.maven.org/maven2)[16:59:48]: for project org.apache.maven.plugins:maven-site-plugin[16:59:48]: at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:605)[16:59:48]: at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository(DefaultMavenProjectBuilder.java:251)[16:59:48]: at org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion(DefaultPluginManager.java:277)[16:59:48]: ... 23 more[16:59:48]: Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository[16:59:48]: org.apache.maven.plugins:maven-site-plugin:pom:2.0-beta-7[16:59:48]: from the specified remote repositories:[16:59:48]: central (http://repo1.maven.org/maven2)[16:59:48]: at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:228)[16:59:48]: at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90)[16:59:48]: at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558)[16:59:48]: ... 25 more[16:59:48]: Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository[16:59:48]: at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:404)[16:59:48]: at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216)[16:59:48]: ... 27 more
Have you tried setting the settings.xml within the Maven installation
e.g. for my TeamCity installation /usr/local/apache-maven/apache-maven-2.2.1/conf/settings.xml
Don't forget that TeamCity will probably be running as its own user, so ~/.m2/settings.xml may not be where you think it is.