Ebean does not find Entities after creating JAR - java

The problem is that in Eclipse-IDE every test with Ebean related methods works fine, but when you compile a jar-File to use it e.g. on a Homepage, or on command prompt, i only get this
Jul 10, 2012 4:25:48 PM com.avaje.ebeaninternal.server.util.ClassPathSearch find
Classes
Warnung: No Entities found in ClassPath using ClassPathReader [com.avaje.ebeanin
ternal.server.util.DefaultClassPathReader#6c08bae7] Classpath Searched[[file:/C:
/xampp/htdocs/webp3/jars/DPG.jar]]
Jul 10, 2012 4:25:48 PM com.avaje.ebeaninternal.server.core.BootupClassPathSearc
h search
Information: Classpath search hits in jars[] pkgs[] searchTime[27]
Jul 10, 2012 4:25:48 PM com.avaje.ebeaninternal.server.lib.sql.DataSourcePool in
itialise
Information: DataSourcePool [mysql] autoCommit[false] transIsolation[READ_COMMIT
TED] min[1] max[25]
Jul 10, 2012 4:25:48 PM com.avaje.ebeaninternal.server.core.DefaultServerFactory
setDatabasePlatform
Information: DatabasePlatform name:mysql platform:mysql
Jul 10, 2012 4:25:48 PM com.avaje.ebeaninternal.server.subclass.SubClassManager$
1 run
Information: SubClassFactory parent ClassLoader [sun.misc.Launcher$AppClassLoade
r]
Jul 10, 2012 4:25:48 PM com.avaje.ebeaninternal.server.deploy.BeanDescriptorMana
ger logStatus
Information: Entities enhanced[0] subclassed[0]
Exception in thread "main" javax.persistence.PersistenceException: com.dpu.entit
ies.Department is NOT an Entity Bean registered with this server?
at com.avaje.ebeaninternal.server.core.DefaultServer.createQuery(Default
Server.java:1008)
at com.avaje.ebeaninternal.server.core.DefaultServer.createQuery(Default
Server.java:965)
at com.avaje.ebeaninternal.server.core.DefaultServer.find(DefaultServer.
java:1001)
at com.avaje.ebean.Ebean.find(Ebean.java:1143)
at com.dpu.data.Datagenerator.generateData(Datagenerator.java:26)
at com.dpu.main.MainGenerator.main(MainGenerator.java:23)
I tried many "solutions" on google like editing the Classpath, but everything seems to be fine regarding on the log.
My JAR-Manifest contains this:
Manifest-Version: 1.0
Main-Class: com.dpu.main.MainGenerator
Class-Path: .
Does someone know how to solve this silly problem? I tried everything this day and it's just annoying

Alternatively to user1537597's answer you can add
# specify jars to search for entity beans
ebean.search.jars=myJarFile.jar
to the ebean.properties file, if you don't use the programmatic configuration.

You can also add the following to ebean.properties
ebean.packages=com.packagename

Same here.
The only way is to extract the jar and run the java main class. You need to put the ebean.properties file in the root of your project too.
e.g.:
jar xf project.jar
cp /my_project_root/ebean.properties project
cd project
java Project

not it depends on the fact that you need to specify in the ebean.properties to look for entities in the jar. I'm looking how to do it from the property file. Now I only found with the programmatic configuration.
config.addJar("nameFile.jar")

I managed to solve this by using a programmatic configuration and adding every entity class manually like this:
serverConfig.addClass(Entity.class);
The advantage of this approach compared to ebean.search.jars=yourJar.jar is that if the jar file name changes, it will still work.

Related

Delta XML- Dita compare getting Caught com.deltaxml.dita.FilterProcessingException

I am using deltaxml for some time and it is working fine. But for a specific dita topics , I am getting these warnings in the logs:
WARNING: Caught com.deltaxml.dita.FilterProcessingException: Exception thrown when attempting to run the ‘input-a/9-dxp-9-cals-table-checker.xsl’ step (source: ‘/dita-xsl/cals-tables/cals-table-checker.xsl’) whilst performing DCE[BEINGPROCESSED: file:/home/nxf36037/crrbcompareissue/trydirecttmp5/a-0-file-/regs/d ipflexcan3syn.dita, file:/home/nxf36037/crrbcompareissue/trydirecttmp5/b-0-file-/regs/d ipflexcan3syn.dita.bak, file:/home/nxf36037/crrbcompareissue/trydirecttmp5/b-0-file-/regs/d ipflexcan3syn.dita]
Feb 09, 2018 2:37:55 PM com.deltaxml.dita.ditabb ditaa
WARNING: Cannot find ids within file:/home/nxf36037/crrbcompareissue/trydirecttmp5/b-0-file-/regs/d ipflexcan3syn.dita Cause: java.io.FileNotFoundException: /home/nxf36037/crrbcompareissue/trydirecttmp5/b-0-file-/regs/dipfl excan3syn.dita (No such file or directory)
Feb 09, 2018 2:37:55 PM com.deltaxml.dita.ditaq ditaa
WARNING: Cannot prepare topics for comparison. Cause: com.deltaxml.util.href.ditab: Cannot construct target (concerning hrefs file:/home/nxf36037/crrbcompareissue/trydirecttmp5/b-0-file-/regs/d ipflexcan3syn.dita, file:/home/nxf36037/crrbcompareissue/trydirecttmp5/b-0-file-/regs/d ipflexcan3syn.dita.dxml-p1)
Feb 09, 2018 2:38:02 PM com.deltaxml.dita.ditaq ditaa
WARNING: Skipping topicref /home/nxf36037/crrbcompareissue/trydirecttmp5/b-0-file-/regs/dipfl excan3syn.dita. Cause: Cannot determine whether file:/home/nxf36037/crrbcompareissue/trydirecttmp5/b-0-file-/regs/d ipflexcan3syn.dita contains change.
I am not able to find the cause of this issue, I have tried almost all the arguments which I felt could be the cause.
The command line I am using is:
java -jar /pkg/deltaxml-dita-/2017.09.21/lib/deltaxml-dita.jar compare mts B1518165232953/dipflexcan3syn/specsource/maps/dipflexcan3synbg .ditamap B1518165232953/dipflexcan3syn/specsource/maps/dipflexcan3syn_bg .ditamap output-format=dita-markup map-result-structure=map-pair map-result-origin=B trydirecttmp5
I have also checked the dita files, they gets validated and there are no errors. Could you please help here?
The schematron code at: https://github.com/nigelwhitaker/cals-table-schematron can be used to detect and report, in a fairly user-friendly manner, table validation issues, either inside an editor or using the schematron skeleton.
As discussed with Mohit over in https://github.com/nigelwhitaker/cals-table-schematron/issues/4 it does however depend on XSLT 2.0 or 3.0 features and therefore is not suitable for all schematron systems.

Error occurs when encrypting text in JTextField [duplicate]

I am creating a swing based application in Java which uses some encryption technique. But
javax.crypto.KeyGenerator.getInstance("AES", "BC") gives exception:
java.security.NoSuchProviderException: JCE cannot authenticate the provider BC
at javax.crypto.SunJCE_b.a(DashoA13*..)
at javax.crypto.KeyGenerator.getInstance(DashoA13*..)
So what is the problem?
edit jre\lib\security\java.security
add security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider
copy bc*.jar to jre\lib\ext
To expand on the comment from GregS, all JCE provider JARs must be signed before they will be trusted by your Java runtime.
BouncyCastle dutifully supplies signed JARs that will work without a problem. However, if you extract class files from this JAR, or recompile the source, it will remove the signature and cause Java to reject the code.
See this related SO question: How to sign a custom JCE security provider
For those finding this issue but actually using SpongyCastle, it might be interesting to know that on Android there is no such signature test and for your tests you can use SpongyCastle via the openJDK-8 as that doesn't care about signatures neither.
For reference, with SpongyCastle the error reads:
java.lang.SecurityException: JCE cannot authenticate the provider SC
More information in this issue
We have been suffering with the same issue for a few weeks and had tried a lot of the suggested steps to no avail. Providing our solution below so others don't have to suffer like we did!
We were attempting to use bcprov-ext-jdk15on-162.jar, added to classpath, included in JBoss lib directories, bundled with WAR, marked as provided and added to JBoss /lib directories but no luck.
In the end, we tried different versions of bouncycastle and found a less recent version who's signature could be verified by our particular Java version's jarsigner (1.5X).
Despite the jar's signature being verifiable by our Java version, when the .jar is packaged into a WAR the signature was invalidated somehow by JBoss.
In the end, the solution for us was to;
1. Add bouncycastle jar to JBoss classpath
2. Add 'org.bouncycastle.jce.provider.BouncyCastleProvider' to 'java.security' providers
3. Mark bouncycastle in your WAR as a 'provided' dependency
Once we had a version of the .jar on our classpath and were sure that our WAR was not packaging it in we were golden.
The issue seems to be tightly coupled to whatever Java/JBoss version you happen to be using. So if this solution does not work for you I would suggest to test different versions of bouncycastle with
jarsigner -verify <bouncycastle.jar>
There are lot of solutions to this problem but unfortunately nobody talks about the causing issue.
If you are generating an executable jar that has BC.jar in it(in form of any dependency) than this issue would occur if below condition matches:
Generating jar via eclipse's export option i.e. Export-> Runnable Jar File -> Libary Handling {extract required libraries into generated Jar}-> FINISH
Boom, now you have landed into trouble and you will face an error i.e. JCE can't authenticate the provider BC
The reason for above problem is, when you create a jar with option 1 than you are actually unpacking the BouncyCastle jar again that violates the security assosiated with BC. So, whenever you run it again java validates it and finds current BC.jar in your assosiated jar has an error.
So, guys make sure what you are doing is justified because by changing the JDK's security data that will make it work but not for everyone.
How to make it work?{This will work on local/personal machine only,not on every machine }
edit jre\lib\security\java.security file
add security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider
copy bc*.jar to jre\lib\ext
That's it.
For me the issue was bcprov-ext-jdk16.jar was being discarded by sbt assembly.
[warn] Merging 'META-INF/license/LICENSE.bouncycastle.txt' with strategy 'discard'
..
[warn] Merging 'META-INF/maven/org.jasypt/jasypt/pom.properties' with strategy 'discard'
[warn] Merging 'META-INF/maven/org.jasypt/jasypt/pom.xml' with strategy 'discard'
..
So I ended up using the bouncycastle.jar from -classpath as below,
java -Denvironment=dev -cp chat-server.jar:/Users/prayagupd/.ivy2/cache/org.bouncycastle/bcprov-ext-jdk16/jars/bcprov-ext-jdk16-1.46.jar com.chat.server.ChatServer
What also works is putting the bouncycastle.jar to $JAVA_HOME/jre/lib/ext,
cp /Users/prayagupd/.ivy2/cache/org.bouncycastle/bcprov-ext-jdk16/jars/bcprov-ext-jdk16-1.46.jar $JAVA_HOME/jre/lib/ext/
$ ls -l $JAVA_HOME/jre/lib/ext/
total 55208
-rw-r--r-- 1 root wheel 1887089 May 7 21:22 bcprov-ext-jdk16-1.46.jar
-rw-rw-r-- 1 root wheel 3860502 Sep 5 2017 cldrdata.jar
-rw-rw-r-- 1 root wheel 8286 Sep 5 2017 dnsns.jar
-rw-rw-r-- 1 root wheel 44516 Sep 5 2017 jaccess.jar
-rwxrwxr-x 1 root wheel 18610276 Sep 5 2017 jfxrt.jar
-rw-rw-r-- 1 root wheel 1179093 Sep 5 2017 localedata.jar
-rw-rw-r-- 1 root wheel 1269 Sep 5 2017 meta-index
-rw-rw-r-- 1 root wheel 2022735 Sep 5 2017 nashorn.jar
-rw-rw-r-- 1 root wheel 41672 Sep 5 2017 sunec.jar
-rw-rw-r-- 1 root wheel 274148 Sep 5 2017 sunjce_provider.jar
-rw-rw-r-- 1 root wheel 248726 Sep 5 2017 sunpkcs11.jar
-rw-rw-r-- 1 root wheel 68924 Sep 5 2017 zipfs.jar
FYI: instead of modifying java.security and copying jar to \jre\lib\ext, below steps resolved my issue as well.
add Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()) in your class.
add provided scope to bcprov.*.jar dependency in pom.xml.
put bcprov.*.jar to your specific folder(e.g: \lib), then refer it when run the project.

Newrelic startup exception

We are getting the following error in catalina.out file when we restart our application with newrelic java agent configured.
We have followed the steps specified in newrelic installation guide and following is the entry created in catalina.sh by newrelic installer:
# ---- New Relic switch automatically added to start command on 2013 Dec 09, 20:24:35
NR_JAR=/usr/share/fk-ops-tomcat6-base/newrelic/newrelic.jar; export NR_JAR
JAVA_OPTS="$JAVA_OPTS -javaagent:$NR_JAR"; export JAVA_OPTS
Exception on app restart in catalina.out:
Error bootstrapping New Relic agent: java.lang.RuntimeException: java.io.IOException: No such file or directory
java.lang.RuntimeException: java.io.IOException: No such file or directory
at com.newrelic.bootstrap.BootstrapLoader.load(BootstrapLoader.java:95)
at com.newrelic.bootstrap.BootstrapAgent.premain(BootstrapAgent.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
Caused by: java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.checkAndCreate(File.java:1704)
at java.io.File.createTempFile(File.java:1792)
at java.io.File.createTempFile(File.java:1828)
at com.newrelic.bootstrap.BootstrapLoader.getJarFileInAgent(BootstrapLoader.java:81)
at com.newrelic.bootstrap.BootstrapLoader.addBridgeJarToClassPath(BootstrapLoader.java:47)
at com.newrelic.bootstrap.BootstrapLoader.load(BootstrapLoader.java:92)
... 7 more
I just encountered the same problem. The not very helpful error message alluded to the fact that the newrelic agent (or rather the user under which my server is running) wasn't able to write into /tmp. Maybe that helps!
I hit that exception with that stack trace recently, and in my case it was caused by the temporary directory not existing at all.
In particular: by default tomcat uses $CATALINA_BASE/temp as value for the java.io.tmpdir property, and seems to create that when needed. At the time the newrelic agent boots up however it may not yet exist, and so newrelic agent fails with that exception.
After restarting things are fine (now the directory exists!), but I solved in my startup scripts:
1. set the value of CATALINA_TMPDIR explicitly to something I control
2. ensure that directory exists before starting tomcat.
Make sure the newrelic.yml placed and marked readable in the same directory as the .jar
I work for New Relic.
As you've seen from the answers above, there can be multiple causes for this kind of message - some of which are pretty unexpected. Since this forum is not intended for back-and-forth messaging about incidents, in case neither of the previous two answers solved the problem for you, your best bet will be to open a ticket for support at http://support.newrelic.com where we can ask to look at your logfile and gather debug logs as necessary.
I had the same problem using apache version 6.0.33. Once I upgraded to 7.0.53 everything worked.
save problem.
But I found this:
Sep 09, 2015 11:19:48 AM org.apache.catalina.startup.Catalina initDirs
SEVERE: Cannot find specified temporary folder at /mnt/apache-tomcat-7.0.56/temp
then doing this:
mkdir /mnt/apache-tomcat-7.0.56/temp
cp /mnt/apache-tomcat-7.0.56/newrelic/* /mnt/apache-tomcat-7.0.56/temp
Everything works.
You may not need cp.
If you look at very early of Tomcat log (catalina.out) after NewRelic exception, you can see what folder is required that are missing. Here is mine:
May 29, 2017 5:04:31 PM org.apache.catalina.startup.Catalina initDirs
SEVERE: Cannot find specified temporary folder at /var/log/tomcat/tomcat7/temp
May 29, 2017 5:04:32 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/7.0.59
Hope this help

Apache FOP applet error Unknown function: gatherContextInfo

I'm trying to use FOP to generate a pdf file in a signed applet, but, i got these errors:
Dez 10, 2013 2:09:45 PM org.apache.fop.fo.properties.PropertyCache <init>
Informações: Unable to access org.apache.fop.fo.properties.use-cache due to security restriction; defaulting to 'true'.
ERROR: 'Unknown function: gatherContextInfo'
I tried the same code in a desktop application, and everything works fine, the problem is just in the applet.
Problem solved!
I had to add the provided xalan.jar in fop-bin.zip to the classpath.
I guess it includes the unknown function while the built in implementation in JRE not.

How to run Jade agents in two containers (from two consoles)

I'm new in Jade and study Jade Primer. I'm using the latest version Jade v4.2.
I'm trying to set up two behaviours, each coded to receive messages. I should run them in two separated windows, but it doesn't work for me.
I'm using Eclipse on WinXp. I have entered classpath to Jade
c:\jade\lib\jade.jar;C:\jade\lib\commons-codec\commons-codec-1.3.jar;C:\Program Files\Java\jre7\bin
and to folder containing my projects
C:\Users\me\workspace\jadeProject\src
There is folder primer4 (package added to Java code), where I put my Java files.
I compiled Java files by javac from console.
Then I tried to run from the console (from primar4 folder):
%java jade.Boot -agents a1:primer4.Responder;a2:primer4.Responder
The First command is working. Then I run second console window and put:
%java jade.Boot -container main:primer4.Template
INFO: Service jade.core.event.Notification initialized
pač 19, 2012 4:35:57 PM jade.core.AgentContainerImpl startBootstrapAgents
SEVERE: Cannot create agent main: Class primer4.Template for agent ( agent identifier
:name main#10.0.2.15:1099/JADE ) not found [nested java.lang.ClassNotFoundException: primer4.Template]
pač 19, 2012 4:35:57 PM jade.core.AgentContainerImpl joinPlatform
INFO: Agent container Container-2#10.0.2.15 is ready.
I got this error, can somebody tell me:
How can I fix it?
Is possible to run agents in two containers from one line in console (in one console, the same time)?
Try the -agents option in the second command:
java jade.Boot -container -agents main:primer4.Template
This is by the Classpath problem. So please make sure the directory which is having your .class files in the classpath.
you can create one agent per container by the
-container option.
or you can create the agents by
jade.core.Runtime runtime = jade.core.Runtime.instance();
jade.wrapper.AgentContainer home = runtime.createAgentContainer(new ProfileImpl());
home.createNewAgent(getName(), Agent.class.getName(), args);
Like this you can create the agents and add dynamically.

Categories