Skip to content

From JAX-RS to Spring MVC#513

Closed
mhdirkse wants to merge 12 commits intomasterfrom
jaxrs-springmvc
Closed

From JAX-RS to Spring MVC#513
mhdirkse wants to merge 12 commits intomasterfrom
jaxrs-springmvc

Conversation

@mhdirkse
Copy link
Member

@mhdirkse mhdirkse commented Jul 3, 2025

No description provided.

Fix

Remove CXF from pom.xml

Replace authorization

License years

Fix javadoc and take care or role IbisAdmin

License years

Restore ApiServlet

Exclude com.sun.activation:jakarta.activation

Add Spring security dependency

Do I want this commit?

Fix Spring annotations so that frontend can reach backend again

Fix @RolesAllowed annotations

Fix dependencies

Fix pom.xml

Remove unnecessary change

Remove unnecessary changes
@mhdirkse
Copy link
Member Author

Toen ik het op dit punt testte zag ik nog de volgende fouten:

  • Ik kon het aantal rapporten dat ik in de debug tabel wilde zien niet veranderen. Ik heb geen HTTP request gezien naar de backend die dat had kunnen doen.
  • De custom report action knop werkte niet, zie stacktrace hieronder.
  • Ik zag geen API call toen ik de compare method van een rapport veranderde.

Custom report action stack trace:

18-Aug-2025 12:34:03.991 SEVERE [http-nio-80-exec-8] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [spring-mvc-dispatcher] in context with path [] threw exception [Request processing failed: java.lang.IllegalStateException: No primary or single unique constructor found for interface java.util.List] with root cause
java.lang.IllegalStateException: No primary or single unique constructor found for interface java.util.List
at org.springframework.beans.BeanUtils.getResolvableConstructor(BeanUtils.java:268)
at org.springframework.validation.DataBinder.createObject(DataBinder.java:931)
at org.springframework.validation.DataBinder.construct(DataBinder.java:910)
at org.springframework.web.bind.ServletRequestDataBinder.construct(ServletRequestDataBinder.java:116)
at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.constructAttribute(ServletModelAttributeMethodProcessor.java:157)
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:148)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:227)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:181)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:986)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:891)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1089)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:195)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:164)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:140)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:483)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:116)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:666)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:398)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:903)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1769)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1189)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:658)
at org.apache.tomcat.ut

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
boolean granted = false;
for(GrantedAuthority grantedAuthority : getAuthentication().getAuthorities()) {
String authorityName = grantedAuthority.getAuthority().substring(5); // Chomp off the AuthorityAuthorizationManager#ROLE_PREFIX
granted = authorityName.equals(role);
if(granted) {
return true;
}
}
return false;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

public abstract class ApiBase implements SecurityContext {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deze class moet weg kunnen.

@@ -49,23 +54,23 @@ protected <T> T getBean(String beanName) {
}

protected void setSessionAttr(String key, Object value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik weet niet waarom je dit zo zou doen, als je sessie scoped variables op wilt slaan moet je een component aanmaken met een @SessionScope.

@Path("/" + ApiServlet.LADYBUG_API_PATH + "/metadata")
@RestController
@RequestMapping("/metadata")
@RolesAllowed({"IbisDataAdmin", "IbisAdmin", "IbisTester"})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Het lijkt mij dat deze hier niet hoort, je hebt de annotaties ook al op de methodes?

Comment on lines 82 to 92
<dependency>
<groupId>com.fasterxml.jackson.jakarta.rs</groupId>
<artifactId>jackson-jakarta-rs-json-provider</artifactId>
<version>${jackson.version}</version>
<exclusions>
<exclusion>
<groupId>com.sun.activation</groupId>
<artifactId>jakarta.activation</artifactId>
</exclusion>
</exclusions>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deze dependency kan dan toch ook weg?

Comment on lines +70 to +75
<!-- Makes spring-web a transitive dependency. That one is sufficient to
build this project, but the project that uses ladybug probably needs
spring-webmvc. If it is not included as a dependency here, it is
difficult to ensure that spring-web and spring-webmvc have the same
version
-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Daarom gebruik je een bom import, zodat de versies altijd kloppen.

@nielsm5
Copy link
Contributor

nielsm5 commented Oct 22, 2025

@mhdirkse mhdirkse marked this pull request as draft November 18, 2025 09:51
@mhdirkse
Copy link
Member Author

Ladybug will be split in three modules to keep JAX-RS. Therefore this PR will be superseded. I won't close it yet to keep easy access to it to copy files.

@mhdirkse
Copy link
Member Author

Superseded by #598.

@mhdirkse mhdirkse closed this Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants