java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V Exception while migrating from 12.1.3 to 12.2 - weblogic12c

I am doing migration from JDev 12.1.3 to 12.2.0. Now there was some problem durnng compilation but it has been resolved by modifiying class path.
Now when I go for deployment then it showing me one exception. That is ...
"java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V"
I am using following dependencies..
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.0.Final</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.0.1.Final</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
Apart from these dependencies I also looked into "C:\oracle_home12c\wlserver\modules" folder and found there was one "org.jboss.logging.jboss-logging.jar" file.
I replaced the maven repo file from "jboss-logging-3.3.0.Final".
I also looked into "jboss-logging-3.3.0.Final" jar file. There is one Logger class file but it does not contain the debugf(String) method.
Exception type;
Caused by: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149)
at org.hibernate.internal.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:764)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:495)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:802)
at org.hibernate.jpa.HibernatePersistenceProvider.createContainerEntityManagerFactory(HibernatePersistenceProvider.java:135)
at weblogic.persistence.BasePersistenceUnitInfo.initializeEntityManagerFactory(BasePersistenceUnitInfo.java:611)
Can someone help to get rid off this problem?
Thanks in advance

If you are using the glassfish server the the problem might be with the lib provided by glassfish. This error is caused by the use of incompatible version.
Just create a glassfish-web.xml file in the WEB-INF directory. The contents of the file are shown below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
 <class-loader delegate="false"/>
</glassfish-web-app>
This ensures that glassfish does not load it's internal libraries, but libraries from your project.

I don't know how JDev classloading works, but maybe it takes the a wrong version of jboss-logging which doesn't have the method? Try removing that from the modules dir. And make sure that your app bundles jboss-logging in the .war. It should be brought in by Hibernate's dependencies. If not, add it to the pom.xml.

Related

Cannot resolve symbol 'owasp', import error in intellij

I want to use ESAPI in my project and have added following dependency in the pom.xml
pom.xml with dependency:
<dependency>
<groupId>org.owasp.encoder</groupId>
<artifactId>encoder</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.5.0.0</version>
</dependency>
But when I import org.owasp.esapi.* intellij give me warning as shown in image.
I want to use ESAPI logger to prevent CRLF injection possibilities in log statements.
My current project uses slf4j.Logger
I am very new to this ESAPI and OWASP and have never used it and have tried from here
https://github.com/ESAPI/esapi-java-legacy/wiki/Using-ESAPI-with-SLF4J#configuring-esapi-to-use-slf4j
Please tell me if im doing something wrong and how to correctly use ESAPI in project.
Hmm. What JDK are you using with IntelliJ? Java 8 or later is required as of 2.4.0.0. That's the only thing that I can think of that would cause this behavior. Looks okay otherwise. Did you check if the esapi-2.5.0.0.jar got pulled down? Because it's either not finding that or it's not compatible with the Java version that your IntelliJ IDE is using.
Well i found that I was adding this dependency in <dependencyManagement> tag instead of <dependencies> tag, that's why it wasn't downloading from the repository.
Previous:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.5.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>
after fix:
<dependencies>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.5.0.0</version>
</dependency>
</dependencies>
Whats the difference in <dependencies> and <dependencyManagement> please refer this Differences between dependencyManagement and dependencies in Maven

java.util.ServiceConfigurationError: javax.xml.stream.XMLInputFactory: Provider com.ctc.wstx.stax.WstxInputFactory not a subtype

I am using Weblogic 12c. I m trying to deploy myApplication.war in Weblogic.
While deploying i get bellow error.
An error occurred during activation of changes, please see the log for details.
Message icon - Error java.util.ServiceConfigurationError: javax.xml.stream.XMLInputFactory: Provider com.ctc.wstx.stax.WstxInputFactory not a subtype
Message icon - Error javax.xml.stream.XMLInputFactory: Provider com.ctc.wstx.stax.WstxInputFactory not a subtype
The same myApplication.war I am able to deploy in weblogic-10,Jboss and Tomcat. But not in weblgic-12c.
I googled and found that i need to include dependency for xercesImpl.jar. I included that but, That dint help. still I am facing the same issue.
I tried including some other dependency, those are.
<dependency>
<groupId>com.fasterxml.woodstox</groupId>
<artifactId>woodstox-core</artifactId>
<version>5.0.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId>
<version>3.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-lgpl</artifactId>
<version>4.4.1</version>
<scope>compile</scope>
</dependency>
the above dependency dint help. Any suggestion for trouble shooting the application,any link.
It seems to be very common problem with weblogic-12c. what is root
cause of the exception?
I add only one dependency in ear pom.xml. It's work for me in WLS 12.2.1.3.
<dependency>
<groupId>com.fasterxml.woodstox</groupId>
<artifactId>woodstox-core</artifactId>
<version>5.0.2</version>
</dependency>
and another libs was exclude, such as org.codehaus.woodstox, stax-api
In WebLogic.xml add:
<container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
</container-descriptor>

Error deploying Spring project to Weblogic [duplicate]

i am using spring 3.1.0.RELEASE, and my servlet container is tomcat 7 and my IDE is eclipse indigo
and the jar spring-webmvc-3.1.0.RELEASE.jar which contains the DispatcherServlet
exists in the lib folder, and yet when running the application, i am getting the exception:
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:126)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1043)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
please advise why i am getting this exception, and how to fix it.
EDIT: following are my configuration files:
1- .springBeans:
<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
<version>1</version>
<pluginVersion><![CDATA[2.9.0.201203011806-RELEASE]]></pluginVersion>
<configSuffixes>
<configSuffix><![CDATA[xml]]></configSuffix>
</configSuffixes>
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>src/main/webapp/WEB-INF/checkout-servlet.xml</config>
</configs>
<configSets>
</configSets>
</beansProjectDescription>
2- web.xml:
<web-app>
<display-name>Checkout</display-name>
<servlet>
<servlet-name>checkout</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>checkout</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
</web-app>
3- checkout-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="com.myapp"/>
<bean id="myService" class="com.myapp.MyService"/>
</beans>
also when trying to access any page in the application, i get the exception:
HTTP Status 404 - Servlet checkout is not available
type Status report
message Servlet checkout is not available
description The requested resource (Servlet checkout is not available) is not available.
Apache Tomcat/7.0.22
You need to add the "Maven Dependency" in the Deployment Assembly
right click on your project and choose properties.
click on Deployment Assembly.
click add
click on "Java Build Path Entries"
select Maven Dependencies"
click Finish.
Rebuild and deploy again
Note: This is also applicable for non maven project.
Two possible answers:
1- You did not include spring-beans and spring-context jars in your lib.
If you are using maven (which will help a lot) those two lines will be enough
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
2- The necessary jars are in your classpath but are not deployed on tomcat.
I had the same problem with Idea Intellij and Spring 4. I fixed the problem and I wanted to share the answer with you.
I use tomcat 7 / idea intellij 13 / spring 4.
pom.xml dependencies:
<properties>
<spring.version>4.0.5.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
enter code here
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
In idea Intellij, you need to go to File -> Project Settings -> Artifacts.
Then
clean -> rebuild the project -> build the artifact, and everything will be ok.
This solves the problem for me. It's easy and pretty simply explained.
Step 1
Right click on project
Click on Properties
Step 2
Click on Deployment Assembly Tab in the
Click Add...
Step 3
Click on Java Build Path Entries
Step 4
Click on Maven Dependencies
Click Finish button
Step 5
Redeploy Spring MVC application to Tomcat again
Restart Tomcat
List item
classnotfoundexception
i found that in the deployment assembly, there was the entry:
[persisted container] org.maven.ide.eclipse.maven2_classpath_container
i removed it, and added the maven dependencies entry, and it works fine now.
If all of these advice doesn't work, you should re-create your Server (Tomcat or like that). That solved my problem.
Include below dependency in your pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>{spring-version}</version>
</dependency>
I was facing the same Issue. When I saw into maven repository .m2 folder(....m2\repository\org\springframework\spring-webmvc) in my local I found two 3.2.0.RELEASE folders. SO I removed one.
Then I went to project, right click->properties->deployment essembly-> add maven dependencies.
clean build and then restart the server.
Then the DispatcherServlet got loaded.
Go to properties of Project which your working
Choose the Deployment Assembly menu and Click on add button
opt the Java Build Path Entries and Click on Maven Dependencies
Build the project and run
In my case I get this trouble after using the maven's update project utility.
I tried all the workarounds you suggested but nothing seemed to work.
At the end the solution was simply to remove the project from the server to ensure that it was clean, and add it again. Then it works, I hope this solution could help any of you.
You can use GlassFish server and the error will be resolved. I tried with tomcat7 and tomcat8 but this error was coming continuously but resolved with GlassFish. I think it's a problem with server.
These are the results with tomcat7:
Here are the results with GlassFish:
right click on your project and choose properties.
click on Deployement Assembly.
click add
click on "Java Build Path Entries"
select Maven Dependencies"
click Finish.
It may be useful for someone, so I'll post it here.
I was missing this dependency on my pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
I solved by following these steps:
Right click in the project > Configure > Convert to Maven project
After the conversion, right click in the project > Maven > Update project
This fixes the "Deployment Assembly" settings of the project.
Move the jar files from your classpath to web-inf/lib, and run a new tomcat server.
I found a simple solution,
Simply add your jars inside WEB-INF-->lib folder..
I had this same issue in WebSphere, but couldn't find a solution even though I verified the Spring dependencies were there and it ran in tomcat just fine. I ended up uninstalling the application and was still getting the error so I think WebSphere was hanging onto some corrupt instance.
To fix the issue I had to reinstall the application, stop it, uninstall it and then reinstall it.
For me it was a mistake in the pom.xml - I'd set <scope>provided<scope> on my dependencies, and this was making them not get copied during the mvn package stage.
My symptoms were the error message the OP posted, and that the jars were not included in the WEB-INF/lib path inside the .war after package was run. When I removed the scope, the jars appeared in the output, and all loads up fine now.

java hibernate 4 org.hibernate.HibernateException: Dialect class not found: org.hibernate.dialect.MYSQLDialect

I'm learning Java EE and Hibernate, and I've run into the following problem:
I've created a Dynamic Web Project in Eclipse, I've converted it into a MAVEN project, added the mysql-connector-java and the hibernate-core dependencies to the pom.xml.
I've added a servlet, and in the doGet method, I've tried to initialize the sessionfactory to create the tables. I'm using tomcat.
When I'm making a request to the servlet I'm getting the following exception:
org.hibernate.HibernateException: Dialect class not found: org.hibernate.dialect.MYSQLDialect
org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.constructDialect(DialectFactoryImpl.java:77)
org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:65)
org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:146)
org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:76)
org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:160)
org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:132)
org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1818)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1776)
hu.adamsan.testhibernate.TestHibernate.doGet(TestHibernate.java:74)
pom.xml:
dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.6.Final</version>
</dependency>
</dependencies>
I've tried to look into the Maven Dependencies, org.hibernate.dialect.MySQLDialect.class is in there, in the location: getServletContext().getRealPath(".") ->E:\eclips_jee\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\TestHibernateWeb\
, in the WEB-INF\lib directory, there is hibernate-core-4.2.6.Final.jar, when I opened it with 7zip, I could find inside the org/hibernate/dialect/MySQL5Dialect.class.
What am I missing? I really have no idea.
doGet method:
PrintWriter w = response.getWriter();
w.println("Testing hibernate<br/>");
w.println(getServletContext().getRealPath(".")+"<br/>");
Configuration config;
ServiceRegistry registry;
SessionFactory factory;
config = new Configuration().addAnnotatedClass(Modell.class);
Properties props = getProperties();
props.setProperty(Environment.HBM2DDL_AUTO, "create");
config.setProperties(props);
registry = new ServiceRegistryBuilder().applySettings(props).buildServiceRegistry();
factory = config.buildSessionFactory(registry);
factory.close();
The answer is in the question. You've found MySQLDialect and MySQL5Dialect in your jar files, but your configuration file tries to use MYSQLDialect. Java is case-sensitive.
I'm puting this because the above answer wasn't accurate for me, In my case I'm using Intellij IDEA While working with Hibernate dependency I was over configuring the pom dependency with a type (pom type) My solution is to remove that type.
<!-- Hibernate JPA dependency -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.6.3.Final</version>
<type>pom</type>
</dependency>
The working version Is :
<!-- Hibernate JPA dependency -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.6.3.Final</version>
</dependency>
NO POM TYPE
Which allowed to make ride of the following bug :
java.lang.TypeNotPresentException: Type org.hibernate.SessionFactory not present
that generally was blocking the resolve of the following property
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
and thus while doing the setup of hibernate session factory under the spring framework

RESTEasy on JBoss 5 - jars needed

We are running JBoss 5.1.0 and I'm trying to get just a simple test app up and running with RESTEasy. However, I cannot figure out what I need in order to do this. Apparently new versions of JBoss have everything included, but that doesn't help me. From what I understand, I need to modify the web.xml of my app to include the bootstrap and some other things. And then I need to include some jars in the WEB-INF/lib. This is where I'm stuck.
Do I need to include any jars in the server/lib in JBoss, or are they all supposed to be in the WEB-INF/lib of my app?
What jars do I need to include? We are not using Maven. I've seen very few tutorials actually mention which jars to use, and when I download RESTEasy there 65 jars in the lib folder. I'm not including 65 jars in my HelloWorld app just to get RESTEasy to run. I can't find any documentation that tells me plainly what I need in order to get a RESTEasy app up and running on JBoss 5
Resteasy libraries are not bundled with JBOSS.5.1.0.
You should include following libraries in your WEB-INF/lib
To add to Prasobh.K's answer - if using the pom.xml in a maven project setup - then you can just add the following inside the dependencies tags:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<version>2.3.4.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>2.3.4.Final</version>
</dependency>
<dependency>
<groupId>org.scannotation</groupId>
<artifactId>scannotation</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>2.3.4.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<version>2.3.4.Final</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.8.5</version>
</dependency>
(instead of copying the jars into the lib folder)
It may also help some doing a port from Wildfly to JBoss 5.1 that the
...\WEB-INF\web.xml should be changed to:
<?xml version="1.0" encoding="UTF-8"?>
from the wildfly version which is:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >