cannot run xtext without eclipse (as jar) - xtext

I'm trying to use Xtext without eclipse as described in this post: http://zarnekow.blogspot.de/2010/06/how-to-deploy-xtext-standalone.html. Unfortunately, I can't get the created .jar file to run.
I have created a run configuration. It uses a Wrapper class as its Main class, which calls the Mwe2Launcher.main method. (Using Mwe2Launcher as the main class didn't work for me).
This, as well as exporting the project to a runnable jar file, so far worked well. However, now I cannot get the jar file to run.
I use
java -jar exported.jar org.example.mydsl.GenerateMydsl
with org.example.mydsl.GenerateMydsl.mwe2 being the workflow file that I usually run as MWE2 Workflow when running Xtext in Eclipse (successfully, btw).
But I receive the following Errors within my output:
7098 ERROR Generator - java.io.FileNotFoundException: ..\org.example.mydsl\META-INF\MANIFEST.MF (The system cannot find the path)
org.eclipse.emf.common.util.WrappedException: java.io.FileNotFoundException: ..\org.example.mydsl\META-INF\MANIFEST.MF (The system cannot find the path)
at org.eclipse.xtext.generator.Generator.mergeManifest(Generator.java:418)
at org.eclipse.xtext.generator.Generator.generateManifestRt(Generator.java:385)
at org.eclipse.xtext.generator.Generator.invokeInternal(Generator.java:137)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:35)
at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:102)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:79)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:71)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:76)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
at org.example.domainmodel.Wrapper.main(Wrapper.java:11)
Caused by: java.io.FileNotFoundException: ..\org.example.mydsl\META-INF\MANIFEST.MF (The system cannot find the path)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at org.eclipse.xtext.generator.Generator.mergeManifest(Generator.java:404)
... 13 more
7098 INFO Workflow - Done.
It's looking for the manifest file in \org.example.mydsl\META-INF\MANIFEST.MF. However, in the jar, the META-INF folder is located directly in the root.
Does anybody have an idea about what I might be doing wrong or what else I could try?
Would be grateful for help.

Related

Log4j2 not loading log4j2.xml

I have a problem concerning log4j2 which does not load the log4j2.xml configuration file in a project.
The project is bundled into an uber jar file. When running the application using java -jar jarfile.jar the application starts but log4j prints the following error to the console:
ERROR StatusLogger No log4j2 configuration file found. Using default
configuration: logging only errors to the console.
I checked the jar and it definitely contains a log4j2.xml file in the root location.
Because I could not figure out why this does not work I debugged to log4j2 bootstrap code. I found out that log4j never tries to read the log4j2.xml. This should happen in org.apache.logging.log4j.core.config.ConfigurationFactory.Factory#getConfiguration.
Unfortunately the list of factories used in this method is empty thus the method always returns null.
Any ideas on this?
If you want to check this clone https://github.com/cryptomator/cryptomator, cd to the main directory in the cloned repo and run mvn clean install -DskipTests -P uber-jar afterwards you will find the jar file in question under main/uber-jar/target.
I suspect this is the same issue as Log4j2 configuration not found when running standalone application builded by shade plugin since it sounds like you are building an uber jar.
I have a similar issue, but not using shade.
I have a jar file, with dependencies in /lib
I have a log4j2.xml file in the same location as the main jar file.
I can (obviously) run the jar file by calling:
java -Dlog4j2.configurationFile=.\log4j2.xml -jar myjar.jar
However, in Windows, it's possible simply to double-click the jar file to load it. Everything loads and works, except that it doesn't find the log4j2.xml file - so no logfile is written.
What I would like to be able to do is have a simple jar file I can hand to someone and have it run on their machine, with the ability to configure logging in the event they run into issues.
EDIT:
To do that, you need to amend your code thus:
public class MyClass
{
static
{
System.setProperty("log4j.configurationFile", "log4j2.xml");
}
private final static Logger LOG = LogManager.getLogger();
//OTHER STUFF HERE
}
Thanks to Load Log4j2 configuration file programmatically for the answer.

Exception thrown when connecting to website during Portfolio Manager demo

I have followed the documentation to install DataStax Enterprise and run the Portfolio Manager demo for both Ubuntu Server and MacOSX. For both operating systems, when i run dse-demos/portfolio-manager/website/start and then navigate to the given url in a browser, in my terminal window I can see the exception listed at the bottom of my message. No data shows up in the browser.
nodetool status and opscenter both show that my node is working. I am using
jdk1.7.0_51.jdk from Oracle, DS 4.0.1 and cassandra 2.0.5.24.
I assume I am missing something from my classpath or a necessary .jar is not installed. I cannot find other instances of this on your support forums, and I am unsure what I need to do to fix the issue. Do you know what is causing this exception?
Error for /portfolio/service
java.lang.NoClassDefFoundError: com/thinkaurelius/thrift/util/TBinaryProtocol$Factory
at com.datastax.bdp.util.CassandraProxyClient.getConnection(CassandraProxyClient.java:668)
at com.datastax.bdp.util.CassandraProxyClient.createConnection(CassandraProxyClient.java:319)
at com.datastax.bdp.util.CassandraProxyClient.initialize(CassandraProxyClient.java:396)
at com.datastax.bdp.util.CassandraProxyClient.(CassandraProxyClient.java:376)
at com.datastax.bdp.util.CassandraProxyClient.newProxyConnection(CassandraProxyClient.java:259)
at com.datastax.bdp.util.CassandraProxyClient.newProxyConnection(CassandraProxyClient.java:306)
at com.datastax.demo.portfolio.controller.PortfolioMgrHandler.getClient(PortfolioMgrHandler.java:204)
at com.datastax.demo.portfolio.controller.PortfolioMgrHandler.get_portfolios(PortfolioMgrHandler.java:73)
at com.datastax.demo.portfolio.PortfolioMgr$Processor$get_portfolios.getResult(PortfolioMgr.java:177)
at com.datastax.demo.portfolio.PortfolioMgr$Processor$get_portfolios.getResult(PortfolioMgr.java:162)
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
at org.apache.thrift.server.TServlet.doPost(TServlet.java:83)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139)
at org.mortbay.jetty.Server.handle(Server.java:285)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:502)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:835)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:641)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:208)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:378)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:226)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)
Caused by: java.lang.ClassNotFoundException: com.thinkaurelius.thrift.util.TBinaryProtocol$Factory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:375)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:337)
Unfortunately this is a bug with the packaging of the Portfolio demo war file. The good news is that it will be fixed in the 4.0.2 DSE release and that there is a workaround. That workaround is to add a missing jar to the demo war, which you can do with a couple of shell commands.
First, you need to locate the jar that should be included but isn't. This file is named thrift-server-0.3.3.jar and is included along with the other Cassandra libraries in a DSE installation. If you're running DSE from a tarball, you can find it in the resources/cassandra/lib directory. If you installed DSE from the .deb or.rpm packages, it's located in /usr/share/dse/cassandra/lib. Next, you need to create the correct directory structure so that when you added to the war file the jar has has the right path.
mkdir -p /tmp/WEB-INF/lib
cp thrift-server-0.3.3.jar /tmp/WEB-INF/lib/
Finally, you need to add the jar to the Portfolio demo war. In a tarball installation this is demos/portfolio_manager/website/webapps/portfolio.war and in package installs it is found in /usr/share/dse-demos/portfolio_manager/website/webapps/portfolio.war. The command to run to update the war is (using the tarball location here):
jar uf demos/portfolio_manager/website/webapps/portfolio.war -C /tmp WEB-INF/lib
(note the space between /tmp & WEB-INF)
You'll need to have the jar executable on your path, or use its full path.
After updating the war file and restarting the webserver, you should find that the errors disappear and you can open the page in a browser.

Sling webapp installation deploy error

I'm trying to run sling framework.
After building it from sources I have org.apache.sling.launchpad-7-SNAPSHOT.war file.
When I'm deploying it in tomcat7 I'm getting
SEVERE: sling: Failed installing jndi:/localhost/sling/WEB-INF/resources/org.apache.sling.launchpad.base.jar
java.io.FileNotFoundException: /var/lib/tomcat7/sling/_sling /Loader_tmp_1397075933316org.apache.sling.launchpad.base.jar (Permission denied)
at java.io.FileOutputStream.open(Native Method)
Have you any suggestions how to overcome this problem?
The Loader_tmp_ pattern in the problematic file makes me think this happens in the Sling Loader class when it tries to create a temporary file there. I'd check whether the tomcat process has read/write access to the /var/lib/tomcat7/sling folder.

how to compile java files classnotfoundexception

I am having a java project having the directory structure as
java->applet and a few .java files
the applet folder further contains two folders and some .java files
I need to develop a jar file out of this project
I did so by writing the command line
jar cvfm myfile.jar *.java
(obviously by moving into corresponding directory)
when I checked by extracting the file(it was zipped as a Nokia application installer file)
it showed me only the classes in the applet folder not the folders in it
moreover i needed to use this jar file in a jquery plugin where i had written
var dasherApplet = $('applet');
dasherApplet.attr({
'height':'100%',
'width':'100%',
'archive':farfalla_path+'plugins/dasher/jardasher.jar',
'code':'JDasherApplet.java'
});
but it showed me the class not found exception
for this I checked the previous versions of the java applet; there the java files were replaced by .class files so i tried compiling a java file into .class by using the command line
C:/>javac filename.java
still all in vain this time it showed me
"cannot find symbol" error
what was interesting was that the errors generated were imitating the java files present in the same folder. I navigated to the directory where the file was stored still the same error
when i tried to simply run it by using
java filename.java
error was main class not found:JApplet.java
Please help me develop this applet
Firstly you need to compile all the jar files before running.
Secondly , you CANNOT run Applets using java filename.java .
As this link explains http://download.oracle.com/javase/tutorial/deployment/jar/build.html ,
jar cvf TicTacToe.jar TicTacToe.class audio images
Here audio and images are folders , so that is how you add folders to jar.
Also .jar files are not Nokia Application Installer files . Nokia simply associates them for installing apps (that is J2ME)

Grails - trying to deploy a nojars application into glassfish 3.0.1

Because of memory constraint i am trying to build a grails app with smaller memory footprint. I build the war with this argument "--nojars". I created a war file without all the jar and when i deploy within the glassfish i encounter this error
Exception while loading the app : java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.web.util.Log4jConfigListener
It seems like the application fail to find where is the jar file.
I had already indicates the path to the library before deploying the application in glassfish.
did i miss out somethinng?
It is commonly recommended to use GlassFish's Common Classloader. That means putting the shared JARS into the $domain-dir/lib folder (but not into a subfolder of that).
You're probably trying to use the Application Classloader with the asadmin deploy --libraries command. This is more complicated and error-prone. If you don't need different versions of the same JARs with different web applications, you should definitely go for the Common Classloader as specified above.
Also see The Classloader Hierarchy for a reference.
EDIT Updated as per the questioner's comment:
The domain/domain1/lib folder definitely works (I've tested that). To validate that, put log4j.jar into that folder and add a test.jsp to domain1/applications/$applicationName, that just contains:
<% out.println(
org.apache.log4j.Logger.getLogger(this.getClass())); %>
If that works but your other code does not, there may be another point to consider: Are you using Log4J's Logger.getLogger(..) or Apache Commons' LogFactory.getInstance(..) in your code?
See the article Taxonomy of class loader problems encountered when using Jakarta Commons Logging for related issues. - I'd also like to advise you to post your complete stacktrace.

Resources