Jsweet library does not work in web application - transpiler

I have tried transpiling java file to javascript file using jsweet library. It works when I executed via the main method of the java class. But the same code does not work when called via a web application hosted on tomcat. Is there any configuration needed for that ?
I am using JDK : 1.8
what I have noticed is when executed from web application :
setupCompiler() method from jsweet class 'org.jsweet.transpiler.JSweetTranspiler' returns null giving warning message : errors during parse tree

Related

Office-js addin with webapi on Azure. Fetch error

Windows 10 20H2, VS 2019 Community
Application contains one office-js addin (typescript) + one Webapi core (c#) in a container, both components communicating with a fetch function thanks to cors.
It works properly on my local computer.
I published both components on azure, the webapi component being derived as a container instance. I checked that the correct azure addin address was entered in the webapi startup module.
Now, each individual component works properly (proof with messages from the addin and with postman for the webapi) but fetch function raises errors (message = "failed to fetch).
Could someone tell me what I did miss ?
Thanks in advance.
Closed. Finally it was about :
debugging in localhost is not enough. You have to test with Swagger. In my case I had a wrong return with a String[] and the decoration of the controller was not ok
having a plain Web api application (ie : with a wwwroot)

Request for (gzipped) 'jsf.js' from Mojarra 2.3.3 results in empty response

I used the <f:websocket/> tag in my project with mojarra 2.3.3 and in project stage 'Development' everything was working fine. But when the project was deployed on our QA system with project stage 'Staging', the client produced the JS error "'mojarra' not defined".
This is due to the jsf.js being loaded as a blank file. When I debugged, I found that in com.sun.faces.application.resource.ResourceHelper#getInputStreamFromClientInfo the content of the js file is copied to a GZIPOutputStream which is never finished and thus nothing is written to the wrapped ByteArrayOutputStream (ll. 234-237), resulting in the empty response to my client.
In stage Development the file is delivered uncompressed.
Is this a bug or am I missing something? Is there a configuration for this? Is there a workaround?
I tried setting com.sun.faces.compressJavaScript to false with no luck.
When I call GZIPOutputStream#finish() on the stream before it's written to the ByteArrayInputStream in the debugger, the content of the input stream is correct and sent to the client. I also checked mojarra 2.3.8 but the code seems to be unchanged.
I expect the client to receive the correct js code. It doesn't necessarily have to be compressed.
Addition:
The project is running on a Tomcat 8.5.14 with JDK1.8.0_161 and I'm using Primefaces (6.2).
I created a miminal working example here which doesn't use Primefaces. It doesn't actually push anything into the websocket channel but the relevant thing here is the JS error when the index.xhtml is loaded.
It's also tested with Java 1.8_202, Tomcat 8.5.37, Mojarra 2.3.8. It's working (loading the jsf.js that is) with Mojarra 2.2.14.

Why doesn't Azure load properly the Interop?

I have a WebApp on Azure that uses a dll. This library needs Interop libraries x86 and x64.
Sometimes, at the restart of the App (I suppose), the App fails due to an exception:
System.EntryPointNotFoundException: Unable to find an entry point named 'sqlite3_config' in DLL 'SQLite.Interop.dll'. at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op) at System.Data.SQLite.SQLite3.StaticIsInitialized() at System.Data.SQLite.SQLiteLog.Initialize() at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework) at T_Dox.WebService.SQLiteDb.CreateConnection() at WebService.CeDb.Connect()
The SQLite used is the SQLCipher's one.
What am I missing here? I don't understand why the app stops working suddenly even if I don't make any changes.
The App is a Web Service (.asmx file) that uses a data access layer to perform some business logic.
It was under a web site project, then we moved it into another project, a webapi\mvc project.
The routing bypasses this extension, so it works as before, a simple web service call.
The called web method initializes a business class loaded from another .net library (a VB.Net library).
Inside, this class uses a wrapper to a sqlConnection, in this case the SQLiteConnection.
In its constructor it starts an SQLiteConnection, and normally it works.
Then it performs some CRUD operations ...
So I can represent the operation this way:
[WebService(Namespace = "...")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SampleService : System.Web.Services.WebService
{
[WebMethod]
public ServerInfo Test()
{
var sampleBusinessClass = new SampleBusinessCLass();
sampleBusinessClass.DoSomething();
using(var connection = new SQLiteConnection()) //the constructor is the parameterless one
{
//...
}
}
}
And the stack will be this (this is not the real one):
System.EntryPointNotFoundException: Unable to find an entry point named 'sqlite3_config' in DLL 'SQLite.Interop.dll'.
at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op)
at System.Data.SQLite.SQLite3.StaticIsInitialized()
at System.Data.SQLite.SQLiteLog.Initialize()
at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework)
at xxx.WebService.SampleService.Test()
It always works, but sometimes it starts to launch this error until the stop and start of the web application on iss (in our case: Azure).
Inspecting the System.Data.SQlite.dll I can clearly see the entry point and actually it always passes this internal code (no conditions that can bypass this part) and it generally works.
The System.Data.SQlite.dll (1.0.96.0 version) is provided by SqlCypher product. I think it is the original System.Data.SQLite one because at first sight I can see the same assembly manifest and content.
The interop System.Data.SQLite uses is probably modified by SqlCypher team to give their features.
To avoid possible issues we put the interop in the path /bin/x64, then we compile our web app ONLY in x64 and it runs on a x64 environment.

Cannot read properties file with web app (Maven web app with JSF)

I have a properties file: hibernate.properties inside default package. I am trying to read it from a class inside another package: com.somepackage.SomeClass.
In a normal desktop application, the following input stream is working:
InputStream is = getClass().getResourceAsStream("/hibernate.properties");
But with my web app (A maven web application created using Netbeans with JSF 2.2 as dependency)
I tried these alternatives:
Using class:
getClass().getResourceAsStream("/hibernate.properties");
Using external context:
FacesContext.getCurrentInstance().getExternalContext().getResourceAsStream("/hibernate.properties");
Using context class loader:
Thread.currentThread().getContextClassLoader().getResourceAsStream("/hibernate.properties");
Each of these return null. How do I read the properties file inside the default package?
I assume you are looking on the wrong location for the file. hibernate.properties is usually not saved in the root of the deployment. Open your .war file and look up the location of hibernate.properties. If you have your application deployed to localhost:8080/app1 you need to call /app1/ to access the contents of your deployment.

Chrome extension: "Uncaught Error: "getBackgroundPage" can only be used in extension processes...."

I published a chrome extension to testers only. The app seems to work very well. I don't see any errors when inspecting the console for the popup or the background page. However, I get the following error when inspecting the console for any web page: "Uncaught Error: "getBackgroundPage" can only be used in extension processes. See the content scripts documentation for more extensions/schema_generated_bindings.js:418"
This app contains several JavaScript files, but each one includes the code within a self executing function. The "getBackgroundPage" calls are in the JavaScript files.
Could you please help? Isn't the app I built an isolated module independent from any web page? How can I prevent this error from happening?
I had the same error when I was trying to communicate with the background page from my content script. The correct way of doing it is via Message Passing. It is very well documented here : https://developer.chrome.com/extensions/messaging.html

Resources