Atlassian FishEye plugin and Spring LDAP classes - java

My plugin for FishEye should have a possibility to accessing the our Active Directory and implement some more features for FishEye. The plugin should make the synchronization with directory every X minutes, so it is based on SAL Scheduler.
When I tried to use com.sun.jndi.ldap.LdapCtxFactory, I found that is works only with REST plugin, but using with SAL does not load this classes even when I re-defined the classloader.
Anyway, I re-implemented my functionality with the Spring LDAP and when I tried to deploy my plugin to the FishEye I got:
2014-12-03 23:12:03,010 ERROR [ThreadPoolAsyncTaskExecutor::Thread 9 ] org.springframework.osgi.extender.internal.activator.ContextLoaderListener DefaultOsgiBundleApplicationContextListener-onOsgiApplicationEvent - Application context refresh failed (NonValidatingOsgiBundleXmlApplicationContext(bundle=com.mycompany.fisheye.ldap-restriction-plugin, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/osgi]
Offending resource: URL [bundle://84.0:0/META-INF/spring/atlassian-plugins-component-imports.xml]
Ok. I googled and found https://developer.atlassian.com/docs/faq/troubleshooting/dependency-issues-during-plugin-initialisation
There is written that I have to change the scope of dependency to provided for avoiding the conflicts. Ok, I made that. But now I have another exception:
Exception in thread "PluginSchedulerTask-com.mycompany.fisheye.LdapRestrictio nComponentImpl:job" java.lang.NoClassDefFoundError: org/springframework/ldap/core/support/LdapContextSource
I tried to put the spring-ldap-core-1.3.2.RELEASE.jar to $fisheyeDir/lib and nothing happens - the bootloader does not pick up this JAR.
Does anybody know what can be done in this situation? Should I use another LDAP framework or it is possible to shove these ldap client implementation to the classpath?
FishEye version 3.6.1 (latest), spring jars into classpath version 3.0.5.RELEASE. My spring-security-ldap dependency is also 3.0.5.RELEASE.
Thanks in advance.

The Spring version FishEye uses internally (3.0.5 in 3.6.1, 3.1.4 as of 3.7), is not exposed to plugins.
Instead they get a spring runtime from the Atlassian plugin system (https://bitbucket.org/atlassian/atlassian-plugins). FishEye uses plugins 3.0.x, so the Spring version that's available to plugins is 2.5.6.
Neither FishEye, the plugin system nor any of the bundled plugins include spring-ldap, so you can't set the dependency scope to (as this causes the library not to be included in the plugin jar, instead expecting it be available via an OSGI import).
So what I believe you should try is to bundle a version of spring-ldap that's compatible with Spring 2.5.6. To solve the BeanDefinitionParsingException, you might need to exclude some transitive dependencies that are provided by the plugin system (use mvn dependency:tree to find those).
Disclosure: I'm a dev working on FishEye/Crucible

Related

Run two versions of elasticsearch in java application using maven

I have a legacy monolith application, which uses elasticsearch 1.X and now we need to run elasticsearch 7.X in the same application, so that same application index and query data in both version of elasticsearch.
In my project, there are multiple modules and they all have their own POM and parent POM, and my new module which uses elasticsearch 7.X depends on some module which uses 1.X.
Although I have excluded 1.X specific dependency in module which uses 7.X, Still it gives me below Error:
[76B7CCD2] java.lang.NoSuchFieldError: LATEST at
org.elasticsearch.Version.(Version.java:49) at
org.elasticsearch.common.io.stream.StreamInput.(StreamInput.java:114)
After doing a lot of research and using this and this link, As explained I excluded the elastic 1.x dependency but still looks like as my other sub-module still has ES 1.X and which is required as well, hence overall classpath of my application has both versions of org.elasticsearch.Version java class from the same package org.elasticsearch, which I feel is the root cause.
Now, How can I include the same class from the same package from two different versions of a same library.
You can't. You can only have one class with a given full qualified name (package + name).
You can try to shade one of the packages (i.e. rename it) with the Maven shade plugin (never tried that, actually), which might work.
Usually, you need to change code and fiddle around until you find a version of elasticsearch that works with all dependencies.

Intellij Maven cannot resolve my dependency

I add my maven dependency as compile, runtime or test but it remains unresolved
This is for Intellij idea verison 2019, Java 8 and Maven 3.6.0
Error -> cannot find symbol
The dependency you are trying to depend on is a runnable Spring Boot archive. These are not intended to be used as dependencies. From the Spring Boot doc (might be an older version):
Like a war file, a Spring Boot application is not intended to be used
as a dependency. If your application contains classes that you want to
share with other projects, the recommended approach is to move that
code into a separate module. The separate module can then be depended
upon by your application and other projects.

ERROR [org.springframework.web.servlet.DispatcherServlet]

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 ?

wildfly 10 - javax.servlet.ServletContainerInitializer: Provider org.springframework.web.SpringServletContainerInitializer not a subtype

I am using Spring 4.3 and Servlet 3.1.
Deployment fails with error
javax.servlet.ServletContainerInitializer: Provider org.springframework.web.SpringServletContainerInitializer not a subtype.
I know that it is some wrong class is loading
The Spring jars and Servlet 3.1 jars are configured as a module and mentioned in module.xml.
javax.servlet.ServletContainerInitializer is present in only one jar jboss-servlet-api_3.1_spec-1.0.0.Final.jar that I have included in module.xml.
SpringServletContainerInitializer is needed for my application.
Let me know if you need me to post more details.
Any help is appreciated.
I had the same problem and solved it by goig through my dependencies to see if anything crashed with my application-servers libraries.
Make sure your java-ee and java-ee-web dependencies are set to "provided" scope in your maven/gradle configuration.
I was getting the same error and after researching, I identified somehow SpringServletContainerInitializer was not loading because of Maven packaging issue. In my case, spring-web-4.3.8.Release.jar was not bundling correctly with application WAR.
This can be fixed by
resolving application bundling conflict
using server shared libraries
if using IDE for application bundling, one can avoid bundling using IDE or switch the IDE (like STS to Eclipse/RAD)
Another potential source of extra copies of servlet-api and other similar Java EE APIs is Spring Boot's tomcat-embed-core-<version>.jar, which you may get from spring-boot-starter-web.

ApacheCXF 3.1.4 and Spring 4.2.4 compatability

I am trying to upgrade my libraries: ApacheCXF 2.7.7 --> 3.1.4. Spring 2.5.5 --> 4.2.4.
My Hudson build keeps failing because it cannot find packages/classes, org.springframework.context.ApplicationContext, for example. The classpath in cxf-manifest.jar, as part of ApacheCXF, refers specifically to Spring 4.1.7 jars.
I've tried loading both Spring 4.1.7 and 4.2.4 versions, but no joy. (Is loading multiple lib versions even possible?).
I've tried removing cxf-manifest.jar from the classpath/buildpath. Eclipse is happy with that and it finds the desired classes in the Spring 4.2.4 jars, but Hudson is still not happy.
I've considered moving to Spring 4.1.7, but I don't see the point of upgrading partially.
Is ApacheCXF 3.1.4 specifically incompatible with Spring 4.2.4? And how would I get Hudson to be happy with the upgraded libraries?
Turns out that I forgot to add the specific directory containing the Spring jars to my build.xml script.
ApacheCXF 3.1.4 IS compatible with Spring 4.2.4
Edit: Apparently I was wrong.

Categories

Resources