How to deploy ff4j server in AKS? - deployment

I have created ff4j server with name - "ff4j-feature-toggle-server" as a maven java project. Trying to deploy this on AKS. I get the below in my logs -
"no main manifest attribute, in ff4j-feature-toggle-server.jar"
I have checked my deployment files and the name is correct and the server runs perfectly in my local machine - but I am unable to deploy on AKS. Can't find anything online regarding ff4j aks deployment as well.
Am I missing something??

No error were mentioned to the ff4j team before regarding AKS deployments. ASK expect an executable JAR i guess.
You might get this error when Main-Class entry is missing in MANIFEST.MF file. You can put maven-jar-plugin plugin in pom.xml to fix it.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<mainClass>org.yourapp.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
source:https://java2blog.com/no-main-manifest-attribute/

Related

How to deploy ApplicationLifecycleListener

I created an ApplicationListener extends ApplicationLifecycleListener in a java project, packaged as a jar file, create ear file contains this jar file, try to deploy it in the weblogic server with the "install" button in weblogic admin console(screenshot), I got error. If I pack it as a war file, create a ear file contains this war file, with the same approach I can deploy it with no error, but it does not being called.
I have searched on the internet for a while, a lot of people was talking about adding this listener to a weblogic-application.xml, I do not have this file in my project, I tried to find this in the weblogic server folders also can not locate it, I am new to weblogic, no idea how should I make a ApplicationLifecycleListener work.
Where should I find this weblogic-application.xml file? Or where do I need to create this file? Do I have to create a J2EE or EJB project? Or a java project can do this.
If possible please give me some detailed steps about deploying an ApplicationLifecycleListener. (I am using Jdeveloper)
First what project I should be using to write this listener class, and after coding, how to I register it, what is the best way and how should I deploy it.
In a typical maven EAR project, you'd put it in /myapp-ear/src/main/application/META-INF/, and it would look a bit like this:
<weblogic-application>
<listener>
<listener-class>com.myapp.SomethingSomethingServiceListener</listener-class>
<listener-uri>myapp-lib.jar</listener-uri>
</listener>
<!-- add whatever other things you'd normally put into weblogic-application-->
</weblogic-application>
Then /myapp-lib/src/main/java would have your listener code.
I like to put this code inside /myapp-ear/pom.xml but that's up to you:
<build>
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<defaultLibBundleDir>APP-INF/lib</defaultLibBundleDir>
<modules>
<jarModule>
<groupId>com.myapp</groupId>
<artifactId>myapp-lib</artifactId>
<bundleDir>/</bundleDir>
</jarModule>
</modules>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<manifestEntries><!-- weblogic really wants to know this for hot deploys -->
<Weblogic-Application-Version>${project.version}</Weblogic-Application-Version>
</manifestEntries>
</archive>
<fileNameMapping>no-version</fileNameMapping>
</configuration>
</plugin>
</plugins>
</build>

Eclipse deploying unfiltered .WAR-Archive on Tomcat

i have the following problem: I want to use maven profiles and the maven-war-plugin for filtering my webapplication, so that it's just one click to deploy it either on the live- or on the development server.
When i build the .WAR-archive via Eclipse (Maven-Plugin) and then manually deploy it on the tomcat-server via the tomcat-manager-interface, my application works as expected. (all variables are replaced correctly inside the generated .WAR-archive)
But when i want to run the application using Eclipse's "Run on Server", an exception occurs:
[..] nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.security.web.authentication.logout.LogoutFilter]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: ${security.casEntryPoint.logoutSuccessUrl} isn't a valid redirect URL
This is the configuration of the maven profiles in my pom.xml:
<profiles>
<profile>
<id>prod</id>
<build>
<filters>
<filter>src/main/filters/dfnaaiAgreement-prod.properties</filter>
</filters>
</build>
</profile>
<profile>
<id>devLocal</id>
<build>
<filters>
<filter>src/main/filters/dfnaaiAgreement-devLocal.properties</filter>
</filters>
</build>
</profile>
This is an example entry for the *.properties file:
security.casEntryPoint.logoutSuccessUrl = https://example_entry/please_logmeout
This is one entry in the settings.xml that should be replaced by the value in the *.properties file:
<security:logout logout-url="/logout" logout-success-url="${security.casEntryPoint.logoutSuccessUrl}" />
and this is the configuration for the maven plugin (in the pom.xml), that is used for filtering the configuration files:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warName>dfnaaiAgreement</warName>
<webResources>
<resource>
<directory>${basedir}/src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</webResources>
</configuration>
This is my maven build configuration:
Maven-Build configuration (Sorry, not enough reputation to post images directly)
It seems like eclipse's "run on server" deploys the unfiltered application on the tomcat-server.
What am i doing wrong?
Update:
I followed this Link Run Maven webapp on server from Eclipse with properties injection from profile, but i'am still receiving the same Exception.
Here's the adjustment of my project's configuration: Active Maven Profiles
Update: Eclipse (Luna) deploys the webapplication to workspace/.metadata/.plugins/.org.eclipse.wst.server.core/tmp0/wtpwebapps/applicationName. The settings.xml that's deployed there still contains the unfiltered variables, whereas the generated .WAR-Archive (that is located at workspace/applicationName/target) has the correctly filtered settings.xml. How is this possible?
Thanks for your help!
Although it's not an optimal solution i found a workaround to fix my problem. Therefor i adjusted the project's deployment assembly settings in the way that the WEB-INF-Folder of the target-Folder will be taken for deployment.
You can do this by rightclicking your project and choose "Properties". Here's a screenshot of how i adjusted the settings:
Web_Deployment_Assembly.PNG

Project "MyProject" has higher compiler option than running Eclipse

I am trying to rebuild Hibernate configuration but i got Wrong Compiler Settings error, please find below screenshots of my App configuration and a of the error:
The problem was because Eclipse ran on a different JVM than the one specified in my project (I have two installed JDK on my machine), to resolve that i just modified the file eclipse.init in a way to ensure Eclipse will run the appropriate JVM.
This is what i added to eclipse.init (you need to use your exact path to javaw.exe):
-vm
C:\Program Files\Java\jdk1.6.0_45\bin\javaw.exe
Further informations regarding the eclipse.init file, could be found here.
It seems that you are using maven so you need to adjust it in the compile plugin it your POM
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
for more details check this example

War deployment to JBoss from maven

I am having a pom file with specific properties to deploy to jboss 7.10. I am running on localhost and default ports. So I am using the hard-deploy instead of deploy. The mojo plugin was always copying the war to \server\standalone\deploy\standalone\deployments\ROOT.war for which I made a workaround.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jboss-maven-plugin</artifactId>
<version>1.5.0</version>
<configuration>
<jbossHome>C:\work\jboss-as-7.1.0.Final</jbossHome>
<deploySubDir>..\..\..\standalone\deployments</deploySubDir>
<serverName>standalone</serverName>
<fileNames>
<fileName>target/ROOT.war</fileName>
</fileNames>
<unpack>true</unpack>
</configuration>
</plugin>
The hard-undeploy needs a different set of configuration than the hard-deploy goal. How can I do this?
Use appropriate maven plugin with AS7
http://docs.jboss.org/jbossas/7/plugins/maven/latest/

Tomcat 7 maven plugin additional context on tomcat7:run

When I run my web app inside eclipse using tomcat 7 maven plugin, I want an additional context to be deployed to tomcat. On the production enviroment this context is mapped to a directory outside tomcat dir using a context configuration
<Context path="/userimages" docBase="C:/test/userimages">
</Context>
And by this way is available in
http://wwww.myhost.com/userimages/test.jpg
How I achive the same on the development enviroment of the webapp (eclipse, tomcat7 maven plugin)?
In other words I want the contents of that folder to be accessible through
http://localhost:8080/userimages
or
http://localhost:8080/myapp/userimages
You should configure tomcat7-maven-plugin plugin.
Try this way:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<path>your_app_context_path</path>
<uriEncoding>utf-8</uriEncoding>
</configuration>
</plugin>
Then all your urls should start with http://wwww.myhost.com/your_app_context_path/...
More optional parameters for tomcat7:run goal can be found at apache tomcat maven plugin document
I found a workaround that doesn't do exactly what I originally wanted (publish another context using the tomcat maven plugin) but it solves my problem in a way. I add a folder "userimages" in the webapp folder of the application and this folder is used when developing. I prevent this folder from getting in the war and thus in the production server by using the "maven-war-plugin" with the following configuration in the pom.xml
<build>
....
<plugins>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<packagingExcludes>userimages/</packagingExcludes>
</configuration>
</plugin>
....
</plugins>
....
</build>
Check also here and here