Part of the project I've been working on requires serializing objects to JSON and passing them to the user. We will be using the Jackson library to do this. Previously I was using version 2.2.3, which was simple enough, but my manager wants to switch back to version 1.9.12. Shouldn't be a problem, 1.9.12 supports everything that we need, but just adding the dependency to the project causes it to basically implode.
The dependency we add:
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.12</version>
</dependency>
The project builds just fine. However, running the server causes it to throw this:
java.lang.ClassNotFoundException: org.codehaus.jackson.JsonGenerationException
followed by about a page of information which I can provide if needed. Trying to load up a web page (which was working previously) causes it to generate a 5MB log file full of errors, and while the page itself loads some of the page entities come out wrong.
A quick check of the compiled .war file shows that the jackson-mapper-asl.jar doesn't contain JsonGenerationException.class, but jackson-core-asl.jar (which I believe is added as part of the jackson-mapper-asl dependency, as it is not listed in the dependencies) does.
I have commented out all of the code relying on Jackson, so the libraries are not used in any way in my code. My suspicion is that Spring is trying to create a JSON mapper for one of the servlets and is somehow crashing. However, I'm not sure why it can't find the dependency.
I think you should migrate towards "com.fasterxml.jackson.core" Jackson.
see packages on Maven cetral:
http://search.maven.org/#search|ga|1|com.fasterxml.jackson.core
It looks like Jackson project changed base package. I have Spring Boot (1.1.8) project in my workspace and it's using Jackson with this new base package.
Related
I have a spring web mvc project with gradle build tools. It is running perfectly fine. but I want to use swagger to generate open api documentation for it. So , I have used
implementation 'org.springdoc:springdoc-openapi-ui:1.5.2'.
But as soon i add this, it causing import problem.
import org.springframework.web.servlet.view.document.AbstractExcelView;
why including spring-doc open ui causing this? Without this dependency AbstractExcelView class is available.
When you include a new dependency in your project, it can sometimes conflict with other dependencies if they use different versions of the same library. In this case, it looks like the spring-doc-openapi-ui is using a different version of the Spring framework than the one that your project is using
My code is built in maven and using jBoss 6 and java 7
The code is working fine on local machine but when i try running war on server i an getting error
ERROR [org.springframework.web.servlet.DispatcherServlet]
I tried using aop jar but still no success
Can some one explain me the error and how to solve it
It is failing during the creation of your #Beans. In particular, it is failing because NoClassDefFoundError: org/springframework/core/convert/converter/ConvertingComparator which means it can't find the Class definition for "ConvertingComparator". The earliest documentation I can find on the ConvertingComparator is Spring
3.2.0. Bear in mind, you are using Spring 3.1.0.RELEASE. I tried running a basic Spring project using your POM and ran into similar issues using the spring version you provided. I also ran into conflicts with Spring 3.2.0. I recommend using Spring 4.3.5.RELEASE in your POM. I had no issues running my basic example after setting the properties you have to:
<properties>
<org.springframework.version>4.3.5.RELEASE</org.springframework.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
That being said, you may have other issues in your code as well. It is difficult to provide a holistic solution without more information.
EDIT:
So here are all your spring dependencies:
spring-beans
spring-web
spring-webmvc
spring-tx
spring-jdbc
So first lets talk about redundancy. spring-webmvc actually contains spring-web and spring-beans. You can therefore remove those dependencies from your POM as they are redundant. spring-jdbc contains spring-tx, rendering that inclusion also redundant. You can remove all of those from your POM right now for clean up.
In your comment, you mentioned a new error being thrown in regards to package org.springframework.mail not being found. This package is found in spring-context-support. Spring context support is actually found in the spring-webmvc as well as an optional dependency. (so you would have to include it manually)
According to this thread, that package was moved into context-support separately. My guess is that you are trying to specifically use some of the objects available in the .mail package and because you were not including it, it wasn't being found. With more information as to your project, the more we can dive into why 3.2 did not work and 4.1 does work. Specifics aside, what this all means is that the 3.2 dependencies you were calling did not expose the required packages, but the 4.1 dependencies do.
Have you stopped the process, I mean that particular bean could be in-use ?
I was following this tutorial to understand the Spring and Hibernate. After I added the hibernate dependency like this:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.3.ga</version>
</dependency>
I got this error
Project 'SpringExample' is missing required library: 'C:\Users\gmuniandy\.m2\repository\hibernate\hibernate3\3.2.3.GA\hibernate3-3.2.3.GA.jar' SpringExample Build path Build Path Problem
.
I have downloaded the jar file and placed in the folder manually but the issue still remain. Please advice.
EDIT
I guess it is an wrong writing in thy pom.xml: Instead of "ga" use "GA" as Ragu already wrote.
Did you try already the downloadable project from the Website?
And what looks strange to me, I found no hint about case-sensitivity on maven.org, though maven uses case-sensitive match when matching against property values. Referring to Maven Model
May I suggest, that you follow this tutorial?
Accessing Relational Data using JDBC with Spring
At the bottom of the Article you will see a complete pom.xml which obtains the required and correct versions of libs from a inherited pom.
It should keep your pom short and simple. So you can better concentrate on your task rather than bothering around with libs at an early stage of your project.
Have you tried to clean up your local Maven repository and resolve dependencies again?
version is wrong -correct one 3.2.3.GA , In mvn repository you can search specific jar maven dependency.
I need to provide a java REST client, which should contain all required jars in one bundle. I chose RestEasy as REST framwork, since the server application is done on a JBoss.
Nearly all examples I found so far use either an application container environment, where those libs are provided and thus only the Java EE API is needed during compile or are build with Maven and thus dependencies are resolved automatically, which maybe be a good idea and the current standard way to do it, but for project-related reasons I need the jars in a lib folder and be able to include during the build and wihtin an executable jar.
So my question is, which jars a necessary to build a simple client which can do something like that:
ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target(myURL).queryParam("param",
"value");
Builder builder = target.request(MediaType.APPLICATION_JSON).header("user", "abc");
Invocation invocation = builder.buildGet();
MyResponseObject response = invocation.invoke(MyResponseObject .class);
The easiest way is to use Maven. The reason I say this, is that the main artifact you want is the resteasy-client artifact, but this artifact has dependencies on other artifacts. If I create a new Maven project, add only this dependency
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.0.9.Final</version>
</dependency>
The project will pull in all this artifacts
But if you are not using Maven, You can download the entire resteasy package here. It comes with a lot more than what you'll need, but it will have all the jars you see in the image above, along with some other goodies like user guides, examples and such. Base on the image above, just get the jars you need. Make sure you download the final-all version. When you unzip it, all the jars should be in the lib dir.
Another thing I might mention is that in order to unmarshal JSON representation into your Java classes, you might also need resteasy-jackson2-provider. Doing the same as above, you will see these pulled in artifacts
Again, these are also include in the download. This will work in most cases, if you are using JAXB annotations (which could return XML or JSON), because of the pulled in artifact jackson-module-jaxb-annotations, but that artifact doesn't support all JAXB annotations, so you might need to pull in the resteasy-jaxb-provider, if need be. Again like I said, just the jackson2-provider may be enough. But in the case you do need the jaxb-prodiver, here's what it looks like
Again, included in the download
If you use maven in your project, you can type dependency:tree to see hierarchy of your dependencies. Libraries used by RestEasy will be listed in tree.
This is my first time really playing around with Java development using Eclipse. I am trying to use EclipseLink's implementation of the JPA. I moved all of my entities into a separate package "entities". I have the persistence.xml in a separate JPA project called "dataModeling".
Everything builds and runs fine.
Just about every project depends on my entities. However, I'm seeing a warning Class javax.persistence.Entity not found - continuing with a stub., etc. showing up because the dependent projects don't reference EclipseLink.
The solution is to go into each dependent project's properties and under Java Build Path > Libraries, click Add Library, then User Library and then select EclipseLink.
However, to me, it doesn't make sense to reference EclipseLink in every project! That's an implementation detail I don't want to burden other projects with. It looks like this is happening because the other projects see the annotations and don't recognize them.
So the real question is: how can I use JPA (via annotations) without every other project needing to reference my JPA implementation?
Your pom.xml should contain:
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
the first one is Eclipse-Link (which you already have), the second one is Persistence API which is lacking.
If you are not using maven - make sure that javax.persistence-2.0.0.jar is on your classpath.
Note that this is version 2.0.0, the newest is 2.1.0
update
The project which makes use of EntityManager should have these dependences. Putting entities and persistence.xml in separate jar file still requires the other project that uses it to fulfill above dependencies.
Thanks to #neil-stockton and #chris, I was able to figure out what was going on. Most JPA implementations have a copy of the javax.persistence JAR floating around somewhere. Most of them are bundled with everything else, leading to my dependency nightmare. There doesn't appear to be a de facto implementation floating around.
In my case, I used the copy that showed up under my Eclipse plugins directory. These annotations were truly empty in that did not have any unwanted dependencies. The JAR file (javax.persistence._<version>.jar) only showed up after I added the Dali and EclipseLink plugins (one or the other).