I have a Spring Boot application in which I renamed package where starting class is in. Application runs without any problem when launching from IDE (Spring Tools Suite) but when I build it with maven and run from command line with
java -jar <application_name.jar>
It says that class in old_package cannot be found. Things I've tried so far:
Clean project
Delete metadata from workspace
Copy project somewhere else and import it from there
Deleting Run Configuration and creating new one with main class in new package.
I also unzipped jar located in target folder and checked its manifest file and Start-Class param is set to old package.
You didn't update your pom.xml, and it contains references written in the form <old_package>.MyClass, whereas this should be <new_package>.MyClass. Your IDE (I'm not an expert with STS though) uses its own rules for compilation, so your program can run in it.
Related
I have the source code of a "util" maven project multiple times on my PC. In one directory I added a function to a class and called mvn clean install to make the new jar available in other projects.
In my main project I include the "util" dependency and can see in the NetBeans Project-tree->Dependencies, that the included jar file contains my changes. However, NetBeans throws an compile error that the new function cannot be found. If I open the imported file (Crtl+click import link), NetBeans opens a source file of a wrong (old) directory.
How do I fix this behavior?
Edit: I deleted the NetBeans Cache without success...
Edit2: I pulled the current version into the "old" directory and NetBeans compiles. Somehow the "jar" is ignored and for-what-reason this directory seams to be the reference...
I created a java project using sbt. While I was trying to use an Immutable class using #Value.Immutable annotation I noticed that generated-source folder is not created. Instead, I see the structure :
I also updated Build, Execution and Deployment section, ran sbt clean then sbt compile. I still don't see the generated-sources folder.
Any naive mistake I am making?
Should scala target directory even be created because its a java play framework project?
My in tension is to create a plugin at at the run time using java code.First a created executable jar using the java.util.jar.JarOutputStream and used javax.tools.JavaCompiler for compiling the classes. And I was able to execute the jar from command line properly.
Then I tried to create a pluign by including the plugin.xml file in the jar package and compiled the classes by using the above packages and plugin is created with out any errors.
But I was using an extension point for the plugin and it is not detecting while I am putting my plugin in the eclipse product.
Then I exported it by using eclispe export option and it is working properly for me. I unzipped both the jar created programtically and by using eclispe and the contents are same.
How can I solve this issue?
I'm trying to build web Service using maven and eclipse. Here is steps I followed.
Generated mvn folder struture using comman prompt
mvn archetype:generate - DarchetypeArtifactId=maven-archetype-webapp
Converted the mvn project into eclipse.
mvn eclipse:eclipse -Dwtpversion=2.0
Imported the project into my workspace.
Changed the project facets such as java version, servlet version, added cxf and jaxb feature and server runtime.
Copied the WSDL to Resources folder.
Since I do not want to add dependencies(as somebody else would be doing this job for me). I added spring and CXF lib into build path. and also to deployment assembly.
Generated the jaxb classes and operations from wsdl. Here all the java classes created instead of going to src/main/java to went to src/main/resources.
I run the app on tomcat. web.xml is invoked from that cxf framework got invoked and also spring bean creation got invoked. but while creating the bean for the webservice class it threw Class not found error.
When I opened up the war I could notice that while packaging instead of placeing the class files, the eclipse placed java file as it is in the war file.
Could some one help me in fixing this problem. Not sure how to configure eclipse to compile and place .class files in the war instead of .java filee.
Figured out the problem, while importing the file eclipse is adding command, exclude all the java files from src/main/resources in srource tab of java build path On removing it worked fine
I have a Java project that utilizes Jython to interface with a Python module. With my configuration, the program runs fine, however, when I export the project to a JAR file, I get the following error:
Jar export finished with problems. See details for additional information.
Fat Jar Export: Could not find class-path entry for 'C:Projects/this_project/src/com/company/python/'
When browsing through the generated JAR file with an archive manager, the python module is in fact inside of the JAR, but when I check the manifest, only "." is in the classpath. I can overlook this issue by manually dropping the module into the JAR file after creation, but since the main point of this project is automation, I'd rather be able to configure Eclipse to generate properly configured JAR automatically. Any ideas?
*NOTE*I obviously cannot run the program successfully when I do this, but removing the Python source folder from the classpath in "Run Configurations..." makes the error go away.
Figured it out, had to add the source folder with the Python module in it as a class folder in the Build Path project properties. Not sure if this next part is necessary or not, but since the module is not compiled, I added the folder again as "Attached Source" after adding the class folder.
Have a look at the maven-jython-compile-plugin and its demo project at http://mavenjython.sourceforge.net/ . It allows bundling jython with dependencies into a standalone jar.