Unable to copy war to Google Bucket - java

I am trying to copy the the snapshot from my google cloud instance to the google bucket.
Maven is being used to compiling the code into a snapshot and snapshot is available at the below location -
/home/bhaskarhnarula/getting-started-java/bookshelf/6-gce/bookshelf-6-1.0-SNAPSHOT.war
In my build file, in my build sh, I am giving the following copy command which is throwing CommandException as below -
CommandException: No URLs matched: target/bookshelf-1.0-SNAPSHOT.war
Below command is used for moving the snapshot to the cloud -
+ gsutil cp target/bookshelf-1.0-SNAPSHOT.war gs://cloudpoc2bucket
Aim is to host a sample application on a new instance created in Google Cloud via Google-Compute-Engine. Any leads would be helpful. Thanks!

No clue if you figured it out, but I ran into the same issue and found out that there was a typo in the script in the example; target/bookshelf-1.0-SNAPSHOT.war doesn't exist, it's actually called target/bookshelf-6-1.0-SNAPSHOT.war. The error makes complete sense then, since the script's asking gsutils to upload a non-existent file. So if you look in the makeBookshelf script, you should see a line labeled
WAR=bookshelf-1.0-SNAPSHOT.war
it should actually be
WAR=bookshelf-6-1.0-SNAPSHOT.war
Edit that and it should run perfectly fine.
I've already sent in a pull request to get this fixed in the repository. Hope you figured it out!

Related

Exception in thread "main" java.net.UnknownHostException: services.gradle.org

I am getting the below error when executing gradle.bat. I have checked the URL path and it looks fine. The URL is defined like this in the wrapper properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip
Here's the error message:
Downloading https://services.gradle.org/distributions/gradle-2.1-bin.zip
Exception in thread "main" java.net.UnknownHostException: services.gradle.org at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)
Could someone help me on this?
Go to "C:\Users\[yourusername]\.gradle\" folder (hidden folder - Go to folder option and enable show hidden files if folder is not showing up)
Look for file "gradle.properties" if DOES NOT (most likely this would be the case) exists, Create it under "C:\Users\[yourusername]\.gradle\
Copy and paste following code (More detail ... https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties ... look for "20.3 Accessing the web via proxy" for https and user/pwd variables)
systemProp.http.proxyHost=[PROXY SERVER]
systemProp.http.proxyPort=[PROXY PORT]
save and try again
look for gradle.properties file open it and change from 'distributionUrl=https\' to 'distributionUrl=http\' that will fix it.
I was facing the same problem when I was connected to WiFi with a download speed of 80 Mbps which is good enough, I guess. After spending hours while still being clueless, I just changed the network. Connected to hotspot from my mobile data with a much lower download speed of around 4 Mbps. The error vanished! Maybe something was wrong with the WiFi.
1) Go to your project directory
2) Find below file on your project directory:
gradlew
gradlew.bat
3) Edit gradlew file and change DEFAULT_JVM_OPTS variable value as below:
DEFAULT_JVM_OPTS="-Dhttp.proxyHost=XXXX -Dhttp.proxyPort=XXXX -Dhttp.proxyUser=XXXX -Dhttp.proxyPassword=XXXX -Dhttps.proxyHost=XXXX -Dhttps.proxyPort=XXXX -Dhttps.proxyUser=XXXX-Dhttps.proxyPassword=XXXX"
save it.
4) Edit gradlew.bat file and change DEFAULT_JVM_OPTS variable value as below:
set DEFAULT_JVM_OPTS=-Dhttp.proxyHost=XXXX -Dhttp.proxyPort=XXXX -Dhttp.proxyUser=XXXX -Dhttp.proxyPassword=XXXX -Dhttps.proxyHost=XXXX -Dhttps.proxyPort=XXXX -Dhttps.proxyUser=XXXX-Dhttps.proxyPassword=XXXX
save it.
5) Now run your "gradlew clean build" and check.
Please set your appropriate value on the place of XXXX
Note: gradlew is use for linux system user and gradlew.bat is user for window system user
Make sure you have enough bandwidth for the download.
I had the same problem just 15 minutes ago (that's why I'm on this page in the first place). Same error message --- and then I noticed that my uTorrent client was occupying the whole datalink. So I killed it, and run gradlew.bat again. This time everything went just fine...
I had similar issue, fixed by following steps:
Created: C:\Users\<username>\.gradle\gradle.properties
Values entered in the property file as below:
systemProp.https.proxyHost="company proxy server"
systemProp.https.proxyPort="company proxy port "
systemProp.https.proxyUser="user login "
systemProp.https.proxyPassword="password "
systemProp.https.nonProxyHosts=localhost
You can try HTTP instead of HTTPS.
I had this problem for a flutter project and what I did was create a new flutter project with the same name as my problem flutter project. I then copied the files from the "android" directory from the new project into the existing flutter project. Basically some set up file was messed up. I don't know which one, but this did the trick
Maybe it's a bit late but you might have to try to UPDATE your ANDROID STUDIO. Had a similar problem, working on Linux pop_os (Ubuntu derivative). So I had Android SDK on my $PATH and everything set well but Ionic v3 build was having a Gradle issues while trying to download.
I simply updated my Android Studio and tried again and it worked. Good luck
Go to your command prompt and set the HTTP and HTTPS proxy
Execute the below in your cmd -
set HTTP_PROXY=http://<proxyservername>:<port>
set HTTPS_PROXY=http://<proxyservername>:<port>?
Once you have set your proxy variables , try rebuilding or re-assembling your application / project
I've got an issue with Android studio. The value of the distributionUrl field in the graddle-wrapper.properties has been changed during package name refactoring.
If error is under flutter
Just hoping this might help someone in the future...
When i encountered that error in flutter, I just had to change network from the current one which seemed unstable, am sure build.gradle was trying to get more resources from internet.
try disconnecting and reconnecting to the network
try changing networks(wifi- date or data - wifi)
In my case disconnecting from my office VPN fixed the problem
Just remove your .android and .gradle folder from C:\Users\[Your user name]\
Uninstall android studio and reinstall it
Open any simple android studio project and run it. It will automatically set up the Gradle and other things
Close the project and run your flutter project. It works for me!!!

Cannot run Flume because of JAR conflict

I've installed Flume and Hadoop manually (I mean, not CDH) and I'm trying to run the twitter example from Cloudera.
In the apache-flume-1.5.0-SNAPSHOT-bin directory, I start the agent with the following command:
bin/flume-ng agent -c conf -f conf/twitter.conf -Dflume.root.logger=DEBUG,console -n TwitterAgent
My conf/twitter.conf file uses the logger as the sink. The conf/flume-env.sh assigns to CLASSPATH the flume-sources-1.0-SNAPSHOT.jar that contains the definition of the twitter source. The resulting output is:
(...) [ERROR org.apache.flume.lifecycle.LifecycleSupervisor$MonitorRunnable.run(LifecycleSupervisor.java:253)] Unable to start EventDrivenSourceRunner: { source:com.cloudera.flume.source.TwitterSource{name:Twitter,state:IDLE} } - Exception follows. java.lang.NoSuchMethodError:
twitter4j.FilterQuery.setIncludeEntities(Z)Ltwitter4j/FilterQuery;
at com.cloudera.flume.source.TwitterSource.start(TwitterSource.java:139)
The conflict results from a FilterQuery class that is defined elsewhere in the flume lib and that does not contain the setIncludeEntities method. For me, the file that contains this class is the twitter4j-stream-3.0.3.jar and I cannot exclude the file from the classpath as suggested here.
I believe this experience was quite frustrating for you, for me it was for sure. The main problem is, both the files, flume-sources-1.0-SNAPSHOT.jar and twitter4j-stream-3.0.3.jar contains the same FilterQuery.class. That is why the conflict message is generated in the log file.
I am not a Java or Big Data expert, but I can give you an alternate to this problem. Download the Twitter4j-stream-2.6.6.jar or lower version from here and replacethe twitter4j-stream-3.0.3.jar. All the 3.X.X uses this class. After replacing, everything should work fine. But you may get some heap error after downloading huge amount of tweets. Please google the solution as it was resolved in 3.X.X files.
-Edit
Also, please don't forget to download and replace all the twitter4j files in /usr/lib/flume-ng folder. Namely, twitter4j-media-support-2.2.6.jar, twitter4j-stream-2.2.6.jar and twitter4j-core-2.2.6.jar. Any mismatch related to version among these files will also create problem.
As suggested in the post a problematic file can be search-contrib-1.0.0-jar-with-dependencies.jar too.
You need to recompile flume-sources-1.0-SNAPSHOT.jar from the git:https://github.com/cloudera/cdh-twitter-example
Install Maven, then download the repository of cdh-twitter-example.
Unzip, then execute inside (as mentionned) :
$ cd flume-sources
$ mvn package
$ cd ..
This problem happened when the twitter4j version updated from 2.2.6 to 3.X, they removed the method setIncludeEntities, and the JAR is not up to date.
PS: Do not download the prebuilt version, it is still the old.
Simply rename all twitter4j-stream* jar files and rerun your flume. It will work with charm. :)
I had the same problem and at last I solved following these steps:
First I renamed all jar files in jarx: from twitter4j-stream-3.0.3.jar -> twitter4j-stream-3.0.3.jarx, ...
This solved the error, but when it tried to estabilish connection, I got error 404:
(Twitter Stream consumer-1[Establishing connection])
[INFO - Twitter4j.internal.logging.SLF4JLogger.info(SLF4JLogger.java:83)] 404:
The URI requested is invalid or the resource requested, such as a user, does not exist.)
After reading this page (https://twittercommunity.com/t/twitter-streaming-api-not-working-with-twitter4j-and-apache-flume/66612/11) finally I solved downloading a new version of twitter4j (in the page there's a link).
Probably not the best solution, but worked for me.

How to access ChangeSets in Eclipse (Mylyn/Team)?

I want to access the ChangeSets of SVN, CVS and Git programatically via Java. I.e. I want the data which is shown in the "Synchronize"-view.
I tried several approaches to find the correct usage in the code, and here's the few documentation I could find (but without success):
I managed to access the Synchronize-View via TeamUI.getSynchronizeManager(), but not the changesets.
An other thing I tried was to get the cangesets via FocusedTeamUiPlugin.getDefault().getContextChangeSetManagers() (got the manager and then the ChangeSetProvider where I tried to get the ChangeSets) - but they always are empty (because they are created when I first call it).
So, how can I access ChangeSets (with Java) in Eclipse (Mylyn)? In the end, I need the number of commits and code churn (loC added/removed/edited). Or is there probably an other, better approach?
Any help is appreciated really much!
I don't think Eclipse has implemented this feature as a public API yet. However, these links may help:
Internal changeset class and other API: http://www.cct.lsu.edu/~rguidry/ecl31docs/api/index.html?org/eclipse/team/internal/core/subscribers/ChangeSet.html
A feature enhancement request where they talk about why they haven't implemented it yet (but it's dated 2008, however the bug is still open?) https://bugs.eclipse.org/bugs/show_bug.cgi?id=116084
Sorry I couldn't be of more help! Maybe this will help you in the right direction...
You could perhaps go around Eclipse:
Apply rsync to get the CVS "*,v" files from the CVS server. It works for me.
Apply cvs2svn's "cvs2git" command to the CVS repos. It works for me.
Apply "git svn clone" (documented under "git-svn") to the SVN repos. I have not tried it.
Finally, use JGit's API to get the changesets from all of the repos, which at this point are all git repos. I think you'll particularly need these:
class Git
class FileResolver
class BaseConnection
interface Repository
class CheckoutCommand
class LogCommand
class RevCommit
class DiffCommand
class DiffEntry
class DiffFormatter
I've looking for this for 1 month now.
I tried to programm a plugin for eclipse, which is able to read the changeset of a Project ("working copy" of the repository).
What I've done now is an ugly work-around.
I used Runtime.exec() to run a cmd-command / Shell- command.
If you install a svn-commandline Client, you can type svn status -v -u
It gives you a list of all files of the working copy with the changeset info.
Then you can parse through the list to find all lines which start with "M" - for "modified" to get the Path of the changed file.

Play in Production - Secure cannot be resolved to a type

I have developed a little program for myself. After testing and
finishing it locally I now wanted to put it on my server.
I get this error:
Compilation error The file /app/controllers/Links.java could not be
compiled. Error raised is : Secure cannot be resolved to a type
It is thrown at this line:
#With(Secure.class)
In the Class Links I have:
import play.mvc.With;
import controllers.*;
#With(Secure.class)
public class Links extends CRUD {
}
I have installed play 1.2.2 on my server. Play is running probably. I
type in the terminal "play start appname" and opened serverIp:9010 to
see this error. If I type "play precompile appname" everything seems
to work.
In the subfolder /modules of the app I have two text files, one "crud"
and one "secure" which point to the modules location on the server. I
also have defined the modules in dependencies.yml like this:
require:
- play
- crud
- secure
In the application.conf I have a Production definition for my server
with the proper Server-ID like this:
%server1.application.mode=PROD
Any idea why this isn't working?
I have solved it. For future reference:
I had an old process of play running. Found it with ps -aux and then kill PID. After that I started the application again with play start.
It's now running fine :)
Thanks for you help!
Declaring the secure module in dependencies.yml file is the first step.
Next you have to type the shell command "play dependencies" in order to resolve them.
Just have a glance on the documentation here : http://www.playframework.org/documentation/1.2.2/dependency#Theplaydependenciescommand
Have fun with Play!
Sometimes you have to refesh the classpath settings by using play eclipsify again. (depends on the IDE you are using)
I had to insert this line to application.config
module.secure=${play.path}/modules/secure
I had the same problem in my development environment, but not in my production server. I tried to solve by the module documentation, the accepted answer here, and many others with no success.
My solution was to download again play framework (1.2.7) and replacing it in the path where I installed first.
Hope this can guide someone else with the same issue.
Regards.

NoClassDefFoundError when running app in emulator/phone [Update to previous question]

This is an update to this question that I asked earlier today.
Brief reiteration of the problem: I have an Android app that requires use of Amazon's Android SDK for AWS. I add the necessary libraries (JAR files) to my Eclipse build path. However, when I run the app, the app crashes with a NoClassDefFoundError.
After a bit of investigation, I have isolated the code that causes the error. I have made a simple dummy Android app that uses the apparently buggy code. The source code for the single Activity is here. And here is the logcat output.
I noticed a couple of odd things about this. If the library wasn't being added correctly, it should fail at line 34:
credentials = new BasicAWSCredentials( accessKeyId, secretKey );
But it doesn't. Instead, it fails at line 62, which chains up to line 48.
Line 62:
sdb = new AmazonSimpleDBClient( credentials );
Line 48 (with part of 47):
list.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, getInstance().listDomains().getDomainNames()));
The funny thing is, the sample project provided with the SDK works perfectly. Here is the code for SimpleDB, which is one of the source files. I have essentially copied and pasted some of the code calling for access to Amazon's SimpleDB, yet mine fails and the sample doesn't.
So, anyone have any ideas?
Turns out, the jar files in the AWS SDK weren't properly built. It appears that they missed an old Apache library that is no longer publicly distributed. Amazon has updated the download, and the libraries no longer throw a NoClassDefFoundError.
Source: Forum post on the AWS mobile dev forum
In the most cases NoClassDefFoundError means that duplicate versions of the class are on the classpath. I think you should check your dependencies/libraries for duplicate .class files. Please check this file first in your jar-s: org.apache.commons.httpclient.params.HttpClientParams
Hope it helps!

Categories

Resources