I am setting up websockets with my Java j2ee servlet application. I was able to write the entire code and got the websockets working using following maven configuration -
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
My implementation does not work without <scope>provided</scope> and gives handshake exception: 404 not found.
Now, when I deploy my application on dev machines using travis, it gives exception while creating a build, and throws Java exception that ServerEndpoint class not found. I am assuming that it is because since scope is provided, Travis is not downloading the required jars while building a build on travis.
How do I avoid this, and ensure that we are able to work on local as well as deploy our builds via travis.
Related
We have an application on java springboot which would interact with IoT devices via HTTP Rest API. However, there is an IoT device that communicates with the LWM2M protocol. So, I need to set up an LWM2M server and make the application an LWM2M client.
First I wanted to make a prototype on my local machine running application on Windows with eclipse ide. I tried importing the Leshan project from this link on eclipse workspace. However when maven clean install, it is not creating a jar file for every project. Attaching the result at eclipse console, when I do maven clean install..
My ask is:
Am I going the right way, in order to implement the LWM2M protocol locally?
How to resolve all jars not creating with Maven clean Install.
Our commercial LWM2M offering that is part of Cumulocity IoT in fact is a Spring Boot application which includes Leshan. So you are definitely on the right track.
While I am not able to disclose internals, I am happy to provide you some pointers how to get this flying.
In your pom.xml, declare the needed Leshan dependencies, for example:
<dependency>
<groupId>org.eclipse.leshan</groupId>
<artifactId>leshan-core</artifactId>
<version>2.0.0-M9</version>
</dependency>
<dependency>
<groupId>org.eclipse.leshan</groupId>
<artifactId>leshan-server-core</artifactId>
<version>2.0.0-M9</version>
</dependency>
<dependency>
<groupId>org.eclipse.leshan</groupId>
<artifactId>leshan-server-cf</artifactId>
<version>2.0.0-M9</version>
</dependency>
<dependency>
<groupId>org.eclipse.leshan</groupId>
<artifactId>leshan-server-redis</artifactId>
<version>2.0.0-M9</version>
</dependency>
<dependency>
<groupId>org.eclipse.californium</groupId>
<artifactId>californium-core</artifactId>
<version>3.7.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.californium</groupId>
<artifactId>scandium</artifactId>
<version>3.7.0</version>
</dependency>
I assume you know how to set up a Spring Boot application using maven. If not, this tutorial shows precisely how it can be done.
In your spring boot application you then can construct a LeshanServer object and accept LWM2M traffic. Have a look at the leshan-server-demo maven module in the Eclipse Leshan source code on how to do that.
Questions about build issues get much better help and answers, if you use Eclipse/Leshan - github issues. Not all open-source projects are watching stackoverflow and so you can get a "first hand first class" answers only there.
I have skipped the integration testing by commenting its dependency in the pom file. Then all other modules got compiled.
I'm trying to build a simple API client, which uses org.apache.httpfor connecting to the API server. Locally everything works fine. I'm successfully connecting to the server and receive the data I want.
But, when I deploy my application to the server. I'm getting following exception:
Caused by: java.lang.ClassNotFoundException: org.apache.http.client.ClientProtocolException from [Module "deployment.adobe-livecycle-jboss.ear:main" from Service Module Loader]
I tried multiple different variants of versions of my depencies. Right now im using the following:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
<scope>compile</scope>
</dependency>
Both of the JARs appear in my Java Build Path, also the class which is "missing" is found in there.
Even when I build the project and search the JAR files libs folder, I can find the class...
I know there are some solutions to find online but none of them helped me.
This is probably caused by a faulty maven local repository. Try looking for your maven local repository (It's generally a hidden folder like named.m2\repository), delete the folder org\apache\httpcomponents then clean compile your project.
Edit:
After further explanation of the problem, it seems that this is a deployment issue not a build one.
If it's the first time that you use this package in your build, then this package's jar must be defined somewhere in the deployment server, it seems that you are deploying in an Adobe environment which seems to be based on JBoss because of that line of log that you provided
[Module "deployment.adobe-livecycle-jboss.ear:main" from Service Module Loader]
Make sure to read the documentation of that environment on how to configure and define external modules.
I am new to Spring and I am starting to learn it from his website.
Understanding Java is not difficult to me, but I have trouble with the environment.
I followed this guide for using Spring Boot for creating a new project and everything went great
https://spring.io/guides/gs/spring-boot/
Now I would like to run this project from the Spring Tool Suite but I get this error when I try to run the same code on Pivotal or Tomcat server.
Failed to instantiate [org.springframework.boot.autoconfigure.web.HttpMessageConverters]: >Factory method 'messageConverters' threw exception; nested exception is java.lang.NoClassDefFoundError:org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverter
Any help from Spring developers for fixing my workflow?
When you try to run the project via a server, first build it using maven so that all the dependencies are downloaded. This helps to download MappingJackson2XmlHttpMessageConverter class also. After building it deploy the war you create into the server.
This class is added to spring from 4.1. You have to add
compile('org.springframework:spring-web:4.1.4.RELEASE')
for gradle, or
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>
for maven.
I am trying to implement "JDO" in my android app.
The big step in this is to integrate it into the backend endpoints implementation of my google appengine portion of the app.
In doing so, I added "jdo-api.jar" to my classpath, which made my PMF.class file error free.
However when I try to run "mvn clean install" I am still getting the error "package javax.jdo not found" - what am I doing wrong here???
It sounds like you're modifying the classpath in an IDE (eclipse?), but when running mvn you're using the maven environment defined in pom.xml. Try adding the jdo-api dependency to the pom.xml
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version> ...fill in version here... </version>
</dependency>
I have searched many similar posts, however I cannot find a definitive answer on the correct way to build and deploy JSF applications, therefore I'm hoping someone can help...
Currently I am using Eclipse with Maven to build a simple JSF application and deploy it onto Tomcat 7, with one dependency in the POM.xml of:
<dependency>
<groupid>javax</groupid>
<artifactid>javaee-api</artifactid>
<version>6.0</version>
</dependency>
When I deploy onto the server I get:
java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener
I cant figure out where this is coming from? I have no listeners defined in web.xml.
If I then change my dependency to:
<dependency>
<groupid>javax</groupid>
<artifactid>javaee-api</artifactid>
<version>6.0</version>
<scope>provided</provided>
</dependency>
And attempt to run the application on the server I get:
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
Which I can understand because I am now using scope as provided and thus it expects Tomcat to have the implementation and it cannot find it.
Finally if I drop javax.faces.2.1.13.jar into tomcat install dir/lib folder it works fine.
The javaee-api-6.0.jar imported using the Maven dependencies seems to contain the same javax.faces.* classes as the javax.faces.2.1.13.jar, therefore can anyone tell me why this doesn't work when I try and run the application on the server without scope as provided?
Although it works when having the javax.faces.2.1.13.jar in the tomcat install dir/lib folder, is this the correct way to deploy a faces application?