ClassNotFoundException in com.amazonaws.demos.polly.PollyDemo - java

I'm new to Maven and the AWS SDK. So I installed both and updated my Java SDK. Double checked all required path and classpath settings.
The AWS Polly manual (page 119 in the pdf) presents a demo code example, to test Polly.
Being in this for the very first time, I tried this example (pom.xml and PollyDemo.java). Calling Maven as written in the manual, I receive the ClassNotFoundException for PollyDemo (classpath to com.amazonaws.demos.polly package has been set).
With over 10 years Java experience I feel like a newbie.
Please help

you need to add aws-java-sdk-polly dependency into your pom.xml
file and update the project, you can find dependency below:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-polly</artifactId>
<version>1.11.77</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.soundlibs/jlayer -->
<dependency>
<groupId>com.googlecode.soundlibs</groupId>
<artifactId>jlayer</artifactId>
<version>1.0.1-1</version>
</dependency>
for more you can refer below link :
http://docs.aws.amazon.com/de_de/polly/latest/dg/examples-java.html
http://docs.aws.amazon.com/polly/latest/dg/examples-java.html

The example can be run if: AWS credentials are created and setted (1), a new project is started by creating an empty directory (e.g. 'my-app'),
opening a shell in 'my-app' and running the command 'mvn archetype:generate -DgroupId=com.amazonaws.demos.polly -DartifactId=polly-java-demo -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false' (2), and finally replace both the existing 'pom.xml' and hello world java file with the ones in the example (3).

Related

import com.amazonaws.services.s3 cannot be resolved

I want to use AWS S3 buckets with my Java 17 / Maven 3.8.5 app but when I add this to the pom.xml file
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.12.177</version>
</dependency>
I get a bunch of errors like these:
Failed to read artifact descriptor for com.amazonaws:aws-java-sdk-iotevents:jar:1.12.177
although when I add -core like this:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.12.177</version>
</dependency>
the errors go away in my pom.xml file but I dont think this is what I want.
What I want is to be able to import com.amazonaws.services.s3.AmazonS3; like this
import com.amazonaws.services.s3.AmazonS3;
import org.springframework.context.annotation.Configuration;
#Configuration
public class AmazonConfig {
public AmazonS3 s3() {
AWSCredentials awsCredentials = new BasicAWSCredentials("", "");
}
}
but I keep getting this error
The import com.amazonaws.services.s3 cannot be resolved
Im really new to Java so I'm not sure if the problem is from my Maven configuration or something else.
Thanks.
you may need to do a mvn install or mvn package, this way, you will download the dependency.
First of all check if the dependencies are pulled or not in the external dependencies section in the IDE. If its not there see if maven is configured properly.
What ide are you using?
If its eclipse force a maven update on the project. If it’s Intellij, invalidate caches from the file menu. Close the ide. Open the root directory of you project in file explorer and Delete any .preferences or .setting or any other unnecessary file or folder present on the source folder reated by the ide and after clearing all that open up IDE and see if that resolves the issue.
Also for s3 you’ll need this dependency
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId></dependency>
Really not sure what was wrong but restarting a new project worked.

Can I install the Graph Data Science (GDS) library embedded Neo4j in my Java applications?

Can I install the Graph Data Science (GDS) library embedded Neo4j in my Java applications? My solution is that I want to include Neo4j with GDS library in a Java project as the standalone Neo4j Server. I do not want to use Neo4j desktop because I also need to develop some functions in the project. I have ever installed it by using Maven dependencies and call a graph algorithm via the browser but I got a problem. The problem is shown below:
There is no procedure with the name `gds.list` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.
The steps of installation is exaplained as follows:
I add the dependencies to my project along the lines of the snippet below. This is usually done in the pom.xml file.
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>4.1.4</version>
</dependency>
<dependency>
<groupId>org.neo4j.gds</groupId>
<artifactId>proc</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.neo4j.gds</groupId>
<artifactId>core</artifactId>
<version>1.4.0</version>
</dependency>
I add syntaxs in neo4j.conf:
dbms.security.procedures.unrestricted=apoc.*, gds.*
dbms.security.procedures.whitelist=apoc.*, gds.*
After a reboot, I try to show a list of currently active settings in neo4j.conf directly from Cypher on Neo4j Browser:
CALL dbms.listConfig()
The value of "dbms.security.procedures.unrestricted" correctly shows on the browser.
Then, I call it again by using the command below. I found an error.
CALL gds.list()
After I call that command, I got a problem that I have show above and below.
There is no procedure with the name `gds.list` registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.
enter image description here
enter image description here
Do I have to call a graph algorithm via Neo4j Java driver?
Anyone got an idea what I am missing here? I would really appreciate your help.

java.lang.NoClassDefFoundError: com/google/common/base/Joiner

I'm hitting this error when run my package jar:
java.lang.NoClassDefFoundError: com/google/common/base/Joiner
I simply call: java -jar xxx.jar
I already added the dependency in my pom.xml:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
<scope>compile</scope>
</dependency>
I'm using IntelliJ editor. I have a unit test for the function which uses the Joiner class. It runs successfully from within IntelliJ.
I put my cursor on the Joiner and use "command + B" to search for the declaration of the Joiner class. It opens the Decompiled source code page, and on the heading it shows the path as: guava-18.0.jar/com/goog/common/base/Joiner
So everything looks correct.
Can anyone help me figure out why do I hit this error?
You could shade guava into your jar but it would result in a bigger jar file. But that way it would be included in your programm 100%. Read more about shading maven depencies into your jar file in the official maven-documentation: http://maven.apache.org/plugins/maven-shade-plugin/

BigQuery: How to load library into java code

I am a new dev in Bigquery.
I am following tutorial in https://developers.google.com/bigquery/bigquery-api-quickstart with Java code and imported library from https://developers.google.com/bigquery/client-libraries.
However, I couldn't load library into Java code such as
import com.google.api.services.bigquery.model.DatasetList;
import com.google.api.services.bigquery.model.GetQueryResultsResponse;
import com.google.api.services.bigquery.model.Job
Please tell me know how to solve this case.
Thanks
You need to add the necessary .jar files (separated by :) to your classpath, i.e.
javac -cp path/to/jar1:path/to/jar2 <your_class.java>
java -cp path/to/jar1:path/to/jar2 <your_class>
alternatively you can add the .jar files to the CLASSPATH environment variable, i.e. (in unix systems)
export CLASSPATH=$CLASSPATH:/path/to/some.jar:/path/to/some/other.jar
This can change depending on your environment (i.e. if you are running these in a webapp server)
if you are using maven this is done easily with the following 2 dependence
(you can changes the version to the latest one)
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev12-1.19.0</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-bigquery</artifactId>
<version>v2-rev168-1.19.0</version>
</dependency>
Are you using Maven and the BigQuery Java Client? It is recommended to use the Java client. If so, you can easily set it up by configuring your pom.xml file:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery</artifactId>
<version>1.111.1</version>
</dependency>
More info on the BigQuery Java client: https://github.com/googleapis/java-bigquery

Why do I get compilation error "org/codehaus/groovy/control/CompilationFailedException"?

I am trying to compile my JasperReports template using an Ant script and Java. I am getting this error:
jasper java.lang.NoClassDefFoundError:
org/codehaus/groovy/control/CompilationFailedException
There is nothing complex in the template, but I still can't compile.
You will have to set the language value in your template to Java. There are two ways you can do this:
If you are using iReport, select the root object in your Report Inspector (the one with the same name as your report). Then in the Properties window, select Java from the Languages drop-down.
If you are editing the raw mark-up in the JRXML file, remove language="groovy" from the file altogether.
Then try to recompile - you should be sorted. :)
If you are using Maven, you must add the groovy dependency in your pom.xml.
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.10</version>
</dependency>
In another case, you must add the library groovy in your lib folder (WEB-INF/lib)
Another solution is to copy groovy-all-{version}.jar from the groovy binary distribution into the application's.
If you are using TIBCOJaspersoftStudio:
Download latest groovy 2.4.* jar from https://groovy.apache.org/download.html
Unpack and get this file ./groovy-2.4.10/embeddable/groovy-all-2.4.10.jar
Put the jar in ./TIBCOJaspersoftStudio-6.3.1.final/plugins
Delete the old jar: ./TIBCOJaspersoftStudio-6.3.1.final/plugins/groovy-all_2.4.5.jar
Change the languge to java in JRXML (ex:- language="java") or add groovy*.jar to your project’s classpath.
Your are missing the a important library groovy in path.
case 1 : if you are using Maven add this dependency with compatible version in pom.xml
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>3.0.4</version>
</dependency>
Case 2 : Second way is add the compatible version of groovy jar in class path
Url to download groovy jar : http://groovy-lang.org/download.html

Categories