Hibernate fails with NullPointerException in EntityTuplizerFactory.constructTuplizer? Why? - java

I have a problem when I try to instantiate Hibernate and connect with a MySQL database (see error message below).
Curiously enough the connection works fine using the exact same hibernate.cfg.xml file when running Junit tests but it refuses to work when run from Tomcat...
I am starting to run out of ideas.
Any clues or tip where to look?
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.DynamicMapEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:69)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:323)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:456)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:131)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:267)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)
at se.fmt.atlantism.util.HibernateUtil.buildSessionFactory(HibernateUtil.java:16)
... 38 more
Caused by: java.lang.NullPointerException
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
... 47 more

I'm writing this for future Googlers and reference.
I've done some more research and the root source of the problem is still not known. However the following article throw me on the right track.
http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/
It seems like the Tomcat (version 6 at least) packages available in Ubuntu (and Debian) are not working correctly. Instead I installed Tomcat using the following guide:
http://www.ctrip.ufl.edu/tomcat6-debian-lenny-howto
While this might not be the premium choice of installation it seems necessary to get Tomcat version 6 running without problems on Ubuntu and/or Debian Lenny.

In my case, this error was resolved by switching the <dependency/> order in my pom.xml. When hibernate (3.2.7.ga) comes before hibernate-annotations (3.4.0.GA) this error occurs. The other way around, it works fine. This is the case even with scope=compile.
I would guess that you need to tweak your classpath, except that (assuming you've dropped both jars in WEB-INF/lib) it should alpha-sort in the correct order. But maybe this will give someone a hint on how to move forward.

In my case it was a simple mistake - the config file *.hbm.xml had a property that the mapped object didnt have! I also heard of cases of that error apearing when you misspell a get/set function - very similar to my case.

I was facing the same problem. It went away after I downloaded "javassist.jar" and put it in the classpath: http://www.java2s.com/Code/Jar/JKL/Downloadjavassistjar.htm

This is how the Tomcat daemon process looks:
root 2605 0.0 0.0 16584 376 ? Ss 15:39 0:00
/usr/bin/jsvc -user tomcat6
-cp /usr/share/java/commons-daemon.jar:/usr/share/tomcat6/bin/bootstrap.jar
-outfile SYSLOG -errfile SYSLOG -pidfile /var/run/tomcat6.pid
-Djava.awt.headless=true -Xmx128M
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
-Dcatalina.base=/var/lib/tomcat6 -Dcatalina.home=/usr/share/tomcat6
-Djava.io.tmpdir=/tmp/tomcat6-temp -Djava.security.manager
-Djava.security.policy=/var/lib/tomcat6/work/catalina.policy
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=/var/lib/tomcat6/conf/logging.properties
org.apache.catalina.startup.Bootstrap
This is how the Tomcat process looks when run from within Eclipse using the Sysdeo Tomcat launcher plugin:
(this one actually works)
jzaruba 2655 19.7 4.5 358304 46152 ? Sl 15:43 0:01
/usr/lib/jvm/java-6-sun-1.6.0.15/bin/java
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:37377
-Dcatalina.home=/usr/share/tomcat6
-Djava.endorsed.dirs=/usr/share/tomcat6/endorsed
-Dcatalina.base=/var/lib/tomcat6 -Djava.io.tmpdir=/var/lib/tomcat6/temp
-Dfile.encoding=UTF-8 -classpath
/usr/share/tomcat6/bin/bootstrap.jar:/usr/lib/jvm/java-6-sun-1.6.0.15/lib/tools.jar
org.apache.catalina.startup.Bootstrap start
The working one (Eclipse launched) is run using java-6-sun-1.6.0.15, I'm Windows user so I don't know how to tell which JRE is used for /usr/lib/jsvc (looking at it though), but my guess would be it is some OpenJDK... Could this be the difference?
update: jsvc probably uses the same JRE Sysdeo Tomcat launcher does

Related

Wix embedded mysql does not start due CommandFailedException due 'Stream closed'

Trying to run my embedded mysql based Unit tests I get an exception with this part:
Failed to instantiate [com.wix.mysql.EmbeddedMysql]: Factory method 'getEmbeddedMysql' threw exception; nested exception is com.wix.mysql.exceptions.CommandFailedException: Command 'CREATE USER 'sa'#'%' IDENTIFIED BY '';' on schema 'information_schema' failed with message 'Stream closed'
The same unit test and environment setup work on my MacBook
This machine with the error is an Ubuntu 20.04
Wix version is 4.6.2; Java 8, mysql.connector 8.0.24
I tried changing the dependencies versions and also tried with Java 11.
Run from within IntelliJ and on the command line. Same result.
Let me put the full comment I found in Github which helped me to fix this and I'm pretty sure most of the people seeing this in Ubuntu will find this as the solution:
I had this same issue with MySQL 5.7, while working on another open source project. I cloned the wix-embedded-mysql repository and ran the tests using the master branch, which also failed in the exact same way, except that I received a longer, more thorough message in the catch.
The issue was that I was on Ubuntu and did not have the ncurses 5 shared library installed. On ubuntu, I installed libncurses5 (apt install libncurses5) and everything started working (all tests on wix, and on my project).
I hope this helps resolve the issue.
Thanks to https://github.com/codesplode

Connect Java Mission Control to Wildfly 16

I try to connect Java Mission Control (JMC) with Wildfly 16. Application server lays on Docker.
I successfully connected to wildfly via jconsole, to manage it I followed steps described here.
Unfortunately, I have no luck to connect via JMC. The URL which I use looks like this:
service:jmx:remoting-jmx://192.168.99.100:9990
I tried to set Xbootclasspath to jboss-cli-client.jar as it was described here, but I just get Unable to connect error.
I set the same jars, which are used for jconsole, but still I got Unable to connect.
I gave a try to adding flags on container site, as it was shown here, but with these flags, even wildfly haven't started.
Then, I found here the idea to hardcode some jboss classes to enable connection via remoting-jmx. I changed version of jars, according to these provided by wildfly16 and put it to jmc.ini like this.
-Xbootclasspath/a:"C:/Program Files/Java/jdk-10.0.2/lib/missioncontrol/dropins/jboss-cli-client.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/remoting-jmx/main/remoting-jmx-3.0.1.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/remoting/main/jboss-remoting-5.0.8.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/logging/main/jboss-logging-3.3.2.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/xnio/main/xnio-api-3.6.5.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/xnio/nio/main/xnio-nio-3.6.5.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/marshalling/main/jboss-marshalling-2.0.6.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/marshalling/river/main/jboss-marshalling-river-2.0.6.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/as/cli/main/wildfly-cli-8.0.0.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/staxmapper/main/staxmapper-1.3.0.Final;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/as/protocol/main/wildfly-protocol-8.0.0.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/dmr/main/jboss-dmr-1.5.0.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/as/controller-client/main/wildfly-controller-client-8.0.0.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/threads/main/jboss-threads-2.3.3.Final.jar;C:/wildfly-16.0.0.Final/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-2.1.7.Final.jar"
After that, finally, I have another error, which is
Could not initialize class org.jboss.remotingjmx.RemotingConnector
I added dependencies of remoting-jmx-3.0.1.Final to Xbootclasspath, but I got still the same error.
My question is, have you got any idea, how to make this connection works ? Maybe someone have done it in different way ?
Any advices how can i debug this problem, will be priceless? Because I'm lack of ideas how to solve it.
In %WILDFLY_HOME%\bin\standalone.conf.bat
put:
set "JAVA_OPTS=%JAVA_OPTS% -XX:+FlightRecorder"
In jmc.ini below -vmargs put
-Xbootclasspath/a:C:\%wildfly_home%\bin\client\jboss-cli-client.jar
(%wildfly_home% is different of course, or just copy jboss-cli-client.jar to another directory and correct the path)
3. Run JMC, then Create New Connection - in Connection Properties pane push the button "Custom JMX service URL", put:
service:jmx:http-remoting-jmx://localhost:9990
In the credentials fields just put user and password, they should be created for Realm Management (e.g. using %wildfly_home%\bin\add-user.bat)
Hope this helps someone.
Solution doesn't work on java 11 for me. Mission control fails on connect to wildfly with error:
Caused by: java.lang.NoClassDefFoundError: org/ietf/jgss/GSSManager
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3137)
at java.base/java.lang.Class.getConstructor0(Class.java:3342)
at java.base/java.lang.Class.getConstructor(Class.java:2151)
at java.base/java.security.Provider.newInstanceUtil(Provider.java:152)
at java.base/java.security.Provider$Service.newInstance(Provider.java:1824)
at org.wildfly.security.WildFlyElytronBaseProvider$ProviderService.newInstance(WildFlyElytronBaseProvider.java:218)
at org.wildfly.security.sasl.util.SecurityProviderSaslClientFactory.createSaslClient(SecurityProviderSaslClientFactory.java:94)
at org.wildfly.security.sasl.util.AbstractDelegatingSaslClientFactory.createSaslClient(AbstractDelegatingSaslClientFactory.java:66)
at org.wildfly.security.sasl.util.ProtocolSaslClientFactory.createSaslClient(ProtocolSaslClientFactory.java:50)
at org.wildfly.security.sasl.util.AbstractDelegatingSaslClientFactory.createSaslClient(AbstractDelegatingSaslClientFactory.java:66)
at org.wildfly.security.sasl.util.ServerNameSaslClientFactory.createSaslClient(ServerNameSaslClientFactory.java:50)
at org.wildfly.security.sasl.util.AbstractDelegatingSaslClientFactory.createSaslClient(AbstractDelegatingSaslClientFactory.java:66)
at org.wildfly.security.sasl.util.ServerNameSaslClientFactory.createSaslClient(ServerNameSaslClientFactory.java:50)
at org.wildfly.security.sasl.util.FilterMechanismSaslClientFactory.createSaslClient(FilterMechanismSaslClientFactory.java:102)
at org.wildfly.security.sasl.util.AbstractDelegatingSaslClientFactory.createSaslClient(AbstractDelegatingSaslClientFactory.java:66)
at org.wildfly.security.sasl.util.LocalPrincipalSaslClientFactory.createSaslClient(LocalPrincipalSaslClientFactory.java:76)
at org.wildfly.security.sasl.util.PrivilegedSaslClientFactory.lambda$createSaslClient$0(PrivilegedSaslClientFactory.java:64)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.wildfly.security.sasl.util.PrivilegedSaslClientFactory.createSaslClient(PrivilegedSaslClientFactory.java:64)
at org.wildfly.security.auth.client.AuthenticationConfiguration.createSaslClient(AuthenticationConfiguration.java:1545)
at org.wildfly.security.auth.client.AuthenticationContextConfigurationClient.createSaslClient(AuthenticationContextConfigurationClient.java:430)
at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:419)
at org.jboss.remoting3.remote.ClientConnectionOpenListener$Capabilities.handleEvent(ClientConnectionOpenListener.java:244)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
Besides, jmc that was embedded to jdk 8 isn't able to start flight recording for java 11 process.
So after investigation i found out that this class is loaded with bootstrap classloader. According to https://openjdk.java.net/jeps/261
jdk.security.jgss module isn't defined to bootstrap classloader. But classes in jboss-cli-client.jar(it originates from wildfly-elytron project) need jgss classes in runtime.
So i found out dirty workaround for this problem: bootstrap needed classes from jre 8 in jmc.ini. Full option for linux is:
-vmargs -Xbootclasspath/a:<path_to_wildfly>/jboss-cli-client.jar:<path_to_jdk8>/jre/lib/rt.jar
And for windows:
-vmargs -Xbootclasspath/a:<path_to_wildfly>\jboss-cli-client.jar;<path_to_jdk8>\jre\lib\rt.jar
after this jmc(run on 11 jdk) succesfully connects to wildfly(run on 11 jdk) and can start and analyze flight recordings.

Unparseable date after upgrading/downgrading Jenkins

So, finally trying to come up from the stone age, upgraded 1.514 to 1.644 without realizing all slaves need to be running Java 1.7 as well. So I install Java 7 on my master, swap .war files to run 1.644 and start it up. Slaves don't come up due to the aforementioned Java req. After stopping Jenkins and removing Java 1.7, I swap back to the 1.514 .war and start Jenkins back up. Now my build history is gone from all jobs with this error in the log:
WARNING: could not load /var/lib/jenkins/jobs/[job name removed]/builds/312 hudson.util.IOException2: Invalid directory name /var/lib/jenkins/jobs/YYMM Check and Build/builds/312 at hudson.model.Run.parseTimestampFromBuildDir(Run.java:354)
...
Caused by: java.text.ParseException: Unparseable date: "312" at java.text.DateFormat.parse(DateFormat.java:354) at hudson.model.Run.parseTimestampFromBuildDir(Run.java:352) ... 155 more
The only things I can find online relate to issues that were fixed pre-1.514. Anyone have any ideas? Thanks for helping.
Installed the latest version that works with Java 1.6: 1.607, and that fixed the issue as soon as it started up.
Your issues are likely related the change to the build directory naming, see JENKINS-24380+Migration.
In case you want to downgrade, there is an “unmigrate” script provided to reverse the migration of $JENKINS_HOME. To do this:
Start Jenkins ≥1.597.
Visit http://server/jenkins/JENKINS-24380/ and copy the unmigration instruction.
Shut down Jenkins completely.
Run the command as instructed by the step above.
Start Jenkins <1.597 with the same $JENKINS_HOME.

STS 3.6 RELEASE error running server

When I run my project, I don't have errors.
But After login, when I try to enter in a form page the application give me the follow error:
GRAVE: Servlet.service() for servlet jsp threw exception
java.util.NoSuchElementException
at java.util.ArrayList$Itr.next(Unknown Source)
at org.apache.jasper.compiler.Validator$ValidateVisitor.getJspAttribute(Validator.java:1381)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:772)
at org.apache.jasper.compiler.Node$UninterpretedTag.accept(Node.java:1251)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:779)
at org.apache.jasper.compiler.Node$UninterpretedTag.accept(Node.java:1251)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2375)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2427)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:895)
...
I think the problem is in the configuration of tomcat but I don't understand where.
I have tomcat7.0.52, use java version 1.7.0_60, idem for jdk.
At my colleague work all without problems, we have the same tomcat version, the only difference is that I have STS 3.6 RELEASE, and He have the 3.5.
EDIT:
I try to delete server, and recreate it, but the problem don't change.
I think that the problem is on wrong configuration server because any project I run give me the same error.
This is my catalina arguments:
-Dcatalina.base="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/base-instance"
-Dcatalina.home="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/tomcat-7.0.53.B.RELEASE"
-Dwtp.deploy="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/base-instance/wtpwebapps"
-Djava.endorsed.dirs="/home/paola/Documenti/sts-bundle/vfabric-tc-server-developer-2.9.6.RELEASE/tomcat-7.0.53.B.RELEASE/endorsed" -Xmx768m -Xss256k -XX:MaxPermSize=256m
-Dinsight.enabled=false -Dspring.profiles.active=dev
Any ideas?
Thank
It looks like the problem is with the version of Tomcat that tcServer is derived from.
This bug which is fixed in Tomcat 7.0.55 is looks like the cause.
I've done some testing and found that the bug is not present in Tomcat 7.0.50, which is used by tcServer Dev Edition 2.9.5.SR1.
So it's either 7.0.51 or 7.0.52 (as you discovered) which introduced the bug.

SVG generation with FOP doesn't work

On one server, and on my Windows laptop, producing PDFs with this method works fine:
http://www.databasesandlife.com/svg-to-pdf/
But on the other server I get this error:
org.apache.batik.transcoder.TranscoderException: Error while setting up PDFDocumentGraphics2D
Enclosed Exception:
Error while setting up fonts
at org.apache.fop.svg.PDFTranscoder.transcode(PDFTranscoder.java:189)
at org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(Unknown Source)
at org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(Unknown Source)
at org.apache.batik.apps.rasterizer.SVGConverter.transcode(Unknown Source)
at org.apache.batik.apps.rasterizer.SVGConverter.execute(Unknown Source)
I have been Googling and searching for hours, but to no avail. What can I do?
I tried installing the following packages but they didn't help:
sudo apt-get install gsfonts gsfonts-x11 gsfonts-other batik \
libbatik-java libxmlgraphics-commons-java \
libxmlgraphics-commons-java fop sun-java6-fonts
My situation is:
Debian 6.0.3
Sun Java version "1.6.0_26"
JARs: avalon-framework-4.2.0.jar batik-all-1.7.jar commons-io-1.3.1.jar commons-logging-1.0.4.jar fop-0.95.jar log4j-1.2.15.jar xml-apis-ext.jar xmlgraphics-commons-1.3.1.jar
Sincerely it is not a good idea to create such temporary files inside the jetty structure from the Debian package. In case of an update, you may get into troubles. Such a cache directory should be located in /var, like /var/tmp for instance.
According to documentation, FOP is supposed to use the temporary directory in case of failure. Probably your finding deserves a bug report.
Until it is fixed, you should set cache-file option Disabling cache with use-cache is another way but probably with performance impacts.
The approach to solving this problem is in log4j.properties I turned up the level to TRACE.
There I saw the extra log before the TranscoderException that I'd seen previously:
2012-02-28 11:51:24,863 DEBUG: org.apache.fop.fonts.FontCache:
Writing font cache to /usr/share/jetty/.fop/fop-fonts.cache
org.apache.batik.transcoder.TranscoderException:
Error while setting up PDFDocumentGraphics2D
Horray for logs! (And writing a log about what the program is about to do, not just once it has done it, so that if the operation fails, then you know what it was trying to do while it failed.)
On Debian, the Jetty webserver runs under the user jetty and has its home directory at /usr/share/jetty/. However, the jetty user does not have write-access to its own home directory, therefore this ~/.fop directory could not be created.
adrian#10770-02:~$ grep jetty /etc/passwd
jetty:x:107:111::/usr/share/jetty:/bin/false
adrian#10770-02:~$ ls -ld /usr/share/jetty
drwxr-xr-x 7 root root 4096 Feb 28 11:52 /usr/share/jetty/
I don't know whether this is by design, or a bug, but creating this directory so that Jetty could write it...
sudo mkdir -p -m 0777 /usr/share/jetty/.fop
...solved the problem.

Categories

Resources