"Circular reference involving containing bean" error while starting tomcat in IntelliJ - maven

I did a "mvn clean package" which downloaded all the external dependencies and was successful. There are jars with overlapping classes and I see that above error when I try to run my application using IntelliJ IDEA. Same result on eclipse too. How can I solve this issue?
I also see
"Caused by: java.lang.NoSuchMethodError:" of a method but I see that class in multiple jars downloaded by maven which are under /root/.m2/repository folder. A couple of those jars have same exact package path and name.
Please let me know if I have to provide more details on this issue.

It turned out to be an actual bug. Different implementations are provided with same class and root package by two different jars (It's a no-no). But still not sure why my VirtualBox VMs are loading that class from one jar 100% of the time while for all others in my team that class is loaded from the correct jar.

Related

NoClassDefFoundError on com.sun.org.apache.xalan.internal.xsltc.trax package in my OSGi maven plugin

I'm trying to parse WSDL files using the EasyWSDL library on my (atlassian) maven plugin project. I keep getting this error when I try to parse the file and it fails when the project tries to reach the TransformerFactoryImpl class from said "xalan" package. The package is located inside the JDK, so it's supposed to be available to runtime, yet for some reason it can't reach it.
I've tried importing the package through
<import-package>com.sun.org.apache.xalan.internal.*,</import-package>
section of the pom.xml, but that gives me the following error:
Unresolved requirements: [[my.plugin.package [304](R 304.0)] osgi.wiring.package; (osgi.wiring.package=com.sun.org.apache.xalan.internal.xsltc.trax)]
Which makes it seem like the other packages of xalan are found, except for the xsltc.trax one.
I've tried creating a bundle extension for OSGi that exports this one package and exposes it to the classpath but due to lack of experience and pretty poor documentation on that matter I can't get that working either. Adding Xalan as a dependency and using <scope>provided</scope> does nothing as well.
I need to find a way to put this specific package on the classpath when the program is running. When I run unit-tests on my implementations they work just fine, so it seems to purely be a runtime classpath problem.
Is there anyone with experience on this matter? I've little experience with OSGi, and my experience with maven isn't huge either. So I'm hoping it's something I did wrong myself instead of this being an impossible problem to solve.

Spring Tomcat7 error "org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer"

I am getting below error while starting the Tomcat7 server.
org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.ServletContainerInitializer
I am just curious to find the root cause of this issue. In what scenario this error happens? I didn't get the error when I use Tomcat Enterprise Edition(TomEE)
In my project ServletContainerInitializer is getting loaded from javeee-api-7.0.jar
I have tried excluding the javax.servlet-api which is getting loaded from javeee-api but thats not working
We encountered this case in our project that contained loads of legacy code that was obviously not really well maintained.
We solved it by analyzing all dependencies inside all pom.xml files.
For this issue particularly, what we did was to exclude javax.servlet api because there was a conflicting version that loaded and caused the cast error.
If you use eclipse, when opening the pom.xml files, you can check the dependencies with the Dependency Hierarchy tab at the bottom.
There you can use the filter to see all servlet jars versions, and the top-level dependency that uses them. You can then exclude the problematic ones by right clicking on them and selecting "Exclude Maven Artifact..."
And then the obvious: save your pom.xml, eventually repeat for other projects/modules, update your maven project configuration and finally build/install/run to see if the problem is fixed.
Hope that helps!
add javeee-api-7.0.jar,it works for me.

fiji plugin : imgOpener exception (scifio class)

I'm using Fiji for the first time, I need to open an image as a FloatType so I followed the example found here http://fiji.sc/wiki/index.php/ImgLib2_Examples#Example_1b_-_Opening_an_ImgLib2_image but I get this error:
WARN: Ignoring non-Maven build directory: /home/utente/workspace/my_project/bin
Exception in thread "main" java.lang.IllegalArgumentException: No compatible service: io.scif.SCIFIOService
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:222)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:176)
at org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:153)
at org.scijava.Context.<init>(Context.java:200)
at org.scijava.Context.<init>(Context.java:127)
at org.scijava.Context.<init>(Context.java:116)
at io.scif.img.AbstractImgIOComponent.<init>(AbstractImgIOComponent.java:65)
at io.scif.img.ImgOpener.<init>(ImgOpener.java:99)
at SGP_db.StartingJFrame.getGn(StartingJFrame.java:216)
at Plugin.SGP_deblurring_boundary.main(SGP_deblurring_boundary.java:58)
Can't undertand why I get this error, any ideas?
Thanks,
sara
It is almost certainly a build path issue in Eclipse. Are you using the M2E plugin to manage your projects?
If you are not, or aren't sure, please follow the directions on the Fiji web site at:
http://fiji.sc/Developing_ImgLib2#Developing_ImgLib2_with_Eclipse
I would strongly suggest not to manually juggle JAR files in non-Maven Eclipse projects. The Eclipse Maven integration will make your life much easier. For more details, see:
http://fiji.sc/Maven
I've solved importing the ImgOpener class from imglib2.io
Please note that imglib2-io no longer exists; the up-to-date way to access the ImgOpener is to use the io.scif:scifio library instead. If you are basing your work off of the ImgLib2 Examples, please note that you can grab the source from GitHub, which includes a Maven POM with the correct dependencies specified. Start from there, or from the minimal-ij1-plugin project if you need to use ImageJ 1.x routines as well.

Maven project on new Kepler workspace fails with "Could not initialize class AspectJExpressionPointcut"

I have had a working Indigo workspace for quite a while, with many projects checked out from SVN. Mostly Ant projects, but a few critical Maven projects.
I'm struggling to get a Kepler workspace working with the same projects. I've essentially given up on the pure STS installation, as that gives me (different) errors in both Maven projects. I filed both Eclipse and STS bugs, and they both say it's the others problem, so I've given up on that path for now.
I'm now trying to start with pure Eclipse and install the Spring pieces I want. I thought I had all the plugins installed that I need, and I'm not getting the error dialogs that I was getting with the STS installation, but I'm getting a build error I can't handle. It's saying this:
Build path is incomplete. Cannot find class file for Could not initialize class org.springframework.ide.eclipse.springframework.aop.aspectj.AspectJExpressionPointcut
I suppose I'm missing some plugin, but I don't know what it would be.
I even did a somewhat exhaustive search for that class ("AspectJExpressionPointcut") in my workspace and Kepler distro, and it can't find it, unless it's in a jar file that's inside a jar file (my search just looks for classes in jar files in a directory tree). I see references to it on the internet, but I can't get much out of those references.
The solution is to install Spring IDE AJDT Integration. For Eclipse Kepler you need to add
http://dist.springsource.com/release/TOOLS/update/e4.3/
to the list of update sites, then install "Spring IDE AJDT Integration"

Cannot load driver class from maven dependency during process-resource phase (groovy script)

I have started to work on a script which is being run during process-resources phase (not my idea, it was like that when I got it). It executes sql script to clean db. I need to migrate it from command line tool to Jdbc.
Problem is that when I try to load driver I get:
java.lang.ClassNotFoundException: net.sourceforge.jtds.jdbc.Driver
I have tried with drivers to other database systems but exception is always the same. Drivers are visible from eclipse as maven dependency and their scope is "compile".
I tried to load it both ways:
Class.forName("net.sourceforge.jtds.jdbc.Driver")
//and:
def sql = Sql.newInstance(url,user,pass,"net.sourceforge.jtds.jdbc.Driver")
I know that running such script during build phase is not a good practice but still would it be possible to have those classes visible at that time?
[EDIT]
It is possible to create an object of the Driver class, so it does not seem to be maven phase issue. Changing title to reflect that.
I'm guessing that you need to add the jar that contains net.sourceforge.jtds.jdbc.Driver as a dependency during the build phase. That is, not a build dependency, but rather something available on the classpath during the build phase.
For this, I believe that you will need to add this jar file as a dependency to one of your plugins. See this information in the maven book:
http://www.sonatype.com/books/mvnref-book/reference/_configuring_maven_plugins.html#_adding_plugin_dependencies
Note that I haven't tried this and I'm not sure if this will work, but this comes to me as a possible solution.

Resources