I’m currently having a hard time with my project, which is an EAR containing a WAR with both BE (Java Spring) and FE (Angular).
Basically I’m trying to deploy it to a JBoss server, which I can’t directly configure.
When I deploy I would expect to access the app at an url like this:
https://example.com/IntDatiWeb
This url should show the dashboard, but it doesn’t. Instead, for some reason, when building the project, an index.jsp (containing a simple hello world) gets created on the WAR’s root.
I don’t know where this jsp comes from, even considering that WAR should only contain META-INF folder and the WEB-INF folder.
At WEB-INF/angular there’s the index.html that the app should be loading when accessing the url above.
Given this structure I figured out that accessing https://example.com/IntDatiWeb/angular shows the app dashboard.
Now my goal is to access the app at https://example.com/IntDatiWeb, and I really tried everything.
Right now my MVC resource handler in the BE looks like this:
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations("/WEB-INF/angular/")
.setCachePeriod(0)
.resourceChain(true)
.addResolver(new PathResourceResolver() {
@Override
protected Resource getResource(String resourcePath, Resource location) throws IOException {
Resource requestedResource = location.createRelative(resourcePath);
Resource indexResource = location.createRelative("index.html");
return !resourcePath.equals("/") && requestedResource.exists() && requestedResource.isReadable() ? requestedResource :indexResource;
}
});
}
While app-routing.module.ts in Angular looks like this:
const routes: Routes = [
{
path: '**',
pathMatch: 'full',
redirectTo: '',
},
];
export const routingConfig: ExtraOptions = {
paramsInheritanceStrategy: 'always',
};
@NgModule({
imports: [RouterModule.forRoot(routes, routingConfig)],
exports: [RouterModule],
})
export class AppRoutingModule {}
Is there a way to definitely solve this problem, possibly without having to edit JBoss configurations?
Even if JBoss must be configured in another way, I would like to know a possible solution, anyway.
Thanks in advance, and tell me if you need any more info.