Uber jar with ehcache breaks with Swagger - reflection

For a Dropwizard application, a Uber-jar is created using maven-shade-plugin. When I try to start it, the Bootstrap class loading done by swagger (dropwizard-swagger bundle) breaks trying to load the classes inside ehcache jar. These classes have a custom class loader, and are inside a folder in the jar with a different extension (.class_terracotta).
- Is there a way to tell Swagger/Reflections to use a Custom classloader so that it can resolve these classes?
- Is there a way to exclude the classes from the scanning, so that it does not attempt the loading?

Related

Mule 4 : Is there a way to refer Maven POM properties from a Mule Flow?

I want to refer the project name and version in the URL of the API. For example, my app is called sample-mule-project and has a version "v1". So my final URL should be like /sample-mule-project/v1/
Maven pom has these properties called name and version with which we can refer these values inside the pom file. Is there a way how we can refer these values inside the mule flow?
I tried using ${project.name} and ${project.version} but it did not work which I understand is because these are not defined inside properties file. So is there a way to achieve this?
That's because Maven properties do not exists anymore when the application is executed.
You can use some Maven plugins to replace values in a properties files, that can be used inside the application. For example the Maven Resources plugin. Be careful of not override properties inside other files, like the XML Mule configurations of the application.

Best place for other php.class in symfony2?

i have a php.class that handle gd-functions in my symfony2-project. Where i can find the best place for this classes?
Regards
Create a folder in src/. To autoload the classes that are in the folder you will create, use Composer Autoload feature (https://getcomposer.org/doc/04-schema.md#classmap) or autoload it in /app/ (https://github.com/symfony/symfony-standard/blob/2.7/app/autoload.php)
If your Class is also useable without an Symfony2 context you should not place it in Acme\Bundles\DemoBundle but rater under Acme\Components\ChangeThisToWhateverYourLibsNameIs. Then you can define an service in your bundle for this class to use this as an service in an Symfony context.
Why?
Because with this way you can reuse the library in that namespace in other frameworks two. You could maybe create a new composer package for it and add it as an dependency of your bundle.
As you see the Symfony core team does it the same way:
https://github.com/symfony/symfony/blob/2.7/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml
Add it to any of your bundles. You sure must have bundles created. Add a directory to your bundle. The directory can be named anything. I normally name it Services. Add namespace to your class. Lets say if your bundle name is AcmeDemoBundle and your directory name is Services, your namespace would be Acme\Bundles\DemoBundles\Services
You can then register this class as a service and access via DI.

External classes/jar in OSGi

My application supports running on many dbms and it requires user to configure dbms connection setting and also provide the jdbc jar file.
Now the application is to be packaged as OSGi bundle. There will be another main jar which lanches OSGi server and starts the application as bundle.
Can you please suggest how can I package the application as bundle and let user provide the jdbc jar file.
Will it require something like the main launcher jar specifying JDBC driver classes as FRAMEWORK_SYSTEMPACKAGES property?
Thanks in advance,
Aman
There are two ways of doing this:
1) Adding the driver.jar to the classpath of the main launcher and, like you say, expose its packages via the framework by specifying that property (or actually you can use the FRAMEWORK_SYSTEMPACKAGES_EXTRA property to just specify additional packages, instead of specifying all of them).
2) Manually wrapping the driver.jar as a bundle, or doing it dynamically at runtime. For example, you could try to wrap bundles that are copied to a certain folder (similar to what Apache Felix File Install does) by using Pax URL or some other tool that can create a bundle out of an ordinary jar file for you (see http://team.ops4j.org/wiki/display/paxurl/Pax+URL).

How to include resource bundles in ActionScript Modules using Flex 4.1?

In the simplest of Flex Projects, create an MXML Flex Module and then load it using the ModuleManager. No problem. Create an ActionScript class that extends Module and then configure your project to compile that into a Module. Load this new module instead. The project compiles, but crashes when running with the following error:
"Error: Could not find compiled resource bundle 'containers' for locale 'en_US'."
I believe the compiler is failing to compile the required class definitions into ActionScript only module, while it succeeds for the MXML module. I can see that my skeleton MXML module is slightly larger than my ActionScript module (66KB vs. 45KB).
How can I resolve this problem (if that is indeed the issue)?
A good approach in these sort of situations is to use -keep-generated-actionscript for two projects, one with the mxml approach, and one with the actionscript approach. You can then compare the code to see what might be missing from one project, but included in another.
Have you tried adding an explicit reference to [ResourceBundle("containers")] to your ActionScript project class? The mxmlc is different to the compc compiler in behaviour for many valid reasons.
I was having this same problem when compiling a library swc. I was able to fix it by adding the following section to the projects projectName-config.xml
<include-libraries append="true">
<library>${flexlib}/locale/{locale}/framework_rb.swc</library>
</include-libraries>
This forces the compiler to include the framework resource bundle for the specified locale.
for me the issue was finding out which project - in my case a library - and which class in this library caused this behavior (I needed to realize my last changes - no info from flashbuilder). Then applying the following attribute to the class:
[ResourceBundle("containers")]
public class IpChecker {
...
That did the trick.

Problem modulating action script project

I am refactoring a hugh action script solution in Flash builder (beta 2) using the flex 4 sdk.
The project does NOT use the mx framework.
What i want to have is:
A big 'MAIN' project
several small 'MODULE' projects. each 'MODULE' class refrences the 'MAIN' project as an External reference (doesnt compile into swf) - this is done by setting link type = external in the 'MODULE' project properties -> library path.
'MAIN' loads a 'MODULE' project on runtime using the 'loader' class.
the problem:
I recieve an error from the MODULE project:
VerifyError: Error #1014: Class [some class in MAIN] could not be found.
PLEASE HELP!
Check which application domain you are loading your module into. The app domain needs to be able to access the class you have externalised or you'll get that error.
It might just be a bug with the beta version of the sdk. It seems like the import of a class in a module created in another project doesn't force it's inclusion in the main swf.
try putting a dummy dependency in you main application class, like:
private var forcedImports:Array = [MyClass];
It fixed some of my problems before.

Resources