My Java service loads a jar file using JarClassLoader and created instance using JclObjectFactory.
1.Once the service is up and once the jar is loaded, will the jar just loaded be cached by JVM
2.Will the continuous run of the service cause memory leak issues loading the same jar again and again.?
Please clarify.
Related
I am trying to run a dotnetcore Console application in a ServiceFabric GuestExecutable Container. While I was adding this GuestExecutable service to my SF application, I cofigured as follows
Code Package Folder -> ..repos\NewDllGuestSF\CoreConsole\bin\Debug\netcoreapp2.0
Program -> CoreConsole.dll
Working Folder -> CodePackage
Here, I know I am trying to host this .dll file as my executable for the GuestExecutable service. This is what I am trying to do but could not somehow. When I tried the same with the treditional .NetFramework app and with an .exe executable, I am able to run it successfully on SF cluster. But I need to do is with dotnetcore application and of course with a dll executable.
So far I have tried is -
I can generate a dll as well as an exe while building my dotnetcore console application and use the generated .exe file in GuestExecutable. But here, I have to configure my console app to target multiple Frameworks as "netcoreapp2.0;net461", that is something I can not do for some reasons.
When I run my dotnetcore Console app with a dll executable in SF cluster, I faced the following error
Here if we see, the GuestExecutable service remains in healthy state but the application doesn't.
Can anyone please help me out on this, all I want to do is to host a .dll file as entry point in a GuestExecutable SF service.
As far as I understand you need to configure CodePackage in ServiceManifest.xml to run your .dll using external executable.
Here is the example how this could be done (please pay attention to IsExternalExecutable="true" attribute):
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost IsExternalExecutable="true">
<!-- We are using dotnet cli to launch our Service.dll -->
<Program>dotnet</Program>
<Arguments>Service.dll</Arguments>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</EntryPoint>
</CodePackage>
Hope it helps.
What steps are required to make a executable war without unpacking the war. ( Similar to the way spring boot does). Basically want to wrap Embedded Tomcat into existing war and make it execurable.
Env: Spring mvc, Java 7, Webapp with web.xml
So far I have done following research:
How Spring boot creates Embedded container in TomcatEmbeddedServletContainerFactory, but all those WebApploader stuff I'm not able to understsnd.
Successfull in packaging a executable war just using spring boot maven plugin but not able to run without unpacking it.
Tomcat api class doesn't read app from war directly.
Have successfully tested embedded tomcat by extracting it in a particular location and calling addWebapp method.
I do not want to create a big fat jar using shade plugin.
Do not want to specify path like src/main as indicated on many examples on the internet.
Upgrading the app to spring boot web is not possible due to time and other dependencies.
Suppose when I make a java spring boot application, it needs jars .
But when I deploy my app to cloud foundry will all the jars get build with my app and then go to cloud foundry or cloud foundry provides the jars dependency by seeing pom etc.
I have seen build folder but the jars are not there so how does it work.
I am new to cloud foundry so if someone can clear my doubt.
For most application types and build packs, when you push an application to Cloud Foundry you are pushing source code, and, if necessary, that source codes gets compiled during the staging process by the build pack. For example, with the Golang build pack you push your Go source code and it's compiled in staging and then run.
The two exceptions to this rule are the Java build pack and the binary build pack. These two build packs assume that you are pushing compiled bits and do not compile anything for you.
In the case of Java, this means that you're going to run Maven, Gradle or some other build system locally or on your CI system to produce a deployable artifact. This could be a WAR file or a JAR file, or a few other things (see "Standard Containers" on the Java build pack docs for other supported formats). Regardless of the format, it needs to be a complete and deployable unit, so it will need to include all dependent libraries.
As a side note, the cf cli has a nice feature that helps to speed up the cf push process and save bandwidth. It matches any files being uploaded and over 65k in size (default, operators can change this) to files cached on the Cloud Controller. If a local file already exists in the cache, it is not uploaded again. This works great for dependent JAR files which don't often change between pushes.
Spring Boot apps are typically packaged as "fat jars" using the Spring Boot maven or gradle plugin. The application code and all dependent jars are packaged into a single jar file.
Cloud Foundry will not download dependent jars when a Java application is deployed. It is the app's responsibility to bring all dependencies with it.
When we package resources in META-INF/resources/webjars/ folder inside a .jar it shows up http://localhost:port/context/webjars/.
How does this work? Is it part of servlet3 specification? Is there some way to control this behaviour? For the exact same binary sometimes the webjars folder isn't made available by Jetty and we're trying to investigate why.
What you are referring to are Servlet 3.0+ jar bundled web accessible resources.
https://blogs.oracle.com/alexismp/entry/web_inf_lib_jar_meta
https://alexismp.wordpress.com/2010/04/28/web-inflib-jarmeta-infresources/
Aka: WEB-INF/{\*.jar}!/META-INF/resources/
For a Jetty specific viewpoint...
Starting in Jetty 8+, on deployment, these are unpacked into the WebApp's temp directory and referenced internally for access via the ServletContext for that WebApp.
I am new to deployment and development of web applications.
Suppose I create three jar files and deploy them on a Tomcat server. I use maven to install the jar file and to deploy.
How is it possible to call a method in another jar file?
For example:
I developed a simple application in mytwitter.jar.
Then, I create myapp.jar, where one of the classes needs to call a method in mytwitter.jar.
Do I first deploy mytwitter.jar to the server and myapp.jar later?
You package all of the JARs you need (yours and 3rd party alike) into a WAR file which is what gets deployed to the Tomcat server. So in your maven config you likely already have dependencies configured for things like the twitter API and other packages. Just add your own JARs in there as well and then your code has access to it like anything else.