Our use case is initiate a java object in Domain Mule app via spring. And the object has to be available in referenced Mule projects
This use case was achieved in mule 3. But It seems Mule 4 - each app has come with own spring application context. The object are not visible in referenced mule 4 project
Is it possible to make the object initiated in Domain available in referenced mule 4 project?
Technically Domain app is what is shared in cluster. So, technically, you cannot share Java objects at all. My guess - app should create Java object and pass it to some some flow or process in the Domain app which will modify/initialize this object.
One of the biggest differences between Mule 3 and Mule 4 - total isolation of Java environment in Mule 4. Not only Mule Context is not available and cannot be used but whole Mule Java environment is unavailable. Almost all classes are protected and cannot be used. and, of course, it is all proprietary. So, Mule 3 approaches do not work in Mule 4.
https://simpleflatservice.com/mule4/Mule3toMule4Transformation.html
Related
I encountered big trouble when trying to migration a web application from Java 8 to Java 11.
The web application:
The web application provides SOAP web services (using Spring WS), is written in Java 8 and runs on Tomcat 9. Spring 4.3 is used for database access, OXM, MVC and dependency injection.
To build the web services, multiple XSD files are used to auto-generate the class files and WSDL document for the web service interface using the xjc tool from the JDK.
My goal:
Migrate the application to Java 11, Tomcat 10 and JakartaEE.
What I have done so far:
In the first step, the compiled web application is migrated using Apache migration tool (version 1.0.0) to get it running on Tomcat 10. There is no problem.
Java migration:
The next step is, to migrate the source code from Java 8 to 11.
Java 11 does not longer include the tools and libraries for XML binding, which makes it necessary to include the XML bind library from JakartaEE.
Rebuilding the auto-generated class files from the XSD files with xjc, that comes with the library, creates source code, which imports from jakarta.xml.bind instead of javax.xml.bind. (Which should be the correct package).
Using JakartaEEs library also requires some minor changes in the code (changing imports to use jakarta.xml.bind instead of javax.xml.bind)
That's the point, where the trouble begins...
The IDE shows no errors and the code is compiled with no errors. Running the web application shows me the error, that javax.xml.bind.JAXBException was not found.
Since there is no source file, that refers to javax.xml.bind I assume, that a library is the cause. I found many references to that package in the Spring OXM library. But: In the master branch of that library, that these references are still there.
I tries to run JEE XML bind and JakartaEE XML bind at same time, but then Spring WS complains about multiple object factories of same type in same name space (which is not true by the way. Both object factories are generated by xjc for different name spaces and reside in different packages...)
My questions:
How can one use JakartaEE, when it is not supported by libraries like Spring?
Did I miss something?
Can someone give me some hints how to migrate the code?
Best regards,
Markus
I have been using the Spring Framework for about 4 years now, and now Spring Boot for the last couple of months. My Spring MVC applications are usually deployed on a Java EE container such as JBoss/WildFly or WebLogic. Doing so allows me to use JNDI for things like datasources or any other sensitive data that involve secrets/passwords. That makes my app "consume" that JNDI resource based on its name.
Now with Spring Boot and especially for self-contained microservices (embedded tomcat), that information is now stored within the application (application.properties and/or in Spring Java Config classes), so versioned in Git.
That makes that information a lot more exposed to other developers, which I'm not very comfortable with. I also don't like having those details show up in SonarQube and Jenkins (through workspaces).
Question is: Are there any best practices for this specific requirement?
* UPDATE *
I see some articles here and there about the use of Jasypt, but I wonder if it's still a valid library to use since the last stable release is dated from 2014.
Thank you
You could consider using a vault. Spring supports a few of them out of the box. You can find more information here http://projects.spring.io/spring-vault/.
If you have spring cloud in your stack, then it's very easy. Use encrypt the value and put it in the application properties. Follow the instruction mentioned here.
Other way is, set the values as environmental variables and using the environmental variables in the application properties. Instructions here
I have a spring-boot app that acts as a small framework for other apps. It provides a couple of JMS queues and a DAO layer to retrieve and store data from a common set of data stores. The problem is that the original developer of this framework app is scanning all the package "com.mycompany" (rather than com.mycompany.framework) so that it can load the beans of the specific app that may be declared under com.mycompany.myapp1 or com.mycompany.myapp2 an which JARs are bundled together with the JARs of the framework.
We only load a single app in the JVM (app1 or app2), but these apps may share other libraries and sometimes we end up with beans in the context that we don't need. (these may be needed in app1 but not in app2)
So, what would be your advice ?
My problem is similar to what was described here:
https://github.com/spring-projects/spring-boot/issues/3300
I am debating if each app should be aware of the framework and load it. Or if the framework should instantiate a class loader and create a new Spring context loading the app specific code as suggested in the link above.
Perhaps you should consider leveraging some of Spring Boot's Auto Configuration capabilities such as #ConditionalOnProperty or #ConditionalOnClass in your framework. That way, you can only actually enable certain beans if and when the application using your framework takes some specific action (e.g. has a given jar on the classpath, or sets a configuration value). For reference check out: http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-developing-auto-configuration
I am new to OSGi and am using Equinox "Virgo Tomcat Server" (VTS) along with eclipse blueprint, and got big assignment to do in limited time
There is application already developed in J2EE Style
By using JSP->Struts2->Spring->MySQL and SOAP Web Services.
-There are various layer in the existing architecture
Simple Request flow is as mention below
From UI layer->it goes to strus2 configration-> it goes to Spring Configuration->From Spring configuration xml (that is module wise application context xml) Struts Action class is called -From Struts Action class layer -> it goes to Task layer->handler layer->Service Layer -> Adapter or DAO layer ->DB in some cases from service layer call also goes to WebService layer and communicate with Back-end legacy system
My Queries are as Follows
Q1] From UI/JSP to up-to strtus2 action layer code for every module should be club together in to a single .war file say "onlinebank.war" and from struts2 action onwords module wise code in every layer should go in to Module wise OSGi bundles
For e.g. if there are 10 modules there should be 10 osgi bundles
And each module wise bundle should contain module specific code from every layer after action layer and there should be communication between one war "onlinebank.war" and 10 osgi bundles
Q2]To take Q1 to next level
If there are 10 modules then instead of crunching module specific code in one OSGi bundle,
I have to create 3 bundles for each module(XXXAPI,XXXMain,XXXConfig)
for e.g. TestModule
I] TestModuleAPI (will contain only interfaces and abstract classes)
II] TestModuleMain (will contain implementation of interfaces and abstract classes and will provide some default functionality)
III]TestModuleConfig (will be accessing the default functionality of Main Bundle Via API Bundle and also provide some customize/new functionality)
So if there are 10 Module and 3 OSGi Bundles for each module (API,Main,Config) then for 10 bundles there should be 3*10=30 bundles and there should be proper communication between -single war "onlinebank.war" and the 30 bundles
Also there should be proper communication among 30 bundles it self to resolve the dependencies and works together properly/synchronously
Any help will be greatly appreciated
Regards,
Gokul
This is a big task you are tackling. I did such a migration and am quite familiar with OSGi. Still it took about 2 months. So you should first not underestimate the problems you will be facing.
The next thing is that a typical spring application is not well modularized. As there are no private/public packages in JSE developers tend to ignore module boundaries. The modules often also do not have a clean and small API at all so people known what they should access and what not.
So I think your first task is to refactor the application so each bundle offers a minimal API and other modules only access the API. For this task it might make sense to use an architecture tool that allows to define and control these accesses. While still in spring you create beans from a service interface from the API. Later in OSGi the API will allow to define clean OSGi services. If you skip this step then OSGi will not have big advantages. OSGi only works well if the application is strictly modularized.
Then for the actual OSGi migration I can only urge you to hire some specialist to help you. It will be a waste of time and resources if you do this alone.
I'm trying to use the new environment abstraction in our Java EE/EJB application. We're already using SpringBeanAutowiringInterceptor to inject Spring Beans into EJBs by using the standard beanRefContext.xml to bootstrap the shared application context for the Java EE app.
Now I've written a concrete Environment class (derived from Spring 3.1 AbstractEnvironment) which uses some kind of environment "auto" detection to select the correct active profile for the machine on which the app is running on. With this feature our app can be delivered with all properties for all environements (inside the ear) and auto select the correct property set.
The problem is now that org.springframework.beans.factory.access.SingletonBeanFactoryLocator.createDefinition(String, String) builds a bean factory group around the beans/context in beanRefContext.xml using the StandardEnvironment class, and I see no simple way to configure the environment implementation to use here without rewriting(overwriting) some part of SingletonBeanFactoryLocator.
Is there a simple solution for this, or is s.th. planned in the direction for supporting to specify the Environment implementation with the EJB/Java EE integration?