I am having trouble playing sound assets in Haxe. I am able to import mp3s with swfmill without error:
<?xml version="1.0" encoding="utf-8" ?>
<movie width="100" height="100">
<frame>
<library>
... other resources ...
<sound id="Shoot" import="shoot.mp3"/>
</library>
</frame>
</movie>
In my Main.hx, I created a class called Shoot which extends Movieclip in the same way I used for my .png resources. Then I use this class as follows:
var sound:MovieClip = new Shoot();
stage.addChild(sound);
sound.play();
But at runtime, when this code is executed, I get the error
"Error #2136: The SWF File <project swf> contains invalid data".
Any obvious mistakes I'm making in my swf xml file or haxe code? How can I debug this error further?
I finally managed to play sounds from the library by declaring them as Sounds (instead of MovieClips)
class Shoot extends flash.media.Sound {public function new() { super(); }}
and you don't need to add them to the stage, just play it:
var shoot : flash.media.Sound = new Shoot();
shoot.play();
Related
In my Android Studio project I have a font file called 'cutive.xml'
The file path is: resources -> font -> cutive.xml
The file looks as follows:
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res/android" //Lint problem here
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="Cutive"
app:fontProviderCerts="#array/com_google_android_gms_fonts_certs">
As you can see, the app namespace is not formed correctly:
xmlns:app="http://schemas.android.com/apk/res/android"
In the MainActivity, I create a static Typeface object that references the font:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
typeface0024 = getResources().getFont(R.font.cutive); //app will crash if app namespace is corrected
else typeface0024 = Typeface.create(Typeface.SANS_SERIF,Typeface.BOLD_ITALIC);
The app loads correctly and finds the font, even though Lint claims that there is an error.
When I switch the app namespace to the correct form as such:
xmlns:app="http://schemas.android.com/apk/res-auto"
The app crashes on the line:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
typeface0024 = getResources().getFont(R.font.cutive);
the error logs gives the following reason: A RuntimeException
Caused by: android.content.res.Resources$NotFoundException: Font resource ID #0x7f090000
How can I fix the error given by Lint? Or, should I just suppress the error and even though the app namespace is not formed correctly the font and app will load correctly.
Any suggestions
I was able to fix the problem by using the 'android' namespace NOT the 'app' namespace.
According to the Android docs make sure you the have the following support library:
compile "com.android.support:support-compat:28.0.0"
Now it works and it looks like this:
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
android:fontProviderAuthority="com.google.android.gms.fonts"
android:fontProviderPackage="com.google.android.gms"
android:fontProviderQuery="Cutive"
android:fontProviderCerts="#array/com_google_android_gms_fonts_certs">
</font-family>
My team and I are new to TypeScript and NodeJS, and we're having some serious troubles getting this project off the ground. It's meant to be a modularized game asset pipeline written in TypeScript for use with NodeJS (I wasn't involved in the decision making here, and the discussion is still sort-of-ongoing, but we still need a prototype).
We have a good idea of the architecture already, but it's kinda difficult to even get the prototype running, because I just can't seem to manage to wrap my head around how modules work in combination with interfaces and external dependencies. Some of our components also need to use NodeJS or other library modules (e.g. NodeJS.fs for reading/writing files), and we'd prefer to be able to use ///reference to add the appropriate d.ts files to keep type safety at development time.
An example of the supposed project structure is:
/pipeline
/log
- ILog.d.ts
- StdOutLog.ts
- FileLog.ts
- ...
/reader
- IReader.d.ts
- TextReader.ts
- ...
/parser
- IParser.d.ts
- XmlParser.ts
- JsonParser.ts
- ...
/task
- ITask.d.ts
- JsTask.ts
- CliTask.ts
- ...
/...
The way we want to use it is that we provide default implementations for our interfaces (to cover the basics, e.g. running a console command, logging to a file or a stream, reading JSON and XML configs, ...), as well as the interfaces themselves so that other teams can create their own extensions (e.g. class GitTask extends CliTask to encapsulate repository operations, or class JpgReader implements IReader).
On the calling side, in a different project/runner app, it should work like this:
import pipeline = require('pipeline');
//...
var log = new pipeline.log.FileLog();
log.info("filelog started");
var parser = new pipeline.parser.XmlParser();
parser.parse(somexmldata);
log.info("parsing XML");
// ...
I'm very likely just doing it wrong (tm), but I feel that it's not easily possible to do with TypeScript what we want to do, especially considering that e.g. the definition for the log component can easily have several interfaces and also enums (factory, logger, logitem, logtarget, loglevel). As far as I understand, NodeJS modules need to be a single JS file, but using even a single import turns your module into an external module and those won't compile into a single file anymore, so that seems like a pretty steep roadblock to me.
Is there a way to realize that strucute and intended usage with TypeScript targeting NodeJS? If yes, what would the files need to look like (especially regarding the module hierarchy and component FQNs, e.g. pipeline.log.X, pipeline.task.Y, etc; how would I properly use module and export for it)? If no, what are suitable alternatives to achieve our goal?
[Update] I've refactored my prototype according to basarat's suggestion, and it already looks much better than before. However, I've encountered a compile error when using one class from another:
error TS2095: Could not find symbol 'LogItem'.
LogItem is a class defined in /log and it's used by StdOutLog.ts in the same folder. IntelliJ gives me multiple definitions for it (obviously, one the LogItem class itself, and the other in /log's index file where it's exported). I've tried using the module notation log.LogItem, but that didn't work. Adding all default implementation files to the global declarations file didn't work either. [/Update]
[Update2] Here's some more code around where the error happens. I don't get any errors/markings in IntelliJ, only when running the grunt-ts task.
// src/log/LogItem.ts:
///<reference path='../pipeline.d.ts'/>
class LogItem implements ILogItem {
// ...
constructor(level:LogLevel, message:string) {
// ...
}
public static create(level:LogLevel, message:string):ILogItem {
return new LogItem(level, message);
}
// ...
}
export = LogItem;
// src/log/Log.ts:
///<reference path='../pipeline.d.ts'/>
class Log implements ILog {
// ...
private getLogItem(level:LogLevel, message:string):ILogItem {
return LogItem.create(level, message); // <-- that's where I get the "symbol not found" error
}
// ...
}
export = Log;
// src/pipeline.d.ts:
///<reference path="../typings/node/node.d.ts" />
//grunt-start
/// <reference path="pipeline.ts" />
/// <reference path="log/Log.ts" />
/// <reference path="log/LogFactory.ts" />
/// <reference path="log/LogItem.ts" />
/// <reference path="log/StdLogEmitter.ts" />
/// <reference path="log/log.d.ts" />
/// <reference path="log/log.ts" />
/// <reference path="parser/JsonParser.ts" />
/// <reference path="parser/parser.d.ts" />
/// <reference path="parser/parser.ts" />
//grunt-end
[/Update2]
Reference all your .d.ts files in a global globals.d.ts file that has ///<reference tags to all your individual references + vendor.d.ts (e.g. node.d.ts) files.
/pipeline
/globals.d.ts
/log
- ILog.d.ts
- StdOutLog.ts
- FileLog.ts
- ...
/reader
- IReader.d.ts
- TextReader.ts
- ...
/parser
- IParser.d.ts
- XmlParser.ts
- JsonParser.ts
- ...
/task
- ITask.d.ts
- JsTask.ts
- CliTask.ts
- ...
/...
This keeps you from constantly referencing .d.ts files.
Now each typescript file will export some class e.g. XmlParser.ts:
/// <reference path='../globals.d.ts'/>
class XMLParser implements IParser{
}
export = XMLParser;
Each folder also has an index.ts that imports and the exports all the classes in that folder External module style:
export import XmlParser = require('./xmlParser');
// so on
Same for the one level up (pipeline/index.ts):
export import parser = require('./parser/index');
Now if you import pipeline/index.ts you code will work as expected :
import pipeline = require('./pipeline/index');
var parser = new pipeline.parser.XmlParser();
parser.parse(somexmldata);
log.info("parsing XML");
Note : Grunt-ts can create these import / export statements for you so that you do not need to worry about file paths : https://github.com/grunt-ts/grunt-ts/issues/85
I have a button on an XPage where I want to connect to a remote OpenOffice instance. OpenOffice is started and is listening for a socket connection.
The onclick event of the button runs following SSJS:
oo = new com.test.OpenOffice();
oo.init("host=127.0.0.1,port=8107");
oo.openFile("C:\\TEMP\\Test.odt");
The code raises an excepction jva.lang.IlleagalStateException: NotesContext not initialized for the thread
The exception is raised within the method initof the class OpenOffice.
The relevant parts of the class OpenOffice is the following code:
public class DHOpenOffice implements Serializable {
private static final long serialVersionUID = -7443191805456329135L;
private XComponentContext xRemoteContext;
private XMultiComponentFactory xMCF;
private XTextDocument oTextDocument;
public DHOpenOffice() {
xRemoteContext = null;
xMCF = null;
oTextDocument = null;
}
public void init(String hostAdr) throws java.lang.Exception {
xRemoteContext = null;
XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null);
XUnoUrlResolver xUrlResolver = UnoUrlResolver.create(xLocalContext);
String sConnect = "uno:socket," + hostAdr + ",tcpNoDelay=0;urp;StarOffice.ServiceManager";
Object context = xUrlResolver.resolve(sConnect);
xRemoteContext = UnoRuntime.queryInterface(XComponentContext.class, context);
xMCF = xRemoteContext.getServiceManager();
}
The code line Object context = xUrlResolver.resolve(sConnect); is the one that raises the exception.
Why is this happing? What is the reason for this exception and how can I resolve the situation?
N.B.: The class code runs smoothly in a standalone application. The error occurs only when the code is started by a SSJS code.
It looks like a threading issue. There are a number of things you can go and try:
Wrap the whole interaction into a custom class and use it from a managed bean instead of calling it from SSJS
Make sure not to hand over any Notes objects into the custom class, only your own
Check if the Open Document Toolkit would be sufficient to do the operations you are interested in, so you don't need to run OO
let us know how it goes
Update
Try to get outside the standard XPages cycle. One way is to deploy a custom plug-in servlet:
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class OpenOfficeServlet extends HttpServlet {
// Your code goes here
}
You need to get the plugin.xml right:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.equinox.http.registry.servlets">
<servlet alias="/ooproxy" class="com.yourcompany.OpenOfficeServlet" />
</extension>
</plugin>
Then you could e.g. post a JSON structure or a serializable Java object to the servlet with the data and process it there (async if necessary). You deploy such a plug-in using the updatesite.nsf
Thanks to the answer of #stwissel I was able to solve the problem (he pointed me to the right direction).
I could solve the problem with a simple OSGI plug-in. The servlet approach solved the problem, too, but for me the OSGI plug-in was easier to use.
So these are the steps to create the plug-in
start a new plugin project
copy the open office jar files into the project and include them into the build path
copy the custom class that uses the UNO API into the plug-in
create a feature project for the plugin
create an update site
deploy the plugin via an update site
The following site where also quite helpfull:
Creating an XPages Library
Wrap an existing JAR file into a plug-in
I have tried to implement a JavaBean in my Application. I'm new on this topic and as it didn't work I got two steps back and tried the same with a HelloWorld example which I had done my self some month ago. This time it didn't work, too.
I use the 8.5.3 Designer Client and we have a 8.5.2 Development Server.
I set in the Application property the flag for compatibility 8.5.2.
The JAVABean Code looks like this:
package net.ta.java.Backend;
import java.io.Serializable;
public class MyHalloWelt implements Serializable {
private static final long serialVersionUID = 1L;
private String HalloWelt;
public String getHalloWelt() {
return HalloWelt;
}
public void setHalloWelt(String halloWelt) {
HalloWelt = halloWelt;
}
public MyHalloWelt() {
HalloWelt = "Hallo neue Welt!";
}
}
The faces-config:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
<managed-bean>
<managed-bean-name>Test</managed-bean-name>
<managed-bean-class>net.ta.java.Backend.MyHalloWelt</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<!--AUTOGEN-START-BUILDER: Automatically generated by IBM Lotus Domino Designer. Do not modify.-->
<!--AUTOGEN-END-BUILDER: End of automatically generated section-->
</faces-config>
The XPage function-call:
<xp:text escape="true" id="computedField1" value="#{Test.HalloWelt}"></xp:text>
The Exception:
Exception javax.faces.FacesException: javax.faces.FacesException: Can't instantiate class: 'net.ta.java.Backend.MyHalloWelt'..
java.lang.ClassNotFoundException: class
java.lang.ClassNotFoundException: net.ta.java.Backend.MyHalloWelt
javax.faces.FacesException: Can't instantiate class:
'net.ta.java.Backend.MyHalloWelt'.. java.lang.ClassNotFoundException:
class java.lang.ClassNotFoundException:
net.ta.java.Backend.MyHalloWelt Can't instantiate class:
'net.ta.java.Backend.MyHalloWelt'.. java.lang.ClassNotFoundException:
class java.lang.ClassNotFoundException:
net.ta.java.Backend.MyHalloWelt java.lang.ClassNotFoundException:
class java.lang.ClassNotFoundException:
net.ta.java.Backend.MyHalloWelt class
java.lang.ClassNotFoundException: net.ta.java.Backend.MyHalloWelt
I followed a hint in this forum which says that it could be an bug with the JAVA Class Design Element new in 8.5.3. Like they said in the post I tried to put my class manually in the src\ path but it didn't work - same error.
I thought it is a compatibility issue with our 8.5.2 Server but locally the same error.
I hope someone could help me. I am at a loss with this... Thanks!
Michael
EDIT:
Thank you very much to all of the people helped me with this issue so far.
Now it works if I opend the XPage with my Notes CLient. It doesen't matter if the database is on the server or local. It doesen't work if I open it with a Browser. If I do so the error is still there.
My problem consists of more then one part:
1. I had a typo in the spelling of my Bean-Attribute "HalloWelt" => "halloWelt"
2. My Server don't have the German Language-pack installed, which caused the misleading Errormessages concerning the resources files.
3. The main Problem finally is the Domino Server 8.5.2 didn't recognize the "Class/JAVA" Folder new in Notes/Domino 8.5.3! If I move my JAVABean to a new created "src" folder the JAVABean get recognized and everything works fine. - A little confusing is the XPage works fine in Notes Client before moving the java file. Only browsers produce the error...
Thanks to all of You provided me with the needed hints. I have learned a lot more about JAVA Development as I had expected. :)
Michael
Whenever I come across this issue I choose in DDE Project - Clean... and clean the whole project. This recompiles all your Code, Xpages etc...
Besides that, I always assign an ID to my managed-bean like:
<managed-bean id="Test">
<managed-bean-name>Test</managed-bean-name>
<managed-bean-class>net.ta.java.Backend.MyHalloWelt</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
I am not really sure if that is required or not. As far as I can see, the bean tries to load your class so I assume, it is not.
Hope that helps-
Michael
Make sure in Java perspective/Package explorer view your classes are under "Code/Java" category. In Java perspective again, right click on project, Build Path/Configure Build Path... Make sure in first "Source" tab your source folder is listed.
At the time of declaring global variables don't initialize them and initialization has to be done with in the constructor,in the exception page root cause will be displayed including Code line no.
I'm working on REST web-service written with jersey and I'm trying to output some XML with CDATA sections in it. I understand the reference implementation of JAXB doesn't support that, so I've downloaded EclipseLink's MOXy and I'm trying to get the #XmlCDATA annotation to work.
My JAXB mapped bean looks like this
package com.me.entities;
#XmlRootElement #XmlAccessorType(XmlAccessType.FIELD)
public class MyBean {
#XmlAttribute
private URI thumbnail;
#XmlElement(name="longdescription") #XmlCDATA
private String description;
public MyBean() { }
public final String getDescription() { return description; }
public final void setDescription(String d) { this.description = d; }
}
and I have the jaxb.properties file in the com/me/entities along with the class files. The properties file has
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory
in it. I'm sure it gets loaded successfully since if I replace the factory class name with some nonsense the app breaks down. Also, explicitly marshaling the file creating the JAXBContext on my own works fine, so the problem seems related to jersey. According to this my setup is fine, but when my jersey resource returns an instance of MyBean
...
#GET #Produces(MediaType.TEXT_XML)
public MyBean getMyBean() {
MyBean b = new MyBean();
b.setDescription("Some blurb plenty of invalid chars like <<< && >>>");
return b;
}
what I get back has no CDATA in it, but looks like
<?xml version="1.0" encoding="UTF-8"?>
<info><longdescription>Some blurb plenty of invalid chars like <<< && >>></longdescription></info>
What am I doing wrong?
Looks like the problem was my application server: I am running this with WebLogic 10.3.5 in development mode, which comes with a lot of common libraries pre-installed that in the default configuration take precedence over those deployed in the webapp WEB-INF/lib folder.
To fix this a weblogic specific application description is needed, just create a weblogic.xml file inside WEB-INF containing the prefer-web-inf-classes option. The file I used is this:
<?xml version='1.0' standalone='yes'?>
<weblogic-web-app>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
I still have no idea which library was the problem though, anyone knows feel free to edit this answer.
Please download Jaxb Extension:
This is Eclipselink open source extension for Jaxb.
Get jar file: eclipselink.jar copy into Project lib.
http://www.eclipse.org/eclipselink/downloads/
EclipseLink 2.4.1 Installer Zip (37 MB)
And see example at:
http://theopentutorials.com/tutorials/java/jaxb/jaxb-marshalling-and-unmarshalling-cdata-block-using-eclipselink-moxy/
Good look!.