This time I have a problem with running my Web App project in Eclipse.
Whenever I'll commit my app to SVN, then build it and deploy using Jenkins to Tomcat container - the app runs fine, and the correct MANIFEST.MF is used.
But, when I want to debug it inside Eclipse (with Tomcat 8.5 container) - there is an deafult manifest file used instead of the one containing my custom properties from pom.xml.
I've defined few variables in pom.xml regarding the application name, version and so on. The manifest file is being generated in /target/generated-resources/m2e-wtp/webResources/META-INF/MANIFEST.MF. This file contain all of my custom properties.
But when I call
resources = getClass().getClassLoader()
.getResources("META-INF/MANIFEST.MF");
The path returned is: /META-INF/MANIFEST.MF. The file indeed exists, but is almost empty:
Manifest-Version: 1.0
Class-Path:
Here's my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- Exclude an unnecessary file generated by the GWT compiler. -->
<!-- <packagingExcludes>WEB-INF/classes/VAADIN/widgetsets/WEB-INF/**</packagingExcludes>-->
<manifest>
<addClasspath>true</addClasspath>
<addDefaultImplementationEntries>false</addDefaultImplementationEntries>
</manifest>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifestEntries>
<Specification-Title>${project.name}</Specification-Title>
<Specification-Version>${project.version}</Specification-Version>
<App-Version>${build.version}</App-Version>
<Build-Number>${build.number}</Build-Number>
<SVN-Revision>${rev.number}</SVN-Revision>
<Sys-Name>${sys.name}</Sys-Name>
<Sys-Full-Name>${sys.full.name}</Sys-Full-Name>
</manifestEntries>
</archive>
<!-- <packagingExcludes>WEB-INF/classes/META-INF/MANIFEST.MF</packagingExcludes> -->
</configuration>
</plugin>
I've tried almost every suggestion I've googled so far and nothing works :(
Please help!
Thank you in advance
Tom
Okay,
Finally I've found a solution. It turned out that I just need to simply copy a generated MANIFEST.MF file from the genrated wtp output folder to my project META-INF.
During building on Jenkins - the file is getting ovewritten by the generated one anyway so it seems that this makes no harm to project.
Related
How do you build an executable JAR file in Netbeans 12.6? I realize this question is asked frequently but none of the other solutions previously posted here work on the latest version of Netbeans. All I ever get is "no main manifest attribute". Amazing to me that such a simple thing does not just work out-of-the-box. Getting Netbeans set up has been harder to learn than Java itself!
When you set the project’s main class, you ensure that the main class is be designated in the manifest. To set the project’s main class:
Right-click the project’s node and choose Properties.
Select the Run category and enter projectname.className in the Main Class field.
Click OK to close the Project Properties dialog box.
https://netbeans.apache.org/kb/docs/java/javase-deploy.html
Here is what worked for me. For Maven, you need to update the POM.xml file. Netbeans does not work out of the box in version 12.6 like older versions. I'm sure they added more functionality but it no longer just works. It maybe similar for Gradle. Add this above ~ < /project> in your file. Change your class name to your's. (My class was called main).
<build>
<plugins>
<plugin>
<!-- Build an executable JAR -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.mypackage.MyClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
I cloned project from here. And I imported in eclipse as maven project and trying to build it using mvn clean install -DskipTests.
After deploying getting com.day.cq.commons- cannot resolve error in system console. For this I checked in depfinder there is already following dependency is present.
Please help me. I'm new in AEM.
Thank you.
I resolve above problem after importing following package in maven-bundle-plugin in pom.xml
<Import-Package>com.day.cq.commons;version=5.7.6;</Import-Package>
So, whole story will look like following:
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.0</version>
<extensions>true</extensions>
<inherited>true</inherited>
<configuration>
<obrRepository>NONE</obrRepository>
<instructions>
<Bundle-Category>social</Bundle-Category>
<Bundle-DocURL>
http://www.adobe.com
</Bundle-DocURL>
<Bundle-Vendor>Adobe Systems Inc.</Bundle-Vendor>
<Import-Package>com.day.cq.commons;version=5.7.6;</Import-Package>
</instructions>
</configuration>
I am getting the following error when I run my playN project.
"No file found for: /myproject/myproject.nocache.js"
Also I am getting only a black screen in the browser.
In the MyProjectHtml.java file I am giving the path as
"platform.assets().setPathPrefix("myproject/");"
How can I resolve this problem. I am not finding any file with the name "nocache".
Note: The comment in one of my previous question's answer will be useful: How to Run my playN game in production mode locally?
Thank you.
SOLVED: the resource folder under war was getting generated using eclipse compile only.I have created a source folder src/main/resources and moved all my resources package to it. Before it was under src/main/java. Now it works..! I can compile from terminal and run.
Are you running the project via Maven (mvn test -Ptest-html) or as GWT project (mvn gwt:run)?
The first case should work if your path is set correctly, but running it as a GWT project has always failed for me.
I also suggest doing a mvn clean install, and seeing which resources are contained within your .war file. Your .nocache.js file should be in there, if not, you probably have a bigger issue (incorrect project setup).
Update:
Seeing as you don't have the .nocache.js file in your war something is wrong with your Maven configuration. See if the following config has been added to your HTML pom in your plugins tags:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
Either way, your HTML version won't run until you see the .nocache.js in your war file. Double-check your Maven configuration with a new PlayN project, and see where there are differences.
I tried changing to the release version of gwt2.4 and run into a problem. I use multiple projects in my setup. I have a project with serverside code, one project with shared code, that can be used in different gwt projects and a gwt project binding everything together. I build everything with maven. i followed the instructions for annotationprocessing found here:
http://code.google.com/p/google-web-toolkit/wiki/RequestFactoryInterfaceValidation
when I compile my shared project, where the proxies and services are, the folder "generated-sources\apt\" with the DeobfuscatorBuilder.java is created. I have the sources of this project as dependency of my mainproject and try to run the validator as well, but the DeobfuscatorBuilder.java is not created here. Everything compiles but when I invoke a call to the requestfactory I get the error:
com.google.web.bindery.requestfactory.server.UnexpectedException: No RequestContext for operation ZwI9iqZS626uTt_TFwRtUwPYSOE=
I guess there is an mistake in my setup, but I could't find where ..
Does anybody know how to solve this problem?
Regards
arne
UPDATE:
I added this to my pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
<!-- <goal>build-classpath</goal> -->
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.myproject.core</groupId>
<artifactId>shared</artifactId>
<version>${shared.version}</version>
<classifier>sources</classifier>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/com.myproject.shared</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
This unpacks the sources of my dependencies and puts them into my target folder.
Then I added:
<configuration>
<sourceDirectory>target/com.fileee.shared</sourceDirectory>
</configuration>
to my processor-plugin.
This way it is not necessary to have all the projects in the workspace and it should work with a continous integration system. Wouldn't have figured that out without Andys reply though :)
I had the same issue and spent hours scouring the web for an answer without any luck. If I add the processor plugin to the shared project, it generates the DeobfuscatorBuilder class, but I get the same No RequestContext exception as you. If I just have the processsor plugin on the GWT war project, the builder isn't generated at all.
With a fair amount of trial and error I found adding the source directory from the shared project into the processor plugin configuration on the war project worked...
http://code.google.com/p/android-shuffle/source/browse/shuffle-app-engine/pom.xml#269
It's a bit dirty, but it does the trick. If there's an official method that doesn't require cross project hackery I'd be more than welcome to switch, but I haven't seen anything suggested yet.
Cheers
Andy
I have a maven project and I'd like to create a distribution of it with the dependencies. I've tried the maven-assembly-plugin and built the jar with dependencies, but that unpacked all of the jars and repackaged them all into a big, single jar. What I'd like is something like my jar file and a lib folder that has all of the dependencies. Then when I run it, I could run "java -cp lib/* my.package.MainClass".
What's the best way to go about doing this with maven? Or the recommended way to deploy?
thanks,
Jeff
I have used the Maven assembly just for that in my project.
First enable your plugin in your POM and call your assembly config :
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<!--I recommend 2.1 as later versions have a bug that may
Duplicate files in your archive
-->
<version>2.1</version>
<!--Executes the packaging along with the mvn package phase
-->
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptors>
<!--Relative path to your descriptor -->
<descriptor>src/main/assembly/package.xml
</descriptor>
</descriptors>
</configuration>
</plugin>
Then in your descriptor you can decide how you want your layout to be before you package the whole thing
<assembly>
<!-- this will create an extra resource project-1.1.1-package.zip, you can
choose jar as well in the format-->
<id>package</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<!-- Insert here extra files as configs or, batch files, resources, docs etc-->
<fileSets>
<fileSet>
<directory>src/main/assembly/files</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**/conf/*.*</include>
<include>**/doc/*.*</include>
</includes>
</fileSet>
<!-- I like to integrate the jre as well... simplifies my deployement -->
<fileSet>
<directory>target/jre</directory>
<outputDirectory>/jre</outputDirectory>
</fileSet>
</fileSets>
<!-- This will scrub your dependencies and add them to your lib folder, I excluded
Test stuff as it is not needed, could have declared the resource as a test
only phase as well would not have had to exclude it here
-->
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<excludes>
<exclude>junit:junit</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
This will create a zip file with the layout you have specified in your output directory config, package the whole thing as a zip file (you can choose zip, jar, war ...) and deploy it in my repository with the rest.
I skipped bits and pieces to make it simpler but my package expands to include batch files, dlls, config, doc and the JRE so everything needed is in the same zip... all is needed to run the thing is extract and click start.bat !
I could also probably make it in to a jar properly formatted with METADATA and just double click the jar itself to start it all, I did not need or have time to toy around this option but you may try it as well.
Beware of versions above 2.1 of the assembly plugin, it will create duplicate entries if your directives enable it to find the same file in different locations, this will give you a lib folder with the same jars repeating twice. not very dangerous as unzipping will collapse them but still annoying to have the unzip ask you if you want to overwrite files. Plus the fact that you do not know which won if somehow they turned out to be different in content.
Maven is great but I find that it is sometimes frustrating to get it working, Plus documentation can sometimes be hard to find and use. However, used appropriately it will save you tons of time.
good luck
See:
http://maven.apache.org/shared/maven-archiver/index.html
You should be able to use the maven-jar plugin to package up an archive, specify the main class to execute along with the classpath. It can generate a manifest file for you for your project.
http://maven.apache.org/shared/maven-archiver/examples/classpath.html#Prefix