I am trying to get 51Degrees.mobi to work with my Maven, JSF and Java project however I am having no luck so far. I have downloaded the 2 jars from http://51degrees.mobi/Support/Documentation/Java.aspx and followed the instructions. I now have a filter which looks like this
import fiftyone.mobile.detection.BaseDeviceInfo;
import fiftyone.mobile.detection.Provider;
import fiftyone.mobile.detection.binary.BinaryException;
import fiftyone.mobile.detection.binary.Reader;
public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String s = httpRequest.getHeader("user-agent");
//Create a Provider object
Provider p;
try {
p = Reader.create();
} catch (BinaryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Provider p = Reader.create(PATH_TO_PREMIUM_DATA);
//Read in a HttpServletRequest or User Agent String
BaseDeviceInfo b = p.getDeviceInfo(s);
//Get the value of a property
String result = b.getFirstPropertyValue("IsMobile");
//Check the property value
if(result.equals("True")){
System.out.println("This is mobile");
}
if(result.equals("False")){
System.out.println("This is not mobile");
}
//Before exiting your application, ensure you dispose of the Provide to
//release it's resources such as it's thread pool
p.destroy();
}
Thats throws no errors. From looking online I have found the dependancy I must add to the pom file and I have it as such
<dependency><!-- Start 51Degrees.mobi dependencies -->
<groupId>mobi.51degrees</groupId>
<artifactId>detection</artifactId>
<version>2.1.15.1</version>
</dependency><!-- End 51Degrees.mobi dependencies -->
Again no errors are thrown in the file itself, however when I use mvn clean install in the directory I get the following error
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[18,32] error: package fiftyone.mobile.detection does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[19,32] error: package fiftyone.mobile.detection does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[20,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[21,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[45,4] error: cannot find symbol
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[47,7] error: cannot find symbol
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[50,11] error: cannot find symbol
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[60,4] error: cannot find symbol
[INFO] 8 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.730s
[INFO] Finished at: Wed Nov 14 12:45:35 GMT 2012
[INFO] Final Memory: 16M/39M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default- compile) on project redirectionportal: Compilation failure: Compilation failure:
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[18,32] error: package fiftyone.mobile.detection does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[19,32] error: package fiftyone.mobile.detection does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[20,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[21,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[45,4] error: cannot find symbol
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[47,7] error: cannot find symbol
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[50,11] error: cannot find symbol
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[60,4] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Anyone have any ideas?
As per the rules, I state that I work for 51Degrees.mobi as a Java developer. I am not sure from looking at the page at this time if you solved your problem? So I thought I would add some more information.
Firstly, If you have two Jar files then you are using 2.1.16.1 not 2.1.15.1, although this should not directly effect your problem I thought I would say for clarity :).
Also, 51Degrees.mobi's version 2.1.16.1 solution was recently made available via the maven central repository, after the current answers were posted. So now all you should have to do is add this dependency to your pom:
<dependency><!-- Start 51Degrees.mobi dependencies -->
<groupId>net.sourceforge.fiftyone-java</groupId>
<artifactId>51Degrees.mobi.detection.core</artifactId>
<version>2.1.16.1</version>
</dependency><!-- End 51Degrees.mobi dependencies -->
If you wished to use our second jar just replace "core" with "webapp".
Make sure you have 51Degrees.mobi in your repository (local or remote). I did a quick search in maven public repository and i cannot find it.
If the jar is in your local folder some where. You can use
mvn install:install-file -Dfile=your-artifact-1.0.jar \
[-DpomFile=your-pom.xml] \
[-Dsources=src.jar] \
[-Djavadoc=apidocs.jar] \
[-DgroupId=org.some.group] \
[-DartifactId=your-artifact] \
[-Dversion=1.0] \
[-Dpackaging=jar] \
[-Dclassifier=sources] \
[-DgeneratePom=true] \
[-DcreateChecksum=true]
check the link maven install plugin
Try to find the jar in your repository:
The jar should reside here:
~/.m2/repository/mobi/51degrees/detection/2.1.15.1/
If you find it there, check whether it contains the classes under package
fiftyone.mobile.detection
-- Update --
In case you don't find this jar, you can use one of the following options:
Use ''system'' scope dependency - it makes your build platform/environment dependent so I don't recommend it, although its the easiest way.
Use mvn install:install-file so that it will place your jar into your local maven repository. Its much better than the first method, but you still will need to use this command before running maven in each local environment / your local repository gets purged...
Maintain your own maven repository somewhere on server, map the maven to use this repository. This is by far the best approach I'm aware of. The best will be to work with repository proxies like 'Nexus' or 'Artifactory'. In the worst case you can create a repository as a plain file system and make it accessible through web server (like apache).
In this repository you'll be able to store thirdparty jars that don't exist in the public maven repository, your own artifacts, or maybe artifacts which are not free/opensource and therefor can't be maintained in the public maven repo (like commercial software that you can use).
Hope this helps
Related
I wanted to deploy my application to heroku server and I am facing this problem. Any idea?
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.339 s
[INFO] Finished at: 2021-08-09T04:05:01Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project russion_spring_boot: Fatal error compiling: invalid target release: 11 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
! ERROR: Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
! Push rejected, failed to compile Java app.
! Push failed
<properties>
<java.version>15.0.1</java.version>
</properties>
Logs depict the error - invalid target release: 11. Basically this error means that you have mentioned higher/mismatched version of Java in maven compiler's source and target java version settings in your pom.xml compared to the JDK which is being pointed out by JAVA_HOME environment variable.
To fix this error, just check the Java version in pom.xml and JAVA_HOME. They should match.
To know more about this issue, check this post - https://dzone.com/articles/how-to-fix-invalid-target-release-17-18-19-or-110
I wanted to use JMetro styling in my Maven project, but whatever I do, Maven gives me the same error. I am using javafx-archetype-simple from org.openjfx, and I tried using JMetro by adding it as a dependency in my pom.xml, and downloading it from JCenter by adding the .settings.xml to ~/.m2/. Whenever I tried to do mvn javafx:run after mvn clean, I always get this error:
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< io.colocasian.calc:ore-no-calculator >----------------
[INFO] Building ore-no-calculator 1.2-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> javafx-maven-plugin:0.0.4:run (default-cli) > process-classes # ore-no-calculator >>>
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # ore-no-calculator ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/rishvic/Documents/Java/ore-no-calculator/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # ore-no-calculator ---
[WARNING] Can't extract module name from jmetro-11.6.5.pom: zip END header not found
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /home/rishvic/Documents/Java/ore-no-calculator/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/rishvic/Documents/Java/ore-no-calculator/src/main/java/io/colocasian/calc/App.java:[17,22] package jfxtras.styles does not exist
[ERROR] /home/rishvic/Documents/Java/ore-no-calculator/src/main/java/io/colocasian/calc/App.java:[35,26] cannot find symbol
symbol: class Style
location: class io.colocasian.calc.App
[ERROR] /home/rishvic/Documents/Java/ore-no-calculator/src/main/java/io/colocasian/calc/App.java:[35,40] cannot find symbol
symbol: variable Style
location: class io.colocasian.calc.App
[ERROR] /home/rishvic/Documents/Java/ore-no-calculator/src/main/java/io/colocasian/calc/App.java:[377,13] cannot find symbol
symbol: class JMetro
location: class io.colocasian.calc.App
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.443 s
[INFO] Finished at: 2020-01-31T21:46:28+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project ore-no-calculator: Compilation failure: Compilation failure:
[ERROR] /home/rishvic/Documents/Java/ore-no-calculator/src/main/java/io/colocasian/calc/App.java:[17,22] package jfxtras.styles does not exist
[ERROR] /home/rishvic/Documents/Java/ore-no-calculator/src/main/java/io/colocasian/calc/App.java:[35,26] cannot find symbol
[ERROR] symbol: class Style
[ERROR] location: class io.colocasian.calc.App
[ERROR] /home/rishvic/Documents/Java/ore-no-calculator/src/main/java/io/colocasian/calc/App.java:[35,40] cannot find symbol
[ERROR] symbol: variable Style
[ERROR] location: class io.colocasian.calc.App
[ERROR] /home/rishvic/Documents/Java/ore-no-calculator/src/main/java/io/colocasian/calc/App.java:[377,13] cannot find symbol
[ERROR] symbol: class JMetro
[ERROR] location: class io.colocasian.calc.App
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Link to Gist containing my edited pom.xml, settings.xml and App.java which I used to try to use JMetro in my project. Source code (without JMetro, which actually runs with mvn clean javafx:run) linked here.
Output of java -version:
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10)
OpenJDK 64-Bit Server VM (build 11.0.6+10, mixed mode)
Output of mvn --version:
Apache Maven 3.6.3 (NON-CANONICAL_2019-11-27T20:26:29Z_root)
Maven home: /opt/maven
Java version: 11.0.6, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-openjdk
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.4.15-2-manjaro", arch: "amd64", family: "unix"
PS: I am really new to using Maven, I would really appreciate some advice regarding using Maven, in general, and also using JavaFX on it. Originally, posted this question on Github Issues, on the JFXtras Styles Git repo, but it wasn't really an issue with JMetro itself, so posted this question here.
Extra info: I don't know if this has anything to do with it, but I am still adding it as reference. When I added JMetro 11.6.7 as a dependency and reran mvn clean javafx:run, while downloading, it gave me these warnings,
...
[WARNING] Can't extract module name from jmetro-11.6.7.pom: zip END header not found
...
[WARNING] Can't extract module name from jmetro-11.6.7.pom: Only outputDirectories and jars are accepted on the path
[WARNING] Some dependencies encountered issues while attempting to be resolved as modules and will not be included in the classpath; you can change this behavior via the 'includePathExceptionsInClasspath' configuration parameter.
The official Maven repo of JMetro didn't work for me as well. I resorted to downloading the JMetro jar from GitHub, adding it manually to Maven, and then use it in my JavaFX apps.
Here's what I did to make JMetro play nice with Maven:
Download the official JMetro jar from GitHub
Add the downloaded jar to the local Maven repo:
mvn install:install-file -Dfile=jmetro-11.6.15.jar -DgroupId=com.jfxtras -DartifactId=jmetro -Dversion=11.6.15
Add it to the project's pom.xml as a dependency:
<dependency>
<groupId>com.jfxtras</groupId>
<artifactId>jmetro</artifactId>
<version>11.6.15</version>
</dependency>
For modular projects, declare it in project's module-info.java:
module <ModuleName> {
...
requires org.jfxtras.styles.jmetro;
...
}
Now JMetro can be used normally.
I was trying building a Java plugin with Maven using Intellij IDEA until I came across an error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.803 s
[INFO] Finished at: 2015-06-16T16:34:55-10:00
[INFO] Final Memory: 17M/216M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project mc-hyperchat: Error occurred in starting fork, check output in log -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I realize that this is because of this line (that I found using the -X flag)
Forking command line: cmd.exe /X /C ""D:\Program Files\Java\jdk1.8.0_45\jre\bin\java" -jar C:\Users\<username>\Documents\+GIT\mc-hyperchat\target\surefire\surefirebooter8505511050498586005.jar C:\Users\<username>\Documents\+GIT\mc-hyperchat\target\surefire\surefire5990474653240919844tmp C:\Users\<username>\Documents\+GIT\mc-hyperchat\target\surefire\surefire_08408900793313340679tmp"
The system cannot find the path specified.
I happen to come across somebody else with the exact same problem:
Maven Surefire 2.13 fails to fork on Windows
The accepted answer seems to be that his JAVA_HOME environment variable was invalid, so I checked mine:
I also echoed the variable on the Command Prompt to make sure it didn't have any quotation marks in it (also me running cmd.exe to see another The system cannot find the path specified message):
I'm convinced my JAVA_HOME environment variable is correct. If that's the case, what else could've caused this problem?
I found this to be a windows related error -
Open the Registry Editor
Navigate to HKCU\Software\Microsoft\Command Processor\AutoRun and clear the values.
Also check HKLM\Software\Microsoft\Command Processor\AutoRun.
I am following the steps as per the Kantega/storm-twitter-workshop project link
but I am stuck at a point. While testing credentials by running the main class in folder cheating
cd cheating
mvn compile exec:java -Dexec.classpathScope=compile -Dexec.mainClass=storm.starter.CheatingTwitterFunTopology
I am getting the below error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project storm-assignment-solution: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Where am I going wrong?
The Error says it all ..
[ERROR] Unable to locate the Javac Compiler in:[ERROR] /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
Looking at your project page found the following
1) It uses 2 maven modules namely cheating and storm-assignment and both of them are expected to run under Java 1.6 as found in their pom.xml
Check the pom.xml for both the module has this
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
Make sure you are running with atleast Java 1.6 or Higher
I am trying my hands on the Akka Pi java tutorials
I am trying to creaate a maven project as stated in the tutorial
but any time I enter the command to create a maven project I get an error.
Below are the command and the Error.
C:\Program Files\akka-2.0.2>mvn archetype:generate \
C:\Program Files\akka-2.0.2>mvn archetype:generate \
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.206s
[INFO] Finished at: Wed Sep 26 02:50:38 BST 2012
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM
in this directory (C:\Program Files\akka-2.0.2). Please verify you invoked Mave
n from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProject
Exception
looks like maven is requesting for the POM file but it is not stated in the tutrials that I have to create a POM before generating the project.
I am actually new too maven so pardon me.
I am using maven version :3.0.4
and akka version 2.0.2
but the tutorial uses akka version 2.0.1 but i donn't think that is the problem
any suggestion please.
thank you
remove the \ then it should start to query for more informations.
I have no windows here, but on linux it shows the same behavior with
mvn archetype:generate /
HTH R
When some tutorials describes a mvn command to be executed that is covered in two rows or more, they might add an extra backslash at the new line (of the instruction) to indicate that the same command continues on next line.
This backslash should be removed BEFORE executing the command. For instance the command for setting up a Jersey Web Application might look like this:
mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes \
-DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeVersion=2.2
but should be launched as below, without backslash:
mvn archetype:generate -DarchetypeGroupId=org.glassfish.jersey.archetypes -DarchetypeArtifactId=jersey-quickstart-webapp -DarchetypeVersion=2.2
If NOT removing this extra backslash you might get the error you described above.