i'm following a tutorial to understand how cassandra works,
but i have a problem with an import
import static com.datastax.spark.connector.CassandraJavaUtil.*;
this import is not recognized, especially this row:
javaFunctions(productsRDD, Product.class).saveToCassandra("java_api", "products");
my pom.xml is this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sparkexamples</groupId>
<artifactId>cassandraExample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cassandraExample</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_2.10</artifactId>
<version>1.3.0-M1</version>
</dependency>
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector-java_2.10</artifactId>
<version>1.3.0-M1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-streaming_2.10</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
</project>
how i can fix it?
thanks in advance.
Use this import, you are following the old API.
import static com.datastax.spark.connector.japi.CassandraJavaUtil.javaFunctions;
Check your /.m2/ directory for the Spark connector jar file. If it's not present, do a mvn -U which will force update the dependencies. If it's there, delete that directory from .m2 (only the Spark connector directory) and do a mvn clean compile> which should download the jar file again.
If you're working with Eclipse and not CLI, then you can right click on the project in Eclipse -> Maven -> Update project. Not sure about how it works in Netbeans/IntelliJ but there must be similar options there as well.
Also please check if your mvn can connect to the internet from your system. I hope this is not the case but there could be a chance the your mvn could be working offline.
Please check your pom:
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector-java_2.10</artifactId>
<version>1.3.0-M1</version>
</dependency>
and
<dependency>
<groupId>com.datastax.spark</groupId>
<artifactId>spark-cassandra-connector_2.10</artifactId>
<version>1.3.0-M1</version>
</dependency>
Please check if this is causing duplicates and there is a conflicting jar.
Related
IntelliJ does not let me import com.microsoft even though Maven resolves the dependency and it appears as a Module in my project settings (thus should be in the classpath).
External dependency resolves:
Modules:
POM file has this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.arcologydesigns.rest</groupId>
<artifactId>ads-webapp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>springexample Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<spring.version>4.0.5.RELEASE</spring.version>
<jdk.version>1.8</jdk.version>
<jackson.version>2.2.3</jackson.version>
<!--<sqlserver.version>4.2.6420.100</sqlserver.version>-->
<sqlserver.version>4</sqlserver.version>
<build.scm.revision>SCM_IDENTIFIER</build.scm.revision>
<build.number>BUILD_NUMBER</build.number>
<build.id>BUILD_ID</build.id>
<build.job.name>BUILD_JOB_NAME</build.job.name>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>${sqlserver.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20120521</version>
</dependency>
</dependencies>
<build>
<finalName>ads-webapp</finalName>
</build>
</project>
I used the following to install sqljdbc driver (which I downloaded from MSDN) for Maven: http://techmajik.com/2014/04/24/how-to-setup-maven-dependency-for-microsoft-sql-server/
Try adding it directtly to Maven repository like this:
mvn install:install-file -Dfile=sqljdbc4.jar -Dpackaging=jar -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc4 -Dversion=4.0
and then add this to your POM.xml
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
for more detailes you can read this topic:
http://claude.betancourt.us/add-microsoft-sql-jdbc-driver-to-maven/
You need to do this because SQL Server driver is not included in maven repository - and you need to install it yourself.
You can directly use this below dependency:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>6.1.0.jre8</version> </dependency>
The older sqljdbc driver (v 4.0) jar file is available at the maven repo :
https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc4/4.0
Download and install it using the command as mentioned by user4198625 taking care to
make sure that maven (mvn) in in your PATH
JAVA_HOME is correctly defined in your env variables (for Windows). This is expecially important if you are running the mvn batch file.
For the command to work as is, you need to execute it from the directory where the jar file is present.
jung2 is in maven repository, here and here.
But my Eclipse does not finding it out:
Code is here:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tests.jung</groupId>
<artifactId>TryJung</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>net.sf.jung</groupId>
<artifactId>jung2</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</project>
UPDATE
Sorry can't accept answers about dependency type, because it is not complete. The code for jung dependency was taken from Maven repository directly:
So, I need an explanation, why doesn't code, taken from repository site, work actually.
What is happening here, who is "guilty"?
As already said, you are addressing a pom file. Which is, in a sense, correct, but if you want to compile you will need to add the actual jars in the dependencies section, such as:
<dependencies>
<dependency>
<groupId>net.sf.jung</groupId>
<artifactId>jung2</artifactId>
<version>${jung.version}</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>net.sf.jung</groupId>
<artifactId>jung-api</artifactId>
<version>${jung.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.jung</groupId>
<artifactId>jung-visualization</artifactId>
<version>${jung.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.jung</groupId>
<artifactId>jung-graph-impl</artifactId>
<version>${jung.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.jung</groupId>
<artifactId>jung-algorithms</artifactId>
<version>${jung.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.sf.jung</groupId>
<artifactId>jung-io</artifactId>
<version>${jung.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
Do not forget to define the version property also in the properties section:
<properties>
<jung.version>2.0.1</jung.version>
</properties>
Hope this helps.
The problem is simply the artifact you are adressing is a pom file and not a jar file. That's the reason for the message.
just stumbled into the same problem pit. apparently these are pom files purely for building/documenting (all) sub-projects (or submodules in maven speak) of a project (in this case jung2)
they can't be used as a dependency in a useful way
actually you can depend on them with <type>pom</type> but will just include the dependencies of that pom but not it's modules.
see here for a more complete explanation:
How to use POMs as a dependency in Maven?
I have maven project. Maven build complete SUCCESS. But i can't make this project.
[INFO] BUILD SUCCESS
Project contains one module. Idea can't see dependencies.
Error:(3, 38) java: D:\Dropbox\Programming\java\spring\springBook\src\main\java\ch14\validator\ContactTestValidator.java:3:
package org.springframework.stereotype does not exist
POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>springBook</groupId>
<artifactId>springBook</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- Shared version number properties -->
<properties>
<org.springframework.version>3.2.3.RELEASE</org.springframework.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<!--для валидации бинов необходима-->
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<!--Spring Data JPA использует его - добавим и пользуемся-->
<!--API для работы с датами-->
<!--ch14 validator-->
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<!--ch14 validator-->
<!--API интерфейса JSR-303-->
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dependency>
<!--ch14 validator-->
<!--API, которая поддерживает интерфейс JSR-303 - BeanValidation-->
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.0.2.GA</version>
</dependency>
<dependency>
<!--для валидации. (#Type...)-->
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.6.2</version>
</dependency>
<!--Spring framework-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${org.springframework.version}</version>
</dependency>
</dependencies>
<build>
<finalName>springBook</finalName>
</build>
</project>
Could you help me? Unfortunately, I can't add screenshots..
There are screenshots:
http://screencast.com/t/iNaWO9gy
http://screencast.com/t/iBGTyMpgH
Project settings - Libraries - empty;
reimport didn't help;
Do the following steps:
Find your pom.xml in your files
Right click on it --> Maven --> Import
Wait for the project to load :D
Press ctrl+alt+shift+s (This opens the Projects window.)
Go to libraries and see if they are empty (they shouldnt)
If they are post your full pom.xml please so I can see the problem
If you still have a problem got to File --> Invalidate Caches
/Restart
Go to maven and Reimport All Maven Projects
Option Maven -> Reimport
should force Intellij to reload all dependencies. Alternatively, as mentioned in comments you can click the Reimport All Maven Projects button in Maven Projects view.
In my case, I had my own apache-maven-3.5.2 folder and a misconfiguration created my problem. Maybe it's your case too:
In rush, I set the local repository to C:/my/folder/apache-maven-3.5.2/settings.xml, but it must be a folder so Maven didn't allow me to download the dependencies. Then I changed the default (in the picture) and it worked.
Open the module dependencies (press F12 on the module), go to Modules -> Dependencies and make sure maven imports are part of the of this.
Try to import the project from sources, if this answer didn't help you.
The following worked for me.
Deleted the maven dependency from my local repository
mvn clean install downloaded the dependency again
File --> Invalidate Caches/Restart
I still saw the compilation error
on my mac, I hit option + enter, intellij asked me to add the jar to classpath
build -> make project
I had faced the same problem, and the issue was small. I had changed the location of settings.xml file of maven and Intellij was picking up the default from C:\users\.m2\settings.xml
So point your maven settings.xml to the correct file as below:
File--> Settings--> Build, Execution, Deployment--> Maven
then on the right window, override "User settings file" to the settings.xml where you have in your local disk.
If you have installed maven in a non-default location then this file you can find in:
\apache-maven-3.2.3\conf\settings.xml
Right click on pom.xml and click Add as Maven Project
I just installed m2e (the Maven Eclipse plugin) and created a new Maven Project with a Quickstart archetype. I then went to the official Maven repo to pull down GWT 2.5.1's dependencies, and see that it wants you to add the following <dependency> element to your project's pom.xml file:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.5.1</version>
</dependency>
So, altogether, my pom.xml looks like:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.me.myorg</groupId>
<artifactId>maven-resolver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>maven-resolver</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
</project>
I am getting the following error:
Missing artifact com.google.gwt:gwt:jar:2.5.1
And furthermore, in Eclipse's Package Explorer, under my project's Maven Dependencies library, nothing is resolving.
What's going on here? Thanks in advance!
Update: the contents of ~/.m2/repository/com/google/gwt/gwt/2.5.1 are as follows:
gwt-2.5.1.jar.lastUpdated gwt-2.5.1.pom.sha1
gwt-2.5.1.pom _maven.repositories
This gwt dependencie it's a parent pom for the gwt project. This means that the repo will only contain the hash and the pom, but not the jar.
You need to use two libraries: gwt-servlet and gwt-user:
I've found this configuration for GWT development (maybe you don't need to put the <scope> as described):
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>2.5.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.5.1</version>
<scope>provided</scope>
</dependency>
<dependencies>
Remove your dependencies and update your pom with these two shown above.
You can also use the gwt-maven-plugin to manage your gwt project and deploy via maven. I've found this information there.
I hope that works!
Im trying to compile this project h__p://ross-warren.co.uk/my-twitter-clone-using-jsp-and-cassandra/
I have downloaded it, and spend almost one day searching for all dependency jar files and still I was not able to run that project. When I did some search I have discover maven. So I've downloaded it, in eclipse I click convert to maven or something, I've added some dependecy records to pom.xml and I still Im not able to run the project. There are some errors in jsp files. These errors werent there befoe.
for example in file LogChech.jsp
<jsp:useBean id="User"
class="uk.co.ross_warren.litter.stores.UserStore"
scope="session"
></jsp:useBean>
I have error Undefined type: UserStore.
I dont know where is the problem but I think there is somethign wrong with packages, becase before project conversion I had all java files in packages (at least eclipse showed package icon) and now there is only normal folder icons and folder tree structure with all java files however the first line in java files is package something which is fine I think.
thank you for your help
EDIT
this is my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Cinnamon</groupId>
<artifactId>Cinnamon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>me.prettyprint</groupId>
<artifactId>hector-core</artifactId>
<version>1.0-4</version>
</dependency>
</dependencies>
<packaging>war</packaging>
</project>
This is the first image how it looked like before maven conversion
http://oi39.tinypic.com/2q84o5z.
And this is how it looks like now
http://oi44.tinypic.com/14nmgyf.
ok stack overflow says I cant submit images, so please take that url and add jpg extension to see image
The standard maven directory layout expects java sources to be in src/main/java and web resources in src/main/webapp. So your java sources directly in src weren't even compiled. These directories can be configured in the build section of your pom.xml. To set the directory for web resources you also have to configure the maven-war-plugin.
Edit: It seems you were also missing some dependencies, the pom below compiles without errors on the command line. I'm not an eclipse user myself but this should work in eclipse too.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Cinnamon</groupId>
<artifactId>Cinnamon</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<directory>build</directory>
<sourceDirectory>src</sourceDirectory>
<outputDirectory>build/classes</outputDirectory>
<!-- not used in your project -->
<testSourceDirectory>srcTest</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>me.prettyprint</groupId>
<artifactId>hector-core</artifactId>
<version>1.0-4</version>
</dependency>
<dependency>
<groupId>org.expressme</groupId>
<artifactId>JOpenId</artifactId>
<version>1.08</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.6.2</version>
</dependency>
</dependencies>
</project>