SpringBoot test for multi project - spring

I've got gradle multi project. One project(A) imports another project(B) functionality in code with custom annotation.
All works good, except for springboot test for loading context in project A. I've got error "Could not open ServletContext resource", it happens because test is not able to find yml file from project B.
Could you please help me with it?

Related

Injection Dependy of a Multimodule Maven project in Maven

I have the following issue.
On one hand I have a multi module maven project, which I use maven install to write the .jar files in my local .m2 repository. This is working fine. Lets call it MultiA.
Now on the other hand, I have a spring boot project (lets call it SpringB) in which I bind the .jar files from my multi module maven project. This is working fine as well. When I execute my buisness logic from IntelliJ, I receive no issue, but when I build the project as a .jar, I receive an issue because the settings.properties file from MultiA are not found. I do not try to access settings.properties from SpringB, but I call a method from MultiA, which in return trys to access the settings properties.
I hope, this description helps and someone knows the answer to this problem.

Jar file not getting added in to a external Libraries in Intellij

I am trying to work on a spring-security project in which i have added the spring security dependency via pom.xml file.But as my maven completed its build successfully,its not getting added in the external library.
Please find my the screenshots below:
pom.xml file:
External Library
Dependencies added after successful maven build :
Tried to create a new project to check whether the above issues persist there as well,but there its working as expected as i am able to get the required java files.So the issue is only relevant to the above project.
I even tried to do the steps mentioned from the below links apart from the maven life cycle steps,but that also did not work out
link

Exception: org.exolab.castor.xml.ValidationException was not added to the list of sorted types

I am trying to deploy EAR file on Websphere Application Server but while deploying it's showing an error.
ERROR CODE:
SEVERER: Exception org.exolab.castor.xml.ValidationException was not added to the list of sorted types.
The project was not built since its build path is incomplete. Cannot find the class file for org.exolab.castor.xml.ValidationException. Fix the build path then try building this project.
I am using Castor in my project but it's there in classpath which i am setting through Shellscript.
Thanks for help in advance.
Your dependencies need to be expressed to the application server runtime, not added to some shell variable or standalone java invocation. Either package them in your application or create an isolated shared library and associate it with your dependent application.

how to access some new java classes added to the existing jar from gwt project when we run with Maven

I am facing below issue when I am running maven for gwt project.
in my project we have "A" project created by using gwt frame work.
"B" project is a java project and we need to access B project classes in "A" project server side.so created a jar for B project and added in A project build path.
Now I need to add some new classes in B project and that new classes should access from "A" project client side.
We can able to add new classes in B project and after running maven for B-project, we are able to see new classes in B-project jar.
But when I run maven for Project A it shows an error like "did you forget to inherit a required module?".
Note: same test projects I have created and can able to access B-project new classes in A-project client side code. But when I am running with Maven it is unable inheriting these new classes.
Kindly advise me how to solve this issue.
Generally you need to compile your code into javascript in order to make it accessible from the client side (if we aren't considering requestfactory proxies, web services etc. here). If your code is located outside the GWT module it simply doesn't exist for client side. Practically this means that you need to extract the client side accessible classes from the B module and put it into A\shared folder for example. Also don't forget to place <source path="shared" /> into your A gwt.xml descriptor. The drawback of this refactoring of course is that you're allowed to use only "JRE emulated" classes in your shared code.
Another solution would be a creation of a gwt module inside your B project and inheriting it in A project.

Eclipse Java EE project and Spring : classnotfoundexception

I am trying to build an project in Eclipse (actually I'm using RAD, so basically eclipse, and when I say 'Java EE Project' I mean an 'Enterprise Application Project').
My Enterprise Application Project (the 'EAR' project) has two module projects :
- service
- web
The service project has some stuff in it, all wired up using Spring.
The web project has its own stuff in it, all wired up using Spring. The UI stuff in the web project needs to use the stuff in the service project.
Both projects are included in the EAR project as modules.
The web project lists the 'service' project as a dependent project in the build path, it's checked off for export, and also has it listed as a EE Module Dependency.
I'm having a really hard time to get this working though:
The spring context in the web project is of course what gets loaded when the application is deployed, and it imports the spring config I need from the service project. This seems to be working fine.
When spring tries to instantiate a bean it throws a ClassNotFoundException. On the very first bean.
I tried simply copying the spring config from my service context and pasting it into my web context, but I got the same ClassNotFoundException.
I have tried instantiating an object of that type (the class that spring says cannot be found) in the java controller class in the web project, and it is successful, both at compile time (no compile errors) and at runtime (no exceptions).
So the classes from my service project are not available on the classpath when spring tries to use them.
Any ideas what's going on here and/or what I might be able to do about it?
There is a class loader policy that you should use ParentClass First . That will be managed either through Application.xml or through web.xml . You need to check your xml's then try.
It's a class loader issue.
Since you're using Spring, I'll assume that you don't have EJBs. If that's the case, why do you need an EAR? Deploy the whole thing as a web project, in a single WAR.
Put all your .class and Spring configuration .xml files in WEB-INF/classes. Load the configuration using org.springframework.web.context.ContextLoaderListener.
I seem to have fixed this - I'm not sure exactly what the problem was but there must have been a small typo in my spring config. I decided to just start fresh with a new spring config and when I started building the new one back up things were working fine. There must have been a problem with the old one.
Thanks for the suggestions though.
Unfortunately we're not always able to change project structure. We're working on structures other people have put in place.
I looked into the ParentClassFirst vs ParentClassLast setting - it seems on websphere the ParentClassFirst setting is the default if you don't specify anything, so I'm leaving it without specification to get that functionality.
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/crun_classload.html

Resources