Fórum

Adding React JS as an OSGi module

thumbnail
Krzysztof Gołębiowski, modificado 6 Anos atrás.

Adding React JS as an OSGi module

Liferay Master Postagens: 549 Data de Entrada: 25/06/11 Postagens Recentes
Hello Everybody,
A long time has passed since I've been here last time, so I'm going to start my comeback with a question! I'm recently going deeper and deeper into OSGi/BNDTools/Blade and thousands other technologies introduced by Liferay 7 - this is hard but I'm trying to keep calm and go on emoticon

So, I want to add a React support to my portal, but not as it is done in many examples available on the internet - just as an include in the Theme/Portlet, or bundled together within a webpack-build bundle. I want to add it as a module, in a similar way as it is done with Senna JS or other JS libraries. There is the article JAVASCRIPT MODULE LOADERS, but from what I understand it's more about importing some specific features build on top of Liferay JS stack rather than importing a whole new framework, so I've gone deeper into LR code and found frontend-js-web module. There is a set of JS Libraries added to the portal via this module (including jQuery) so I wanted to do something similar with React. From what I understand, what happens there is:
  • The libraries are downloaded by Gradle via org.webjars.npm
  • Some processing happens (I don't want to get very deep into it) which is done by some node scripts
  • Gradle then executes some custom tasks and copies the libraries (configured in build.gradle)
  • Then they is picked up by embedded BNDTools (?) because of -includeresource: META-INF/resources=tmp/META-INF/resources and zipped in a jar file (bnd.bnd)
  • To be finally included in portal's HTML header as stated in Liferay-Top-Head-JS-Resources or Liferay-Top-Head-Authenticated-JS-Resources directives (also in bnd.bnd)

First question is where is the documentation about -includeresource (I guess it is a BND Tools thing) and Liferay-Top-Head-Authenticated-JS-Resources (this is Liferay one).

And second issue is that I cannot make it running, the build fails all the time either with [Input file does not exist: react.js, Input file does not exist: react-dom.js] or strange error Could not copy MANIFEST.MF to '/Users/kgolebiowski/someproject-src/modules/reactjs-web/build/tmp/jar/MANIFEST.MF'.

Can any of you explain to me what is actually the flow here, which tool is responsible for what action, where can I find some other examples of this and what could be wrong with my plugin?

My build.gradle:

task buildReact(type: Copy)

buildReact {
    from "${projectDir}/node_modules/react/dist/react.js", "${projectDir}/node_modules/react-dom/dist/react-dom.js"
    into "${buildDir}/"
}

classes {
    dependsOn buildReact
}

dependencies {
	compile group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.0.0"
	compile group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"
	compile group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
}


My bnd.bnd:

Bundle-Name: React JS Liferay Plugin
Bundle-SymbolicName: org.something.frontend-js-react
Bundle-Version: 1.0.0
Liferay-Releng-Module-Group-Description:
Liferay-Releng-Module-Group-Title: Frontend Infrastructure
Web-ContextPath: /frontend-js-react-web

Liferay-Top-Head-JS-Resources:\
	/react.js\
	/react-dom.js

-includeresource:\
    react.js,\
    react-dom.js


Regards,
KG
thumbnail
Christoph Rabel, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Liferay Legend Postagens: 1554 Data de Entrada: 24/09/09 Postagens Recentes
Hi Krzysztof,

Quite interesting. Especially Liferay-Top-Head-Authenticated-JS-Resources and Liferay-Top-Head-JS-Resources. I think, I can use them.

It doesn't matter how the js files are created, you can use grunt, gulp, webpack, do it manually, or whatever.

In the end, everything that should be deployed has to end up in the build folder. However you do it. I have a webpack build here and I just configured it to write the generated js, css & bundle file directly to the build folder (somewhere in resources/META-INF/resources/js; path from memory, so might be wrong).

-includeresource is a osgi directive(?) Not sure what's the correct term for those bnd file terms. It basically just copies files from the project folder to the build folder. It has a lot more features, but that's what it does. I used it a couple of times, but I am just a dabbler in the art. So, maybe somebody else can confirm or correct me.

AFAIK it just copies the contents of tmp/META-INF/resources to META-INF/resources when you write:
-includeresource: META-INF/resources=tmp/META-INF/resources

The Web-ContextPath maps your osgi bundle to that path. There is a "magic" servlet called "o" which does the mapping. Your files are then found later at /o/Web-ContextPath/...

When you use it, you need to give it parameters so that the files you want to copy end up where you want them.

I guess your main error is that it doesn't find the react js files it wants to copy. I got the Manifest error a couple of times, it always meant that something else went wrong earlier in the build process. So you can probably ignore it.

I guess "Liferay-Top-Head-JS-Resources" is picked up later by Liferay when you deploy your jar file. It only makes sense that way. It has to read the list and add it to the theme includes.

hth

Btw.: Are you coming to Devcon in Amsterdam?
thumbnail
Krzysztof Gołębiowski, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Liferay Master Postagens: 549 Data de Entrada: 25/06/11 Postagens Recentes
Hi Christoph,
It's nice to hear you again emoticon I've done some more research about Liferay-Top-Head-JS-Resources today and it turned out that it's even more complicated than I thought. I found some old documentation which seems to list the class responsible for handling it as one of Liferay Core Integration Points, however it is a very old repository and the directive is not mentioned in new docs.

I haven't managed to make it work, as it seems to me that the behaviour is hardcoded according to its type coming from method getResourceType method. It seems that the types in PortalWebResourceConstants and theirs behaviour is hardcoded somewhere in Liferay and using the type RESOURCE_TYPE_JS replaces all paths to Liferay bundles libraries breaking the portal. If I use my own type though, it doesn't work - no new Libraries are attached to the portal.

I shared my research plugin in on github if you or someone else wants to check it.

-includeresource is a osgi directive(?) Not sure what's the correct term for those bnd file terms.

That's the problem, because of lack of the documentation we don't even know what kind of "thing" it is and where does it come from... :/

Btw.: Are you coming to Devcon in Amsterdam?

Yes, definitely! See you in two weeks then emoticon
thumbnail
Chema Balsas, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module (Resposta)

Regular Member Postagens: 127 Data de Entrada: 25/02/13 Postagens Recentes
Hey guys!

Nice to see you giving this a try! A couple of notes:
  • The Liferay-Top-Head-JS-Resources and Liferay-Top-Head-Authenticated-JS-Resources are two new headers we've just introduced to modularize the old javascript.barebone.files and javascript.everything.files. It should allow any module to include resources in top_js.jspf. This won't see the light until a new full release comes out, so it's not something to use unless you're building out from master ;)
  • Providing an OSGi bundle with a global React isn't that hard, just a matter of configuring the build properly. We have some old examples floating around, but I'd recommend you take a look at https://github.com/izaera/liferay-npm-examples. Support for this has landed and will be available in SP5 and GA5. We hope we can simplify things for frontend developers, so any feedback will be welcomed!


Hope that helps!
thumbnail
Krzysztof Gołębiowski, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Liferay Master Postagens: 549 Data de Entrada: 25/06/11 Postagens Recentes
Hello Chema,
Great, thanks for the clarification, it's good to know that those extension points are (or rather will be) the equivalent to old barebone and everything files. Now I know why it is not working for me, I'll wait for GA5 then and give it another try emoticon

I looked at the react-example from the repository you mentioned and indeed it really looks like a clear and good approach. However I couldn't make it work - the plugin (together with the whole workspace) builds and deploys without any errors, but then on:
  • Liferay DXP Digital Enterprise 7.0.10 GA1

It generates a wrong src that obviously generates 404 (adding missing "/" results in 404 again):
<script src="http://intranet-liferay-localliferay-npm-example-react@1.0.0.js?languageId=en_US"></script>

  • Liferay Community Edition Portal 7.0.3 GA4

The src looks better but still doesn't work:
<script src="http://intranetdev-appsrv/combo/?browserId=other&amp;minifierType=&amp;languageId=en_US&amp;b=7003&amp;t=1500030939654&amp;liferay-npm-example-react@1.0.0.js"></script>

Portal produces 404 and there is the following error in logs:
12:32:51,830 ERROR [http-nio-8080-exec-9][ComboServlet:89] java.lang.IllegalArgumentException: Path liferay-npm-example-react@1.0.0.js does not start with a "/" character
java.lang.IllegalArgumentException: Path liferay-npm-example-react@1.0.0.js does not start with a "/" character
	at org.apache.catalina.core.ApplicationContext.getRequestDispatcher(ApplicationContext.java:454)
	at org.apache.catalina.core.ApplicationContextFacade.getRequestDispatcher(ApplicationContextFacade.java:221)
	at com.liferay.portal.servlet.ComboServlet.getResourceRequestDispatcher(ComboServlet.java:409)
	at com.liferay.portal.servlet.ComboServlet.doService(ComboServlet.java:221)
	at com.liferay.portal.servlet.ComboServlet.service(ComboServlet.java:86)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.servlet.filters.uploadservletrequest.UploadServletRequestFilter.processFilter(UploadServletRequestFilter.java:93)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.servlet.filters.language.LanguageFilter.processFilter(LanguageFilter.java:82)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:125)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:265)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:99)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:676)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)


Again adding missing "/" doesn't help as then it returns 404 and says that the path just does not exist.

I don't know those new mechanisms enough to diagnose the error on my own, maybe you have some ideas?

Regards,
KG
thumbnail
Chema Balsas, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Regular Member Postagens: 127 Data de Entrada: 25/02/13 Postagens Recentes
Hey Krzysztof,

The npm examples will work only on SP5 and GA5 (and future versions). The infrastructure to support it is not there in previous releases

The new headers will only be available in a future 7.1 release, so don't be waiting around to use it anytime soon emoticon
thumbnail
Krzysztof Gołębiowski, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Liferay Master Postagens: 549 Data de Entrada: 25/06/11 Postagens Recentes
Ok, then I'm really looking forward to the new version to play with the npm-examples.

Thanks and hope to talk to you at the Devcon emoticon
KG
Óscar Rodríguez Bouza, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

New Member Postagens: 2 Data de Entrada: 17/08/17 Postagens Recentes
Hi guys,

Sorry for bumping this thread but my problem is pretty similar to Krzysztof's issue.

I saw from Liferay's Dev Con Modern frontend workflows in Liferay Portal presentation and I thought it was cool to try the angular-npm-portlet demo but so far I'd been unable to do so.

I'm running Liferay DXP Enterprise Edition with Fix Pack 32, so all this new stuff should be supported. (FP30 is the requirement)

Generated script tag after adding the portlet to a blank page looks as follows:
<script src="/combo/?browserId=other&amp;minifierType=&amp;languageId=en_US&amp;b=7010&amp;t=1508483605453&amp;angular-npm-portlet@1.0.0.js"></code></pre><br /><br />And the error on liferay log is pretty similar to Krzysztof&#39;s one:<br /><pre><code>
07:30:08,420 WARN  [http-nio-8080-exec-6][code_jsp:172] {code="404", msg="ProxyServlet: /o/frontend-js-web/es6-promise.map", uri=/o/frontend-js-web/es6-promise.map}
07:30:08,514 ERROR [http-nio-8080-exec-1][ComboServlet:89] java.lang.IllegalArgumentException: Path angular-npm-portlet@1.0.0.js does not start with a "/" character
java.lang.IllegalArgumentException: Path angular-npm-portlet@1.0.0.js does not start with a "/" character
	at org.apache.catalina.core.ApplicationContext.getRequestDispatcher(ApplicationContext.java:454)
	at org.apache.catalina.core.ApplicationContextFacade.getRequestDispatcher(ApplicationContextFacade.java:221)
	at com.liferay.portal.servlet.ComboServlet.getResourceRequestDispatcher(ComboServlet.java:426)
	at com.liferay.portal.servlet.ComboServlet.doService(ComboServlet.java:238)
	at com.liferay.portal.servlet.ComboServlet.service(ComboServlet.java:86)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:119)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.frontend.compatibility.ie.servlet.filter.IEMimeTypeCompatibilityFilter.processFilter(IEMimeTypeCompatibilityFilter.java:48)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.servlet.filters.uploadservletrequest.UploadServletRequestFilter.processFilter(UploadServletRequestFilter.java:93)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.servlet.filters.language.LanguageFilter.processFilter(LanguageFilter.java:82)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:125)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.servlet.filters.jsoncontenttype.JSONContentTypeFilter.processFilter(JSONContentTypeFilter.java:42)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:142)
	at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:265)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:48)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:207)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:112)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:168)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:188)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:96)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:99)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
07:30:08,566 ERROR [http-nio-8080-exec-1][status_jsp:907] Path angular-npm-portlet@1.0.0.js does not start with a "/" character
</code></pre><br /><br />Anything to try?<br />Thanks!</script>
thumbnail
Ivan Zaera, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Regular Member Postagens: 119 Data de Entrada: 01/10/13 Postagens Recentes
Hi Oscar:

Can you please check the version of your gradle workspace plugin as explained here: https://github.com/liferay/liferay-npm-build-tools/issues/56 ?

I think that may be the cause.

Cheers,
Ivan
Oscar Rodríguez, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

New Member Postagens: 2 Data de Entrada: 17/08/17 Postagens Recentes
Ivan Zaera:
Hi Oscar:

Can you please check the version of your gradle workspace plugin as explained here: https://github.com/liferay/liferay-npm-build-tools/issues/56 ?

I think that may be the cause.

Cheers,
Ivan


Hi Ivan,

Thanks! Got it to work! emoticon

I was trying to expand angular npm example (https://github.com/liferay/liferay-blade-samples/tree/master/gradle/apps/npm/angular-npm-portlet) but I'm finding an issue with external templates.

What I did is to modify app.component.ts so


    template: `
        <h1>{{title}}</h1>
        <h2>{{hero.name}} details!</h2>
        <div><label>id: </label>{{hero.id}}</div>
        <div>
        <label>name: </label>
        <input [(ngModel)]="hero.name" placeholder="name">
        </div>
    `


Became..

    templateUrl: './app.component.html'


And create the corresponding app.component.html at the same level of app.component.ts. Nothing fancy

Liferay log shows no error, but when loading the portlet on my browser tries to look for app.component.html under http://localhost:8080/app.component.html resulting on a 404 error.

How I can define the template so angular knows where to look it for?
Thanks in advance
thumbnail
Ivan Zaera, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Regular Member Postagens: 119 Data de Entrada: 01/10/13 Postagens Recentes
Hi Oscar:

As you have guessed the template URL is not correct. You need to use /o/npm-angular-portlet/js/app/app.component.html which is the correct URL for the html resource you are trying to use.

In particular:

- /o stands for the standard OSGi context prefix
- /npm-angular-portlet is the configured Web-ContextPath for the sample portlet (see its bnd.bnd file)
- /js/app/app.component.html is the relative path of the template resource (starting at src/main/resources/META-INF/resources, which is the root folder for the portlet's Web-ContextPath).

Cheers,
Ivan
thumbnail
Narsingh Pal, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Junior Member Postagens: 53 Data de Entrada: 18/01/14 Postagens Recentes
Hey guys,

Thanks for the nice example.

Wanted to know, how can we add/create portlet's resource URL in Angular module. Any pointers/guidance will help.


Thanks and Regards
Narsingh Pal
thumbnail
Narsingh Pal, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Junior Member Postagens: 53 Data de Entrada: 18/01/14 Postagens Recentes
Hey guys,

Thanks for the nice example.

Wanted to know, how can we add/create portlet's resource URL in Angular module/component. Any pointers/guidance will help.


Thanks and Regards
Narsingh Pal
thumbnail
Ivan Zaera, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Regular Member Postagens: 119 Data de Entrada: 01/10/13 Postagens Recentes
thumbnail
Narsingh Pal, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Junior Member Postagens: 53 Data de Entrada: 18/01/14 Postagens Recentes
Just wondering how to get reference of Liferay/AUI object in component.ts file?


Hi Guys.. any suggestions ?

Thanks and Regards
Narsingh Pal
thumbnail
Narsingh Pal, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Junior Member Postagens: 53 Data de Entrada: 18/01/14 Postagens Recentes
Just wondering how to get reference of Liferay/AUI object in component.ts file?


Hi Guys.. any suggestions ?

Thanks and Regards
Narsingh Pal
thumbnail
Ivan Zaera, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Regular Member Postagens: 119 Data de Entrada: 01/10/13 Postagens Recentes
If you mean accessing any global from Typescript, you just need to declare it like explained in https://stackoverflow.com/questions/12703266/how-to-handle-warnings-for-proprietary-custom-properties-of-built-in-objects-in/12703866#12703866.

Basically you would put:


interface Liferay {
    AUI: any
}


if you want to access Liferay.AUI.

And so on...

This may help too: https://stackoverflow.com/questions/12709074/how-do-you-explicitly-set-a-new-property-on-window-in-typescript#30740935
thumbnail
Narsingh Pal, modificado 6 Anos atrás.

RE: Adding React JS as an OSGi module

Junior Member Postagens: 53 Data de Entrada: 18/01/14 Postagens Recentes
Ivan Zaera:
If you mean accessing any global from Typescript, you just need to declare it like explained in https://stackoverflow.com/questions/12703266/how-to-handle-warnings-for-proprietary-custom-properties-of-built-in-objects-in/12703866#12703866.

Basically you would put:


interface Liferay {
    AUI: any
}


if you want to access Liferay.AUI.

And so on...

This may help too: https://stackoverflow.com/questions/12709074/how-do-you-explicitly-set-a-new-property-on-window-in-typescript#30740935


Thanks Ivan,

Will try this out.


Regards
Narsingh Pal