Custom Tomcat Valve contained in web app WAR file - tomcat6

I'm looking to implement a custom Valve and configuring it using META-INF/context.xml.
At the moment though, when context.xml is parsed during deployment, Tomcat (6.0.32) dies with a ClassNotFoundException on my custom Valve implementation.
I'm under the impression that I'm running into a class loading context issue and I'm not 100% sure I understand it.
Is my class not found because it is located in the WEB-INF/classes file and the Context level class loader is unable to locate the class because of the hierarchy?
Thanks in advance.

You can not load Valves from inside the webapp class loader. If you look at http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html it shows the available class loaders. You must use one of the Bootstrap, System or Common classloaders because Valve definitions are processed BEFORE the individual webapp classloaders are created: the Context has to be processed before the webapp is available.
Package your Valve in a jar by itself and copy it into the $CATALINA_HOME/lib folder and you should be all set.

Related

Develop Salesforce Commerce Cloud Cartridge Loading Order

I would like to develop a Salesforce Commerce Cloud Cartridge.
My JS code needs to load before all other JS Code.
What are my possibilities to achieve that? is it even possible to determine when your plugin loads?
I read about the cartridge stack load order,
Base -> Plugin -> LINK -> Custom (default).
I cannot seem to understand, is it possible to develop a Plugin or LINK cartridge? what does it require of me?
In SFCC the cartridge path and the cartridge itself has no influence on the JS code that is delivered to the client. It only defines what files take precedence during code generation on the server-side.
If you want to make sure you plugin code runs first on the client side you would have to either write a wrapper that makes all other scripts wait or add your JS code as dependency to other scripts. I doubt however that you can provide this functionality simply through your cartridge. I think whoever uses the cartridge has to take care of that manually.

How can I build a Go app with a ReactJS GUI in a single binary?

I would like to develop a Go application with a ReactJS "GUI".
My point is to launch a single binary "app" that launch a server at "localhost:someport" serving a ReactJS app.
I would like my actions in the ReactApp to be taken into account in the Go-side app.
I can do a Websocket-based ReactJS-Go application but I'd like everything to be bundled into a single binary.
I've followed this : https://medium.com/#esslamben/serving-static-sites-with-go-55bfc1ae4495.
This tutorial helped me to serve static files (a React App) with a single file.
But, I don't know how to continue to satisfy my wishes.
The thing I would like to achieve is the behavior like the old "RethinkDB".
When you run "rethinkdb.exe" in command line, it notifies a administration panel is running on 8080 port.
Navigating through localhost:8080 enables to administrate the database with a web-based GUI.
Does someone have advice to help me to obtain such a behavior?
You cant make binary for your React code , it should be copied
Your react built code (I assume static ) and put it in a specific path
Use Go http FileServer handler to serve the app as static one.
This might work or may not , I am not sure what are the bindings which is necessary should alos be copied. (your node modules and additional libraries you use it in your package.json)
Put your *.js binary data inside an HTTP handler to serve the client.
Store your js file as an []byte inside your application.

Apache Camel File component base path

How do I manage to configure the File component of my Camel Context, so that all directory paths provided to its endpoints are prepended with some base path?
For example, if someone writes
file:input/customer12?include=.*\.csv
it will effectively be
file:/usr/local/share/app/exchange/input/customer12?include=.*\.csv
For example, I get the component during the Camel Context initialization like this:
FileComponent file = CAMELCONTEXT.getComponent("file", FileComponent.class);
What do I do next? createComponentConfiguration()?
addition: It's a standalone cli app which I want to be runnable from any directory
The easiest solution is start your app under folder /usr/local/share/app/exchange , but this is not an option as state in addition requirement
If you have a layer between your user input and your code, then you could inject the path. For example, Java DSL with RouteBuilder.
The last solution is override Camel's file component in component class before it create the actual endpoint.

How to deploy Custom Dataformat in camel

I am running Camel inside Karaf.
I have created a custom dataformat by implementing DataFormat interface.
Now I have my custom class.
In order to make it visible to my camel route inside karaf where to copy this class file?
Please provide guidance.
I'd just add it to my Camel application source code and deploy it with that bundle. If you need to reuse it across several bundles, then you could package it as a separate bundle and export/import it appropriately I suppose...

EntryPoint Classes & Modules in GWT

GWT code structure is really getting hard for me to follow :(.
As per my understandings,
Modules references Entry Point classes.
When a module is loaded entry point classes referenced on it get initiated, and onModuleLoad() of corresponding classes will get executed
HTML host pages need to include a nocache.js file (only if it needs to work with entry point classes)
If my understandings are correct,
In standard web development platforms like asp .net an aspx page refer to a servlet. Here mulitple html pages can refer to a single entry point class.Why?(and this is much complicated?)
When I can expect a module to load? If multiple modules & html pages are there, how we can assign modules to html pages, so that a particular module will load when user requests an html page?
I have an Async service call implemented at onModuleLoad(). And want to call this only for index.html page. But How can I identify the html page at onModuleLoad()?
Why Google proposes GWT for GAE app development?
I am newbie in GWT. I want to follow a good programmig structure for GAE app development. Corrections and suggestions are expecting...
Pls see this to understand how a GWT project is organized: https://developers.google.com/web-toolkit/doc/latest/DevGuideOrganizingProjects
(Bootstrap is also described there, how application loads from the html page)
I think the main thing is that everything compiles to one javascript file.
The app runs in a single page.
In .gwt.xml you define the entry-point of your app.
Also you specify what other modules you inherit.
This is very similar to java or .net applications where you specify what other packages you need. The modules are like libraries. For example if you needed to use JSON you would inherit the json module. Also I don't think to you are obliged to use GWT on the front

Resources