package org.hibernate.annotations does not exist - entity

I have generated Jhipster Application which was working fine & was building successfully but after generating the entities it is not building & showing this error in file
which is /src/main/java/com/foodnet/mandi/domain/Buyer.java
Actually i generated the buyer entity

I put a dependency in pom.xml file
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
</dependency>
& My problem was solved

Make sure you have hibernate jar included in classpath. Which build tool are you using?

Related

Liquibase 4.13+ dependency without opencsv dependency

I tried to upgrade the liquibase version to 4.13 in my project, but when I tested it, I found a problem with loading csv data. It looks like the opencsv dependency provided with the liquibase dependency is missing. The following dependency helped to solve this problem. But my question is, why do I have to manually add it now?
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.6</version>
</dependency>
In v4.12.0 opencsv.jar was moved. Rather than shading opencsv into the liquibase-core.jar, define it as a dependency in the shipped pom.xml and include it as a separate jar in the internal/lib directory.

ContextFactory cannot be found in Eclipse

I have an Eclipse based application which is being ported from Java 8 to Java 11. Since javax.xml and friends was removed from the JDK, I had to add it as an Import-Package to every plug-in that needed them.
Now however, when run this code
Marshaller marshaller = JAXBContext.newInstance(MyClass.class).createMarshaller();
I get the following exception:
java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at org.eclipse.osgi.internal.framework.ContextFinder.loadClass(ContextFinder.java:135)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at javax.xml.bind.ContextFinder.safeLoadClass(ContextFinder.java:480)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:184)
I can add com.sun.xml.bind, which should have the dependency, but nothing happens. This is understandable, since OSGi rules prevents hacking into another plug-in via reflection.
However I cannot add Require-Bundle nor Import-Package to the JDK or the bundle around javax.xml.bind.
There is a bug surrounding this issue, but I cannot find a good solution for my application in the comments. Still I assume it can be fixed for an Eclipse application, else Eclipse itself shouldn't be able to run on Java 11.
How do I fix this exception?
We found an OSGi compatible way to fix this exception:
add the following implementations to the target platform
org.apache.servicemix.specs.jaxb-api-2.2 (from Maven central)
com.sun.xml.bind (from the Eclipse platform; this is the one that contains the ContextFactory)
make sure these bundles are started with your application
make sure the Apache bundle is started before everything else
So in Tycho, this would look like this:
<bundleStartLevel>
<bundle>
<id>org.apache.servicemix.specs.jaxb-api-2.2</id>
<autoStart>true</autoStart>
<level>1</level>
</bundle>
</bundleStartLevel>
<dependencies>
<dependency>
<artifactId>org.eclipse.e4.rcp</artifactId>
<type>eclipse-feature</type>
</dependency>
<dependency>
<type>p2-installable-unit</type>
<artifactId>org.apache.servicemix.specs.jaxb-api-2.2</artifactId>
</dependency>
<dependency>
<type>p2-installable-unit</type>
<artifactId>com.sun.xml.bind</artifactId>
</dependency>
</dependencies>
I'm too using jaxb in my application (JMSToolBox) and too migrated from Java 1.8 to Java 11 and didn't had this problem
In my plugin, I have a "lib" directory with the"jaxb-ri"jar and its dependencies (from maven):
jaxb-api-2.3.1.jar
jaxb-runtime-2.3.2.jar
javax.activation-api-1.2.0.jar
istack-commons-runtime-3.0.7.jar
Then the plugin references those jars (MANIFEST.MF + build.properties) and I don't have any problem
The plugin is here

EasyWSDL has missing dependencies

I am trying to add a WSDL module to my existing application, but I'm struggling to get the dependencies resolved.
According to their website, this is the correct dependency
<dependency>
<groupId>org.ow2.easywsdl</groupId>
<artifactId>easywsdl-wsdl</artifactId>
<version>2.1</version>
</dependency>
After a search (search.maven.org), I already changed the version to 2.3 and there are a bunch of files that are downloaded into my local repository, but when running the application (with the websites demo code), I bump into this error:
java.lang.ClassNotFoundException: com.ebmwebsourcing.easycommons.uri.UriManager
And I believe it has something to do with the missing artifacts :
com.ebmwebsourcing.easycommons:easycommons.uri:jar:1.1
com.ebmwebsourcing.easycommons:easycommons.logger:jar:1.1
In particular the first one. Now, I'm relatively new to using Maven... How would I go about solving this?
Thanks.
The solution is to add the petalslink repository. Appearantly the standard maven repository doesn't contain the easycommons dependency. The petalslink repository does.

How do I install JQuery into my web app using Maven?

I am looking at using Maven 3 for some web development. I know how to use maven to resolve java based jar files. How do I use maven to resolve JavaScript dependencies for example I want to have maven automatically put jquery in my webapp/js folder?
Is it possible to do transative JavaScript dependencies with Maven 3?
You could create your own "war" that has jquery in it on the path you specified.
Afterwards add that war to your real web application. Maven should merge it. I think it was called somehting like "processing overlay".
I'm using the same for some GWT application where the javascript is generated by a maven plugin and it works well.
Perhaps WebJars can help you:
WebJars are client-side web libraries (e.g. jQuery & Bootstrap) packaged into JAR (Java Archive) files.
Explicitly and easily manage the client-side dependencies in JVM-based web applications
Use JVM-based build tools (e.g. Maven, Gradle, & SBT) to download your client-side dependencies
Know which client-side dependencies you are using
Transitive dependencies magically appear
Caveat: WebJars does not put the jquery files in the webapp/js folder. Please read documentation to see how it is used with some popular frameworks.
Try adding this to your pom.xml file. It worked for me :
<dependency>
<groupId>com.efsavage.jquery</groupId>
<artifactId>jquery-maven</artifactId>
<version>1.7.2</version>
</dependency>
This library gives you a way to drop jQuery into your project as a Maven dependency, which means you don't have to include these third party files in your own source control.
Source : here
May be you should use one of CDN to include external javascript libs to your webapps?
E.g. for jQuery you can simple include it from any of URLs from http://docs.jquery.com/Downloading_jQuery#CDN_Hosted_jQuery
Also libs from CDN will reduce your server bandwidth usage.
You can create a new zip artifact in your repo with your version of jquery inside.
Then use the maven war plugin to deploy it to your war.
Take a close look at <targetPath> and <includes> to be sure to deploy what you need where you need it :)
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<overlays>
<overlay>
<groupId>yourgroupid</groupId>
<artifactId>yourJqueryArtifactId</artifactId>
<type>zip</type>
<targetPath/>
<includes>
<include>js/jquery.js</include>
</includes>
</overlay>
</overlays>
</configuration>
</plugin>
the previous config supposes that you have a directory called 'js' in your zip with jquery.js inside. It will be unzipped in your war at js/jquery.js
More info here

Error while using JSFUnit/HtmlUnit/CSSParser

We've just recently converted our project to using Maven for builds and dependency management, and after the conversion I'm getting the following exception while trying to run any JSFUnit tests in my project.
Exception class=[java.lang.UnsupportedOperationException]
com.gargoylesoftware.htmlunit.ScriptException: CSSRule com.steadystate.css.dom.CSSCharsetRuleImpl is not yet supported.
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:527)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537)
...
All the dependencies and JARs for JSFUnit were pulled with Maven using the JBoss repository (http://repository.jboss.com/maven2/).
We're using the following dependencies in the project:
jboss-jsfunit-core 1.2.0.Final
jboss-jsfunit-richfaces 1.2.0.Final
richfaces-ui 3.3.2.GA
openfaces 2.0
JSF 1.2_12
Facelets 1.1.14
Before the dependencies were being managed by Maven, we were able to run our JSFUnit tests just fine. I was able to semi-fix the issue by using a ss_css2.jar file that someone had tucked into our WEB-INF/lib directory (from before the Maven conversion). I'm hoping to find out if there's something else I can do to fix the dependencies in Maven rather than resorting to managing some of the dependencies myself.
You're very likely getting an "incompatible" version of HtmlUnit or another JAR (pulled transitively). Try with the version you were using previously and declare it under the dependencyManagement section, e.g.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.7</version><!-- put "your" version here -->
</dependency>
</dependencies>
</dependencyManagement>
Or, if you changed any version, try to revert to the exact previous state (by the way, could you clarify the differences between the previous versions and the one currently used?).
Update: It appears that the problem was related to the version of the cssparser artifact. I hadn't all the required elements to figure this out but the OP did :)