What should I do to be able to access the Webjars from Angular application on Weblogic Server?
I've received basic temporary project, which is running on Tomcat, but on Weblogic it's not working properly. After few modifications, I was able to deploy the application, but I'm not able to run it properly. The webjars are still not visible. What's more, I also found that for Weblogic 12C, I should use this dependency in Gradle
:
compile 'org.webjars:webjars-locator-weblogic:0.9'
but after that, I'm not able to deploy the application because I'm receiving an error "URI is not hierarchical". Without this dependency, I'm able to deploy the application and see the index.html
, but it points to other js
file like this:
<script data-main="js/configImport" src="webjars/requirejs/require.min.js"></script>
which contains something like this:
require.config({
map: {
'*': {
'css': 'webjars/require-css/css'
}
},
paths: {
'angular': 'webjars/angularjs/angular.min',
'myApp': 'js/app',
'cssCore': 'js/cssCore'
},
shim: {
'angular': {exports: 'angular'},
},
baseUrl: '.'
});
require(['angular', 'myApp', 'cssCore', 'js/controllers/MainCtrl'], function (angular) {
angular.bootstrap(document, ['myApp']);
});
I also tried to add this line to servlet.xml
file:
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
but with no success.
All the webjars are added by Gradle
as dependencies. spring-boot
and webjars-locator
are at compile level, the rest like angularjs
at runtime level.
What am I missing? What should I do in this case to make it work?
UPDATE :
I'm adding the stack trace from the deployment with webjars-locator-weblogic
. The question is if do I need to put both: webjars-locator
and webjars-locator-weblogic
or only weblogic version?
I tried with both and in both cases I'm getting the same error. I tried to solve this problem by adding WebConfig
class like its done here and even adding the code in Main
class like it's done under the same link but at the topic Enhanced support for RequireJS
. Unfortunately it didn't work for me. I still can't access the webjars.
Don't know if you already got it working, but what works for me with weblogic 12.2.1.3 is:
All js/css are then resolved correctly. Example:
<script type="text/javascript" src="/app-name/webjars/angular/1.6.6/angular.js"></script>
On a side not, i am using "standard" spring, not boot. Shouldn't make any difference though. Webjars are packed inside the war (in WEB-INF\lib) while the remaining dependencies (spring, aspectj, other application modules, etc.) are packed inside the ear package. The build comes down to a ear package containing:
What i can't get to work with weblogic is the version agnostic locator. Have tried with both standard webjars-locator and webjars-locator-weblogic with no luck.
[EDIT] On a side note, i did get that same error you got (URI not hierarchical) when, by mistake, i placed the webjar dependencies on the ear module instead of the war one. After placing them in the war, i found out that weblogic is rather "sensitive" regarding the servlet mappings. I had the standard servlet mapping pattern to root (like i usually have on other servers) and that was somehow messing with the remaining mappings (webjars included). In the end i had to specify a url pattern other then to be handled by Spring alone.