Connection Time out error while parsing hbm file - java

I am facing this weird issue while opening hbm file. I am using hibernate3.jar. I also verified that there is only one hibernate3.jar in classpath and it contains hibernate mapping dtd file.
I tried to put code and exception here but StackOverFlow engine continuously throwing some error.
Code and exception is given at [link] https://forum.hibernate.org/viewtopic.php?f=1&t=1029004.
I also tried by specifying docBuilder.setEntityResolver(new DTDEntityResolver());
I was running it via Apache Ant and behind proxy.
Any pointers will be appreciated.
Thanks,

Setting proxy values as export
ANT_OPTS="-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080"
didn't work. So, I set the proxy values in Ant's build file as given in ant documentation and it worked.
<property name="proxy.port" value="80"/>
<property name="proxy.user" value=""/>
<property name="proxy.pass" value=""/>

Related

No suitable driver found for "jdbc:oracle:thin:#localhost:1521:xe" in hibernate without IDE

I am using Hibernates without any IDE. I doing on notepad++ text editor. I follow all the steps and worked fine. I set all the jars as classpath. i set classpath foe ojdbc14.jar for my jdk 1.8.0_15. When i run my java file hibernates gives the below error.
No suitable driver found for jdbc:oracle:thin:#localhost:1521:xe
I use the below line in hibernate.cfg.xml
<session-factory>
..
...
<property name="connection.url">jdbc:oracle:thin:#localhost:1521:xe</property>
..
..
</session-factory>
help me to how to resolve this no suitable driver found?
Thanks in advance.

Hibernate Mapping issue with Tomcat

I want to get rid of xml table mappings from my hibernate.cfg and replace them with references to classes themselves.
Here is what is used to have in my hibernate.cfg and what i'm replacing it with..
<mapping class="com.eugene.repository.mappings.Users"/>
<!--<mapping resource="/mappings/Users.hbm.xml"/>-->
I can do that and then run tests from my local box and everything works well,
but when i create war file and upload it to tomcat, it cant resolve mappings..
What am i missing?

Getting 'Missing Required Attribute' JiBX error after migrating to WebLogic 12

Good morning,
I've been working on a project where I'm supposed to:
upgrade the application from JRockit 1.6 to Java 7
upgrade the application to run in a WebLogic 10.3.5 environment to run in a WebLogic 12 environment
I'm sure this doesn't help but I'm new to the Java/Spring/WebLogic world.
I was able to upgrade from JRockit 1.6 to Java 7 but when it comes to the WebLogic part, I've been having issues starting the application.
Every time I do, I get the following error
org.jibx.runtime.JiBXException: Missing required attribute "a" (line 1, col 71)
at org.jibx.runtime.impl.UnmarshallingContext.attributeText(UnmarshallingContext.java:975)
at com.mydomain.JiBX_rule_def_bindingMungeAdapter.JiBX_rule_def_binding_unmarshalAttr_1_0()
at com.mydomain.JiBX_rule_def_bindingMutableRuleDefinition_access.unmarshal()
at org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2757)
at org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2900)
and have been trying to debug it for a while now. What's really weird is that when I take out the code from a Spring/WebLogic environment and execute it, it works fine (ie, unmarshalls the data).
When it was in the WebLogic 10.3.5 environment w/ JRockit 1.6 and JiBX 1.2.1 jars, I had zero issues.
Here's what I've tried
upgraded JiBX jars from 1.2.1 to 1.2.5
upgraded xpp3 jars to 1.1.3.4.O
upgraded Spring jars from 2.5.5 to 3.2.11
tried including a weblogic.xml file (didn't have one before) and try to used the
<preferred-web-inf>true</preferred-web-inf>
but no luck
tried including a weblogic-application.xml file and an APP-INF folder (didn't have one before) and tried to used the JiBX as my preffered class for unmarshalling
Here is some more information about the environment I'm working in
Non Maven Environment (had to upgrade .jars manually)
Used Java 1.7.0.45 and .71
WebLogic 1.2.1.2
Spring 3.2.11
JiBX 1.2.5
using MyEclipse Version: 2014 Build id: 12.0.0-20131202
no xsd file just a .xml binding file
<binding>
<mapping name="rule"
class="com.mydomain.MutableRuleDefinition">
<value name="a" field="a" style="attribute" />
<value name="b" field="b" style="attribute" />
<collection field="ruleElements">
<structure name="ruleElement"
type="com.mydomain.MutableRuleElement">
<value name="c" field="c" style="attribute" />
<value name="d" field="d" style="attribute" />
<collection field="values" item-type="java.lang.String"
usage="optional">
<value name="value" />
</collection>
</structure>
</collection>
</mapping>
</binding>
Here is the unmarshalling code:
private MutableRuleDefinition unmarshalXMLRuleDef(String _xmlRuleDef) {
MutableRuleDefinition mruleDef = null;
try {
IBindingFactory bfact = BindingDirectory
.getFactory(MutableRuleDefinition.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
mruleDef = (MutableRuleDefinition) uctx.unmarshalDocument(
new ByteArrayInputStream(_xmlRuleDef.getBytes()), null);
} catch (JiBXException e) {
logger.error("Could not un-marshalling the XML rule definition:["
+ _xmlRuleDef + "]", e);
}
Apparently this was an issue back in JiBX 1.2.1 but was fixed in 1.2.2 :
https://www.mail-archive.com/jibx-users#lists.sourceforge.net/msg04200.html
Any help appreciated. Please let me know if you need more info...
Update #1
I have tried
<value name="a" field="a" style="attribute" usage=optional />
on all the attribute flags and the unmarshalling will work, however, these fields aren't optional so I can't use that as a fix.
Update #2
fwiw, here is an example that would come into be unmarshalled
<rule a="dataForA" b="dataForB">
<ruleElement c="dataForC1" d="dataForD1" />
<ruleElement c="dataForC2" d="dataForD2" />
<ruleElement c="dataForC3" d="dataForD3" />
<ruleElement c="dataForC4" d="dataForD3" />
</rule>
R Hanna,
I would suggest looking at the JiBX dependencies and making sure all of the Jars are the exact same version as the ones used by JiBX. We use some eclipse libraries that often conflict with web server jars.
Also, remember that JiBX is open source. You may want to step through the code and see what is causing JiBX to fail.
One more thing. I can't see your schema definition, but it is strange that the error seems to say that you are missing an attriburte. Are you sure the 'source' attribute is not required.
Good Luck!
Don Corley
JiBX contributor
R Hanna,
I got this resolved for me after using 1.2.5 version of jibx however i made sure all the related jars also updated to 1.2.5 and made sure there are no stale class files present in my war which were created by the previous jars that did the trick for me hope its helps you .

Package a runnable JPA jar putting persistence.xml outside

I want to export my jpa/swing project to a runnable jar. But I want the persistence.xml to be outside the jar not packaged inside, so I can change it without the need to export the jar again after each config.
According to JPA specifications, persistence.xml file cannot be detected outside the JAR file where the persistence unit is defined. By convention, it should be placed inside META-INF directory.
Read JSR-317, paragraph 8.2.1 for more details (http://download.oracle.com/otndocs/jcp/persistence-2.0-fr-eval-oth-JSpec/).
Nevertheless, you can try the hint proposed by this guy here and deploy your archives in exploded form.
I had the same problem, but I only needed to change Server, database, user and password. So this did it for me:
In JBoss AS, you can even have the property value as a placeholder, for example:
<property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://${DbServer}:1234;databaseName=${DbName}" />
<property name="javax.persistence.jdbc.user" value="${DbUser}" />
<property name="javax.persistence.jdbc.password" value="${DbPassword}" />
and then pass the "DbServer", "DbName", "DbUser" and "DbPassword" value as a Java system property:
-DDbServer=sql99 -DDbName=db_Name -DDbUser=USER -DDbPassword=pw
In Eclipse:

Hibernate Logging while Executing ANT SCRIPT for POJO Class Generation

I am using ANT SCRIPT to generate POJO classes from database.
I want to generate log for each class and table while executing the script.
Can I use Log4J for Hibernate? Any documentation or tutorial for this? or any other suggestions?
Please help!!
Thanks in advance.
just add to your hibernate.cfg.xml with following.
<property name="hibernate.show_sql">true</property>
Just write this code in your hibernate.cfg.xml
<property name="hibernate.show_sql">true</property>
This will show hql on catalina.out file. or on console if you are making desktop application.
You can use Log4J as log listener for Ant, then Log4J will log any ant message or call. Use this argument to attach the listener during ant execution.
-listener "org.apache.tools.ant.listener.Log4jListener"
Of course you'll have to specify the logger in the ant classpath.

Categories