Springframework 2.5.6 and OSGi - java

I am trying to figure how to enable OSGi in a 2.5.6 install (The Dynamic Modules seems long gone now. Correct? ).
Is there some documentation describing the necessary steps and measures in getting OSGi workig the installed framework? I cannot find any. Maybe I'm just looking in the wrong places? I do get results that seem relevant with Google, but they point to dead ends (dead links - points to http://www.springsource.org/, but the documents seem to be removed).
I have a suite of OSGi bundles and need some of the services they provide as bean-references:
"<osgi:reference ... />" as defined by http://www.springframework.org/schem...pring-osgi.xsd
Is this possible? Other ways to do it? Schema seems to still be in place. But valid?

I got some info from another source also indicating the fact that Spring DM merged into Eclipse Gemini Blueprint. As of version 3.0.0 of Spring framework this is valid.

Related

Cannot inject javax.security.enterprise.SecurityContext in basic JEE8 login application

I'be been struggling for about 20 hours and also working in the weekend as you can see and I can't make this work. I think I have exhausted all the online options
I have copied the example here
https://rieckpil.de/howto-simple-form-based-authentication-for-jsf-2-3-with-java-ee-8-security-api/
in a new Dynamic web project in Eclipse for Java Enterprise Developers. I activated JSF 2.3 in the project facets (since I know that TomEE can use them)
I copied the classes, I set the web.xml to be the same.
My project runtime is TomEE8 (which is basically Tomcat9 with CDI and other stuff)
When I try to run the project on TomEE, I get this error:
javax.enterprise.inject.UnsatisfiedResolutionException: Api type
[javax.security.enterprise.SecurityContext] is not found with the
qualifiers Qualifiers: [#javax.enterprise.inject.Default()] for
injection into Field Injection Point, field name : securityContext,
Bean Owner : [LoginBacking, WebBeansType:MANAGED, Name:loginBacking,
API Types:[java.lang.Object,LoginBacking],
Qualifiers:[javax.inject.Named,javax.enterprise.inject.Default,javax.enterprise.inject.Any]]
I have tried creating the beans.xml file in my WEB-INF folder
I have created another bean with this annotation:
#FacesConfig(
// Activates CDI build-in beans
version = JSF_2_3
)
I have tried not using TomEE and using Tomcat 9 with weld, same problem.
I have no idea how to make this work. The thing is I need to add user login to my main application, but if this simple example won't work I don't think I can do this and I'm feeling very down.
If anyone can help me see the light, I'd be appreciative. I am also open to using the old method (ManagedBean and ManagedProperty I guess), but I'm not sure if it has the same effect.
Thanks!
Time for an answer.
It seems like TomEE does not provide an implementation for javaee-web-api. I had to add my own.
I have added the Soteria implementation to my lib file
https://search.maven.org/classic/#search%7Cga%7C1%7Ca%3A%22javax.security.enterprise%22
Now all seems well (at least the app is running).
Good luck!

spring-boot-starter-web-reactive + spring-boot-starter-actuator doesn't work together?

I tried out spring-boot-starter-actuator, by default instructions, add to spring boot project in pom, and it works without any issues.
As soon as I add spring-boot-starter-web-reactive everything breaks down, newly created reactive endpoint works, but actuator stopped working, have anybody had such issue and maybe already have any ideas how to solve it?
Also noticed, that h2 /console which I had working before, also broken.
I receive no errors, no exceptions, these things just stop working.
As Github page of Spring Boot Web Reactive Starter mentiones:
This experimental project ...
and
Go to start.spring.io, set the Spring Boot version to 2.0.0(SNAPSHOT) and add the "Reactive Web" starter.
When it's experimental, it is clearly not meant to be used in production and is not fully stable. Feel free to contribute or create issue.
Please, refer to this post Netty HttpServer api changed/differs from available examples
As the reactive-web is experimental you should add BOM file with compatible versions of libraries.

Changes done from Spring 2 to Spring 3

Recently while I was upgrading a project in spring 2.5.6 to spring 3.0.5, happened to know that some libraries aren't there anymore and some were renamed like spring-agent to spring-instrument...
Is there any site or a resource to refer to know these sort of changes done in migrating from spring 2 -3 ?
Yes, for most purposes, the Spring Upgrade Guide should provide you with what you need. In particular, check section 2.5 and 2.6 on the new packaging model.
If you are looking for a class that appears to be no longer available, try searching for it with FindJar. Some utility classes have been moved to another packages.

How to find out which dependencies need to be included?

I'm fairly new to Java/Spring and am trying to put together a simple app which will include some basic CRUD operations and I'd like to use Hibernate for data access.
I'm using Maven as my build tool. My question is: how can I find out which dependencies are required to use Hibernate? For example, I'm using Spring 3.0.6, but how would I know what version of Hibernate to use with that version of Spring? More over, if there are multiple possible Hibernate dependencies, how would I know which ones to include for the functionality I need? So far this seems to be partially reading documentation and partially trial and error.
Is there a definitive way of knowing which Maven dependencies to use with certain version of other dependencies? Any which dependencies to use for particular bits of functionality?
Thanks,
James.
I follow these steps when starting to use a new framework:
Go to framework's web site. In your case hibernate web site and try to find latest (or a specific) version. For hibernate it is 3.6.8-Final at the time of writing.
Search for a maven dependency definition on the framework web site. If you can not find any dependency definition, them simply google for "frameworkname _version_ maven dependency" and you'll most probably find necessary definition, as well as the necessary repository information. For example you can find the dependency definition for hibernate on mvnrepository.com and necessary artifact repository information on Hibernate 3.6.8 release page:
The artifacts have all been published to the JBoss Nexus repository under the org.hibernate groupId at http://repository.jboss.org/nexus/content/groups/public-jboss/
The question of which dependencies are necessary and which are optional depends entirely on the framework to be used. So for example in order to use hibernate, as stated on Hibernate Quick Start Guide:
hibernate-core: The main artifact, which contains all the Hibernate classes, in packageorg.hibernate. You need these to build applications using the native Hibernate APIs. It includes capabilities for using native Hibernate mapping in hbm.xml files, as well as annotations.
About compatibility issues (which version of hibernate is compatible with spring 3.0.6), all I can say is you have to read about integration manuals for those frameworks. Since Spring and Hibernate are two exclusively distinct frameworks, I don't think you can find a constant location to look for version compatibility matrix or something like that.
The purpose of Maven is to avoid handling dependencies by hand. Just choose which version of Hibernate to use and include it in your pom; Spring supports many different versions.
If you know what parts of Spring you want to use, just include those parts in your pom; they'll include their own requirements.
Is there a specific module and/or version combination you're having an issue with?
The only way to know for sure that you've got all dependencies is by running your app.
Maven resolves for you transitive dependencies so you can quickly detect missing ones by compiling the java code.
However, in a web app there are many dependencies that are required in runtime only, so they are not detected at compilation time.
you can find out the dependencies by running mvn dependency:tree and analyze if they are required or not by running mvn dependency:analyze.
Taking the newest ones usally works as long as they are stable.
Start with hibernate and spring core, context, tx.
After you added some could you will probably recognize that something else is missing.
Try and error doesn't sound good, but its working pretty well for spring dependencies.

I am confused with Hibernate Spring

I am rookie into Java and I am directly thrown into Hibernate and Spring. I have attended some training classes and I am following documents online from random forums and trying to run a test project. I have some set of questions to be answered.
What is the latest version of Hibernate that has come and where do I download all the dependent jars in one place?
What is the latest version of Spring that is out there?
Any links/blogs that shows me to configure a hello world or a similar implementation would be of great help with the latest versions of Spring and Hiberante!!
Thanks.
The project web page says it is Spring 3.0.5 Release
The project web page says it is Hibernate 3.6.1 Release
Hibernate and Spring tutorial
Rest you will find using some web search like google.com or bing.com or altavista.com
I highly recommend you check out Spring Roo. There is a super duper quickstart.
Although its touted for doing Code and JSP scaffolding I find its biggest benefit is setting up your project in a very canonical and java/spring best practice setup.
It will setup maven and all the dependencies you will need. The default Maven Pom file alone is a big time saver.
If you don't want to use Roo you can easily just strip it out of your Maven pom file after your done doing the initial scaffolding.
The other option is using a Maven Archetype like AppFuse but I haven't used this in quite some time and I find Roo easier.
What I don't recommend is wasting your time writing an Ant script and then trying to cobble together all the dependencies.

Categories

Resources